Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8dcba65ddf | |||
| 7e8667f80f | |||
| 8f73b78476 | |||
| 60a66e8783 | |||
| 14a1642fb8 |
@@ -6,11 +6,13 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
- 'feature/add-sentry'
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
env:
|
||||
DOCKER_USER: 1001:127
|
||||
SENTRY_DSN: ""
|
||||
|
||||
jobs:
|
||||
build-and-push-backend:
|
||||
@@ -109,7 +111,10 @@ jobs:
|
||||
context: .
|
||||
file: ./src/frontend/Dockerfile
|
||||
target: frontend-production
|
||||
build-args: DOCKER_USER=${{ env.DOCKER_USER }}:-1000
|
||||
build-args: |
|
||||
DOCKER_USER=${{ env.DOCKER_USER }}:-1000
|
||||
SENTRY_DSN=${{ env.SENTRY_DSN }}
|
||||
SENTRY_ENV=${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && 'production' || 'staging' }}
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
@@ -107,7 +107,9 @@ jobs:
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: "3.10"
|
||||
python-version: "3.12.6"
|
||||
- name: Upgrade pip and setuptools
|
||||
run: pip install --upgrade pip setuptools
|
||||
- name: Install development dependencies
|
||||
run: pip install --user .[dev]
|
||||
- name: Check code formatting with ruff
|
||||
@@ -199,7 +201,7 @@ jobs:
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: "3.10"
|
||||
python-version: "3.12.6"
|
||||
|
||||
- name: Install development dependencies
|
||||
run: pip install --user .[dev]
|
||||
|
||||
+1
-3
@@ -13,9 +13,7 @@ and this project adheres to
|
||||
|
||||
- 🌐(frontend) Add German translation #255
|
||||
- ✨(frontend) Add a broadcast store #387
|
||||
- ✨(frontend) WIP: New ui
|
||||
- 💄(frontend) Add left panel
|
||||
- 💄(frontend) update header layout #421
|
||||
- 🔊(project) Add sentry #410
|
||||
|
||||
## Changed
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ services:
|
||||
- "1081:1080"
|
||||
|
||||
minio:
|
||||
user: ${DOCKER_USER:-1000}
|
||||
# user: ${DOCKER_USER:-1000}
|
||||
image: minio/minio
|
||||
environment:
|
||||
- MINIO_ROOT_USER=impress
|
||||
|
||||
@@ -44,3 +44,6 @@ OIDC_AUTH_REQUEST_EXTRA_PARAMS={"acr_values": "eidas1"}
|
||||
AI_BASE_URL=https://openaiendpoint.com
|
||||
AI_API_KEY=password
|
||||
AI_MODEL=llama
|
||||
|
||||
# Sentry
|
||||
SENTRY_ENV=development
|
||||
|
||||
+1
-1
Submodule secrets updated: 38594182e8...d91797b97f
@@ -72,6 +72,8 @@ class AIService:
|
||||
|
||||
json_response = json.loads(sanitized_content)
|
||||
|
||||
raise RuntimeError("Error Test Sentry")
|
||||
|
||||
if "answer" not in json_response:
|
||||
raise RuntimeError("AI response does not contain an answer")
|
||||
|
||||
|
||||
@@ -10,14 +10,17 @@ For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/3.1/ref/settings/
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import tomllib
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
import sentry_sdk
|
||||
from configurations import Configuration, values
|
||||
from sentry_sdk.integrations.django import DjangoIntegration
|
||||
from logging import getLogger
|
||||
|
||||
logger = getLogger(__name__)
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
@@ -27,19 +30,12 @@ DATA_DIR = os.path.join("/", "data")
|
||||
def get_release():
|
||||
"""
|
||||
Get the current release of the application
|
||||
|
||||
By release, we mean the release from the version.json file à la Mozilla [1]
|
||||
(if any). If this file has not been found, it defaults to "NA".
|
||||
|
||||
[1]
|
||||
https://github.com/mozilla-services/Dockerflow/blob/master/docs/version_object.md
|
||||
"""
|
||||
# Try to get the current release from the version.json file generated by the
|
||||
# CI during the Docker image build
|
||||
try:
|
||||
with open(os.path.join(BASE_DIR, "version.json"), encoding="utf8") as version:
|
||||
return json.load(version)["version"]
|
||||
except FileNotFoundError:
|
||||
with open(os.path.join(BASE_DIR, "pyproject.toml"), "rb") as f:
|
||||
pyproject_data = tomllib.load(f)
|
||||
return pyproject_data["project"]["version"]
|
||||
except (FileNotFoundError, KeyError):
|
||||
return "NA" # Default: not available
|
||||
|
||||
|
||||
@@ -63,7 +59,7 @@ class Base(Configuration):
|
||||
* DB_USER
|
||||
"""
|
||||
|
||||
DEBUG = False
|
||||
DEBUG = True
|
||||
USE_SWAGGER = False
|
||||
|
||||
API_VERSION = "v1.0"
|
||||
@@ -372,7 +368,8 @@ class Base(Configuration):
|
||||
CORS_ALLOWED_ORIGIN_REGEXES = values.ListValue([])
|
||||
|
||||
# Sentry
|
||||
SENTRY_DSN = values.Value(None, environ_name="SENTRY_DSN")
|
||||
SENTRY_DSN = values.Value(None, environ_name="SENTRY_DSN", environ_prefix=None)
|
||||
SENTRY_ENV = values.Value(None, environ_name="SENTRY_ENV", environ_prefix=None)
|
||||
|
||||
# Easy thumbnails
|
||||
THUMBNAIL_EXTENSION = "webp"
|
||||
@@ -522,6 +519,10 @@ class Base(Configuration):
|
||||
|
||||
# The SENTRY_DSN setting should be available to activate sentry for an environment
|
||||
if cls.SENTRY_DSN is not None:
|
||||
logger.debug("Sentry is SENTRY_ENV. %s ", cls.SENTRY_ENV)
|
||||
logger.debug("Sentry is cls.__name__.lower(): %s ", cls.__name__.lower())
|
||||
print("Sentry is cls.__name__.lower(): %s ", cls.__name__.lower())
|
||||
print("Sentry is SENTRY_ENV. %s ", cls.SENTRY_ENV)
|
||||
sentry_sdk.init(
|
||||
dsn=cls.SENTRY_DSN,
|
||||
environment=cls.__name__.lower(),
|
||||
|
||||
@@ -127,6 +127,7 @@ select = [
|
||||
[tool.ruff.lint.isort]
|
||||
section-order = ["future","standard-library","django","third-party","impress","first-party","local-folder"]
|
||||
sections = { impress=["core"], django=["django"] }
|
||||
extra-standard-library = ["tomllib"]
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"**/tests/*" = ["S", "SLF"]
|
||||
|
||||
@@ -76,6 +76,12 @@ ENV NEXT_PUBLIC_MEDIA_URL=${MEDIA_URL}
|
||||
ARG SW_DEACTIVATED
|
||||
ENV NEXT_PUBLIC_SW_DEACTIVATED=${SW_DEACTIVATED}
|
||||
|
||||
ARG SENTRY_DSN
|
||||
ENV NEXT_PUBLIC_SENTRY_DSN=${SENTRY_DSN}
|
||||
|
||||
ARG SENTRY_ENV
|
||||
ENV NEXT_PUBLIC_SENTRY_ENV=${SENTRY_ENV}
|
||||
|
||||
RUN yarn build
|
||||
|
||||
# ---- Front-end image ----
|
||||
|
||||
@@ -36,7 +36,7 @@ export const createDoc = async (
|
||||
|
||||
await page
|
||||
.getByRole('button', {
|
||||
name: 'New doc',
|
||||
name: 'Create a new document',
|
||||
})
|
||||
.click();
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ test.describe('Doc Header', () => {
|
||||
test('it updates the title doc from editor heading', async ({ page }) => {
|
||||
await page
|
||||
.getByRole('button', {
|
||||
name: 'New doc',
|
||||
name: 'Create a new document',
|
||||
})
|
||||
.click();
|
||||
|
||||
@@ -159,7 +159,9 @@ test.describe('Doc Header', () => {
|
||||
page.getByText('The document has been deleted.'),
|
||||
).toBeVisible();
|
||||
|
||||
await expect(page.getByRole('button', { name: 'New do' })).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole('button', { name: 'Create a new document' }),
|
||||
).toBeVisible();
|
||||
|
||||
const row = page
|
||||
.getByLabel('Datagrid of the documents page 1')
|
||||
@@ -412,7 +414,7 @@ test.describe('Doc Header', () => {
|
||||
// create page and navigate to it
|
||||
await page
|
||||
.getByRole('button', {
|
||||
name: 'New doc',
|
||||
name: 'Create a new document',
|
||||
})
|
||||
.click();
|
||||
|
||||
@@ -447,7 +449,7 @@ test.describe('Doc Header', () => {
|
||||
// create page and navigate to it
|
||||
await page
|
||||
.getByRole('button', {
|
||||
name: 'New doc',
|
||||
name: 'Create a new document',
|
||||
})
|
||||
.click();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ test.describe('Doc Routing', () => {
|
||||
|
||||
test('Check the presence of the meta tag noindex', async ({ page }) => {
|
||||
const buttonCreateHomepage = page.getByRole('button', {
|
||||
name: 'New doc',
|
||||
name: 'Create a new document',
|
||||
});
|
||||
|
||||
await expect(buttonCreateHomepage).toBeVisible();
|
||||
@@ -27,7 +27,7 @@ test.describe('Doc Routing', () => {
|
||||
await expect(page).toHaveURL('/');
|
||||
|
||||
const buttonCreateHomepage = page.getByRole('button', {
|
||||
name: 'New doc',
|
||||
name: 'Create a new document',
|
||||
});
|
||||
|
||||
await expect(buttonCreateHomepage).toBeVisible();
|
||||
|
||||
@@ -36,7 +36,6 @@ test.describe('Doc Table Content', () => {
|
||||
await page.getByRole('button', { name: 'Strike' }).click();
|
||||
|
||||
await page.locator('.bn-block-outer').first().click();
|
||||
await editor.click();
|
||||
await page.locator('.bn-block-outer').last().click();
|
||||
|
||||
// Create space to fill the viewport
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
import { goToGridDoc } from './common';
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/');
|
||||
});
|
||||
|
||||
test.describe('Footer', () => {
|
||||
test('checks all the elements are visible', async ({ page }) => {
|
||||
const footer = page.locator('footer').first();
|
||||
|
||||
await expect(footer.getByAltText('Gouvernement Logo')).toBeVisible();
|
||||
|
||||
await expect(
|
||||
footer.getByRole('link', { name: 'legifrance.gouv.fr' }),
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
footer.getByRole('link', { name: 'info.gouv.fr' }),
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
footer.getByRole('link', { name: 'service-public.fr' }),
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
footer.getByRole('link', { name: 'data.gouv.fr' }),
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
footer.getByRole('link', { name: 'Legal Notice' }),
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
footer.getByRole('link', { name: 'Personal data and cookies' }),
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
footer.getByRole('link', { name: 'Accessibility' }),
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
footer.getByText(
|
||||
'Unless otherwise stated, all content on this site is under licence',
|
||||
),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('checks footer is not visible on doc editor', async ({ page }) => {
|
||||
await expect(page.locator('footer')).toBeVisible();
|
||||
await goToGridDoc(page);
|
||||
await expect(page.locator('footer')).toBeHidden();
|
||||
});
|
||||
|
||||
const legalPages = [
|
||||
{ name: 'Legal Notice', url: '/legal-notice/' },
|
||||
{ name: 'Personal data and cookies', url: '/personal-data-cookies/' },
|
||||
{ name: 'Accessibility', url: '/accessibility/' },
|
||||
];
|
||||
for (const { name, url } of legalPages) {
|
||||
test(`checks ${name} page`, async ({ page }) => {
|
||||
const footer = page.locator('footer').first();
|
||||
await footer.getByRole('link', { name }).click();
|
||||
|
||||
await expect(
|
||||
page
|
||||
.getByRole('heading', {
|
||||
name,
|
||||
})
|
||||
.first(),
|
||||
).toBeVisible();
|
||||
|
||||
await expect(page).toHaveURL(url);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -75,13 +75,29 @@ test.describe('Header mobile', () => {
|
||||
test('it checks the header when mobile', async ({ page }) => {
|
||||
const header = page.locator('header').first();
|
||||
|
||||
await expect(header.getByLabel('Open the header menu')).toBeVisible();
|
||||
await expect(
|
||||
header.getByRole('link', { name: 'Docs Logo Docs' }),
|
||||
header.getByRole('button', {
|
||||
name: 'Les services de La Suite numérique',
|
||||
}),
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
header.getByRole('button', { name: 'Les services de La Suite numé' }),
|
||||
page.getByRole('button', {
|
||||
name: 'Logout',
|
||||
}),
|
||||
).toBeHidden();
|
||||
|
||||
await expect(page.getByText('English')).toBeHidden();
|
||||
|
||||
await header.getByLabel('Open the header menu').click();
|
||||
|
||||
await expect(
|
||||
page.getByRole('button', {
|
||||
name: 'Logout',
|
||||
}),
|
||||
).toBeVisible();
|
||||
|
||||
await expect(page.getByText('English')).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -6,7 +6,11 @@ test.beforeEach(async ({ page }) => {
|
||||
|
||||
test.describe('Language', () => {
|
||||
test('checks the language picker', async ({ page }) => {
|
||||
await expect(page.getByLabel('Logout')).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole('button', {
|
||||
name: 'Create a new document',
|
||||
}),
|
||||
).toBeVisible();
|
||||
|
||||
const header = page.locator('header').first();
|
||||
await header.getByRole('combobox').getByText('English').click();
|
||||
@@ -15,7 +19,11 @@ test.describe('Language', () => {
|
||||
header.getByRole('combobox').getByText('Français'),
|
||||
).toBeVisible();
|
||||
|
||||
await expect(page.getByLabel('Se déconnecter')).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole('button', {
|
||||
name: 'Créer un nouveau document',
|
||||
}),
|
||||
).toBeVisible();
|
||||
|
||||
await header.getByRole('combobox').getByText('Français').click();
|
||||
await header.getByRole('option', { name: 'Deutsch' }).click();
|
||||
@@ -23,7 +31,11 @@ test.describe('Language', () => {
|
||||
header.getByRole('combobox').getByText('Deutsch'),
|
||||
).toBeVisible();
|
||||
|
||||
await expect(page.getByLabel('Abmelden')).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole('button', {
|
||||
name: 'Neues Dokument erstellen',
|
||||
}),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('checks that backend uses the same language as the frontend', async ({
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
test.describe('Left panel desktop', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/');
|
||||
});
|
||||
|
||||
test('checks all the elements are visible', async ({ page }) => {
|
||||
await expect(page.getByTestId('left-panel-desktop')).toBeVisible();
|
||||
await expect(page.getByTestId('left-panel-mobile')).toBeHidden();
|
||||
await expect(page.getByRole('button', { name: 'house' })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'New doc' })).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Left panel mobile', () => {
|
||||
test.use({ viewport: { width: 500, height: 1200 } });
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/');
|
||||
});
|
||||
|
||||
test('checks all the desktop elements are hidden and all mobile elements are visible', async ({
|
||||
page,
|
||||
}) => {
|
||||
await expect(page.getByTestId('left-panel-desktop')).toBeHidden();
|
||||
await expect(page.getByTestId('left-panel-mobile')).not.toBeInViewport();
|
||||
|
||||
const header = page.locator('header').first();
|
||||
const homeButton = page.getByRole('button', { name: 'house' });
|
||||
const newDocButton = page.getByRole('button', { name: 'New doc' });
|
||||
const languageButton = page.getByRole('combobox', { name: 'Language' });
|
||||
const logoutButton = page.getByRole('button', { name: 'Logout' });
|
||||
|
||||
await expect(homeButton).not.toBeInViewport();
|
||||
await expect(newDocButton).not.toBeInViewport();
|
||||
await expect(languageButton).not.toBeInViewport();
|
||||
await expect(logoutButton).not.toBeInViewport();
|
||||
|
||||
await header.getByLabel('Open the header menu').click();
|
||||
|
||||
await expect(page.getByTestId('left-panel-mobile')).toBeInViewport();
|
||||
await expect(homeButton).toBeInViewport();
|
||||
await expect(newDocButton).toBeInViewport();
|
||||
await expect(languageButton).toBeInViewport();
|
||||
await expect(logoutButton).toBeInViewport();
|
||||
});
|
||||
});
|
||||
@@ -3,3 +3,5 @@ NEXT_PUBLIC_Y_PROVIDER_URL=
|
||||
NEXT_PUBLIC_MEDIA_URL=
|
||||
NEXT_PUBLIC_THEME=dsfr
|
||||
NEXT_PUBLIC_SW_DEACTIVATED=
|
||||
NEXT_PUBLIC_SENTRY_DSN=
|
||||
NEXT_PUBLIC_SENTRY_ENV=production
|
||||
|
||||
@@ -2,3 +2,4 @@ NEXT_PUBLIC_API_ORIGIN=http://localhost:8071
|
||||
NEXT_PUBLIC_Y_PROVIDER_URL=ws://localhost:4444
|
||||
NEXT_PUBLIC_MEDIA_URL=http://localhost:8083
|
||||
NEXT_PUBLIC_SW_DEACTIVATED=true
|
||||
NEXT_PUBLIC_SENTRY_ENV=development
|
||||
|
||||
@@ -3,30 +3,24 @@ const config = {
|
||||
default: {
|
||||
theme: {
|
||||
colors: {
|
||||
'card-border': '#E5E5E5',
|
||||
'card-border': '#ededed',
|
||||
'primary-bg': '#FAFAFA',
|
||||
'primary-100': '#EDF5FA',
|
||||
'primary-150': '#E5EEFA',
|
||||
'info-150': '#E5EEFA',
|
||||
'greyscale-000': '#fff',
|
||||
'greyscale-1000': '#161616',
|
||||
},
|
||||
font: {
|
||||
sizes: {
|
||||
ml: '0.938rem',
|
||||
xl: '1.50rem',
|
||||
t: '0.6875rem',
|
||||
s: '0.75rem',
|
||||
xl: '20px',
|
||||
lg: '18px',
|
||||
md: '16px',
|
||||
sm: '14px',
|
||||
xs: '12px',
|
||||
h1: '32px',
|
||||
h2: '28px',
|
||||
h3: '24px',
|
||||
h4: '22px',
|
||||
h5: '20px',
|
||||
h6: '18px',
|
||||
h1: '2.2rem',
|
||||
h2: '1.7rem',
|
||||
h3: '1.37rem',
|
||||
h4: '1.15rem',
|
||||
h5: '1rem',
|
||||
h6: '0.87rem',
|
||||
},
|
||||
weights: {
|
||||
thin: 100,
|
||||
@@ -40,21 +34,6 @@ const config = {
|
||||
auto: 'auto',
|
||||
bx: '2.2rem',
|
||||
full: '100%',
|
||||
'050V': '2px',
|
||||
'100V': '4px',
|
||||
'150V': '6px',
|
||||
'100W': '8px',
|
||||
'300V': '12px',
|
||||
'200W': '16px',
|
||||
'300W': '24px',
|
||||
'400W': '32px',
|
||||
'500W': '40px',
|
||||
'600W': '48px',
|
||||
'700W': '56px',
|
||||
'800W': '64px',
|
||||
'900W': '72px',
|
||||
'1200W': '96px',
|
||||
'1500W': '120px',
|
||||
},
|
||||
breakpoints: {
|
||||
xxs: '320px',
|
||||
@@ -67,11 +46,6 @@ const config = {
|
||||
alt: '',
|
||||
},
|
||||
},
|
||||
global: {
|
||||
hover: {
|
||||
'greyscale-100': '#055fd214',
|
||||
},
|
||||
},
|
||||
components: {
|
||||
datagrid: {
|
||||
header: {
|
||||
@@ -130,7 +104,7 @@ const config = {
|
||||
focus: 'var(--c--components--forms-select--border-radius)',
|
||||
},
|
||||
'font-size': 'var(--c--theme--font--sizes--ml)',
|
||||
'menu-background-color': '#fff',
|
||||
'menu-background-color': '#ffffff',
|
||||
'item-background-color': {
|
||||
hover: 'var(--c--theme--colors--primary-300)',
|
||||
},
|
||||
@@ -152,7 +126,7 @@ const config = {
|
||||
},
|
||||
},
|
||||
modal: {
|
||||
'background-color': '#fff',
|
||||
'background-color': '#ffffff',
|
||||
},
|
||||
button: {
|
||||
'border-radius': {
|
||||
@@ -222,23 +196,6 @@ const config = {
|
||||
},
|
||||
dsfr: {
|
||||
theme: {
|
||||
spacings: {
|
||||
'050V': '2px',
|
||||
'100V': '4px',
|
||||
'150V': '6px',
|
||||
'100W': '8px',
|
||||
'300V': '12px',
|
||||
'200W': '16px',
|
||||
'300W': '24px',
|
||||
'400W': '32px',
|
||||
'500W': '40px',
|
||||
'600W': '48px',
|
||||
'700W': '56px',
|
||||
'800W': '64px',
|
||||
'900W': '72px',
|
||||
'1200W': '96px',
|
||||
'1500W': '120px',
|
||||
},
|
||||
colors: {
|
||||
'card-border': '#ededed',
|
||||
'primary-text': '#000091',
|
||||
@@ -252,7 +209,7 @@ const config = {
|
||||
'primary-700': '#272747',
|
||||
'primary-800': '#21213f',
|
||||
'primary-900': '#1c1a36',
|
||||
'secondary-text': '#fff',
|
||||
'secondary-text': '#FFFFFF',
|
||||
'secondary-100': '#fee9ea',
|
||||
'secondary-200': '#fedfdf',
|
||||
'secondary-300': '#fdbfbf',
|
||||
@@ -263,16 +220,16 @@ const config = {
|
||||
'secondary-800': '#341f1f',
|
||||
'secondary-900': '#2b1919',
|
||||
'greyscale-text': '#303C4B',
|
||||
'greyscale-000': '#fff',
|
||||
'greyscale-050': '#F6F6F6',
|
||||
'greyscale-100': '#eee',
|
||||
'greyscale-200': '#E5E5E5',
|
||||
'greyscale-250': '#ddd',
|
||||
'greyscale-300': '#CECECE',
|
||||
'greyscale-400': '#929292',
|
||||
'greyscale-500': '#666',
|
||||
'greyscale-700': '#3A3A3A',
|
||||
'greyscale-1000': '#161616',
|
||||
'greyscale-000': '#f6f6f6',
|
||||
'greyscale-100': '#eeeeee',
|
||||
'greyscale-200': '#e5e5e5',
|
||||
'greyscale-300': '#e1e1e1',
|
||||
'greyscale-400': '#dddddd',
|
||||
'greyscale-500': '#cecece',
|
||||
'greyscale-600': '#7b7b7b',
|
||||
'greyscale-700': '#666666',
|
||||
'greyscale-800': '#2a2a2a',
|
||||
'greyscale-900': '#1e1e1e',
|
||||
'success-text': '#1f8d49',
|
||||
'success-100': '#dffee6',
|
||||
'success-200': '#b8fec9',
|
||||
@@ -319,22 +276,6 @@ const config = {
|
||||
accent: 'Marianne',
|
||||
base: 'Marianne',
|
||||
},
|
||||
size: {
|
||||
ml: '0.938rem',
|
||||
t: '0.6875rem',
|
||||
s: '0.75rem',
|
||||
xl: '20px',
|
||||
lg: '18px',
|
||||
md: '16px',
|
||||
sm: '14px',
|
||||
xs: '12px',
|
||||
h1: '32px',
|
||||
h2: '28px',
|
||||
h3: '24px',
|
||||
h4: '22px',
|
||||
h5: '20px',
|
||||
h6: '18px',
|
||||
},
|
||||
},
|
||||
logo: {
|
||||
src: '/assets/logo-gouv.svg',
|
||||
@@ -356,9 +297,9 @@ const config = {
|
||||
'color-hover': '#1212ff',
|
||||
'color-active': '#2323ff',
|
||||
},
|
||||
color: '#fff',
|
||||
'color-hover': '#fff',
|
||||
'color-active': '#fff',
|
||||
color: '#ffffff',
|
||||
'color-hover': '#ffffff',
|
||||
'color-active': '#ffffff',
|
||||
},
|
||||
'primary-text': {
|
||||
background: {
|
||||
@@ -422,7 +363,7 @@ const config = {
|
||||
},
|
||||
'forms-input': {
|
||||
'border-radius': '4px',
|
||||
'background-color': '#fff',
|
||||
'background-color': '#ffffff',
|
||||
'border-color': 'var(--c--theme--colors--primary-text)',
|
||||
'box-shadow-color': 'var(--c--theme--colors--primary-text)',
|
||||
'value-color': 'var(--c--theme--colors--primary-text)',
|
||||
@@ -440,7 +381,7 @@ const config = {
|
||||
'item-font-size': '14px',
|
||||
'border-radius': '4px',
|
||||
'border-radius-hover': '4px',
|
||||
'background-color': '#fff',
|
||||
'background-color': '#ffffff',
|
||||
'border-color': 'var(--c--theme--colors--primary-text)',
|
||||
'border-color-hover': 'var(--c--theme--colors--primary-text)',
|
||||
'box-shadow-color': 'var(--c--theme--colors--primary-text)',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const crypto = require('crypto');
|
||||
|
||||
const { withSentryConfig } = require('@sentry/nextjs');
|
||||
const { InjectManifest } = require('workbox-webpack-plugin');
|
||||
|
||||
const buildId = crypto.randomBytes(256).toString('hex').slice(0, 8);
|
||||
@@ -65,4 +66,6 @@ const nextConfig = {
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = nextConfig;
|
||||
module.exports = withSentryConfig(nextConfig, {
|
||||
silent: false,
|
||||
});
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
"@gouvfr-lasuite/integration": "1.0.2",
|
||||
"@hocuspocus/provider": "2.13.7",
|
||||
"@openfun/cunningham-react": "2.9.4",
|
||||
"@sentry/nextjs": "8.37.1",
|
||||
"@tanstack/react-query": "5.59.15",
|
||||
"i18next": "23.16.2",
|
||||
"i18next-browser-languagedetector": "8.0.0",
|
||||
@@ -33,7 +34,6 @@
|
||||
"react-dom": "*",
|
||||
"react-i18next": "15.0.3",
|
||||
"react-select": "5.8.1",
|
||||
"react-intersection-observer": "9.13.1",
|
||||
"styled-components": "6.1.13",
|
||||
"y-protocols": "1.0.6",
|
||||
"yjs": "*",
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import * as Sentry from '@sentry/nextjs';
|
||||
|
||||
import packageJson from './package.json';
|
||||
|
||||
Sentry.init({
|
||||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
environment: process.env.NEXT_PUBLIC_SENTRY_ENV,
|
||||
integrations: [Sentry.replayIntegration()],
|
||||
release: packageJson.version,
|
||||
replaysSessionSampleRate: 0.1,
|
||||
replaysOnErrorSampleRate: 1.0,
|
||||
tracesSampleRate: 1.0,
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
import '@testing-library/jest-dom';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
|
||||
import { AppWrapper } from '@/tests/utils';
|
||||
|
||||
import Page from '../pages';
|
||||
|
||||
jest.mock('next/navigation', () => ({
|
||||
useRouter() {
|
||||
return {
|
||||
push: jest.fn(),
|
||||
};
|
||||
},
|
||||
}));
|
||||
|
||||
describe('Page', () => {
|
||||
it('checks Page rendering', () => {
|
||||
render(<Page />, { wrapper: AppWrapper });
|
||||
|
||||
expect(
|
||||
screen.getByRole('button', {
|
||||
name: /Create a new document/i,
|
||||
}),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ComponentPropsWithRef, ReactHTML } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { CSSProperties, RuleSet } from 'styled-components/dist/types';
|
||||
import { CSSProperties } from 'styled-components/dist/types';
|
||||
|
||||
import {
|
||||
MarginPadding,
|
||||
@@ -15,7 +15,7 @@ export interface BoxProps {
|
||||
$align?: CSSProperties['alignItems'];
|
||||
$background?: CSSProperties['background'];
|
||||
$color?: CSSProperties['color'];
|
||||
$css?: string | RuleSet<object>;
|
||||
$css?: string;
|
||||
$direction?: CSSProperties['flexDirection'];
|
||||
$display?: CSSProperties['display'];
|
||||
$effect?: 'show' | 'hide';
|
||||
@@ -45,7 +45,6 @@ export type BoxType = ComponentPropsWithRef<typeof Box>;
|
||||
export const Box = styled('div')<BoxProps>`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
${({ $align }) => $align && `align-items: ${$align};`}
|
||||
${({ $background }) => $background && `background: ${$background};`}
|
||||
${({ $color }) => $color && `color: ${$color};`}
|
||||
@@ -74,7 +73,7 @@ export const Box = styled('div')<BoxProps>`
|
||||
${({ $transition }) => $transition && `transition: ${$transition};`}
|
||||
${({ $width }) => $width && `width: ${$width};`}
|
||||
${({ $wrap }) => $wrap && `flex-wrap: ${$wrap};`}
|
||||
${({ $css }) => $css && (typeof $css === 'string' ? `${$css};` : $css)}
|
||||
${({ $css }) => $css && `${$css};`}
|
||||
${({ $zIndex }) => $zIndex && `z-index: ${$zIndex};`}
|
||||
${({ $effect }) => {
|
||||
let effect;
|
||||
|
||||
@@ -16,7 +16,7 @@ export const Card = ({
|
||||
$background="white"
|
||||
$radius="4px"
|
||||
$css={`
|
||||
|
||||
box-shadow: 2px 2px 5px ${colorsTokens()['greyscale-300']};
|
||||
border: 1px solid ${colorsTokens()['card-border']};
|
||||
${$css}
|
||||
`}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { PropsWithChildren, ReactNode, useEffect, useState } from 'react';
|
||||
import React, {
|
||||
PropsWithChildren,
|
||||
ReactNode,
|
||||
useEffect,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { Button, DialogTrigger, Popover } from 'react-aria-components';
|
||||
import styled from 'styled-components';
|
||||
|
||||
@@ -24,7 +29,7 @@ const StyledButton = styled(Button)`
|
||||
text-wrap: nowrap;
|
||||
`;
|
||||
|
||||
export interface DropButtonProps {
|
||||
interface DropButtonProps {
|
||||
button: ReactNode;
|
||||
isOpen?: boolean;
|
||||
onOpenChange?: (isOpen: boolean) => void;
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
import { Text, TextType } from '@/components';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
|
||||
type Props = {
|
||||
iconName: string;
|
||||
className?: string;
|
||||
};
|
||||
export const Icon = ({ iconName, className }: Props) => {
|
||||
return <span className={`material-icons ${className}`}>{iconName}</span>;
|
||||
};
|
||||
|
||||
interface IconBGProps extends TextType {
|
||||
iconName: string;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ export interface TextProps extends BoxProps {
|
||||
$weight?: CSSProperties['fontWeight'];
|
||||
$textAlign?: CSSProperties['textAlign'];
|
||||
$size?: TextSizes | (string & {});
|
||||
|
||||
$theme?:
|
||||
| 'primary'
|
||||
| 'secondary'
|
||||
@@ -32,7 +31,6 @@ export interface TextProps extends BoxProps {
|
||||
| 'warning'
|
||||
| 'danger'
|
||||
| 'greyscale';
|
||||
|
||||
$variation?:
|
||||
| 'text'
|
||||
| '100'
|
||||
@@ -43,8 +41,7 @@ export interface TextProps extends BoxProps {
|
||||
| '600'
|
||||
| '700'
|
||||
| '800'
|
||||
| '900'
|
||||
| '1000';
|
||||
| '900';
|
||||
}
|
||||
|
||||
export type TextType = ComponentPropsWithRef<typeof Text>;
|
||||
@@ -66,16 +63,14 @@ export const TextStyled = styled(Box)<TextProps>`
|
||||
const Text = forwardRef<HTMLElement, ComponentPropsWithRef<typeof TextStyled>>(
|
||||
({ className, $isMaterialIcon, ...props }, ref) => {
|
||||
return (
|
||||
<>
|
||||
<TextStyled
|
||||
ref={ref}
|
||||
as="span"
|
||||
$theme={props.$theme ?? 'greyscale'}
|
||||
$variation={props.$variation ?? 'text'}
|
||||
className={`${className || ''}${$isMaterialIcon ? ' material-icons' : ''}`}
|
||||
{...props}
|
||||
/>
|
||||
</>
|
||||
<TextStyled
|
||||
ref={ref}
|
||||
as="span"
|
||||
$theme="greyscale"
|
||||
$variation="text"
|
||||
className={`${className || ''}${$isMaterialIcon ? ' material-icons' : ''}`}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
import { PropsWithChildren, useMemo } from 'react';
|
||||
|
||||
import { DropButton, DropButtonProps } from '@/components';
|
||||
import { Icon } from '@/components/Icon';
|
||||
|
||||
import styles from './dropdown-menu.module.scss';
|
||||
|
||||
export type DropdownMenuOption = {
|
||||
icon?: string;
|
||||
label: string;
|
||||
callback?: () => void | Promise<unknown>;
|
||||
danger?: boolean;
|
||||
show?: boolean;
|
||||
};
|
||||
|
||||
export type DropdownMenuProps = Omit<DropButtonProps, 'button'> & {
|
||||
options: DropdownMenuOption[];
|
||||
showArrow?: boolean;
|
||||
arrowClassname?: string;
|
||||
};
|
||||
|
||||
export const DropdownMenu = ({
|
||||
options,
|
||||
children,
|
||||
showArrow = false,
|
||||
arrowClassname,
|
||||
...dropButtonProps
|
||||
}: PropsWithChildren<DropdownMenuProps>) => {
|
||||
const showDropdown = useMemo(() => {
|
||||
let show = false;
|
||||
options.forEach((option) => {
|
||||
show = show || (option.show !== undefined ? option.show : true);
|
||||
});
|
||||
return show;
|
||||
}, [options]);
|
||||
|
||||
const getButton = () => {
|
||||
if (!showArrow) {
|
||||
return children;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.withArrowContainer}>
|
||||
<div>{children}</div>
|
||||
<Icon
|
||||
className={arrowClassname ?? 'clr-primary-600'}
|
||||
iconName={
|
||||
dropButtonProps.isOpen ? 'arrow_drop_up' : 'arrow_drop_down'
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
if (!showDropdown) {
|
||||
return;
|
||||
}
|
||||
|
||||
return (
|
||||
<DropButton {...dropButtonProps} button={getButton()}>
|
||||
<div className={styles.listOption}>
|
||||
{options.map((option) => {
|
||||
if (option.show !== undefined && !option.show) {
|
||||
return;
|
||||
}
|
||||
return (
|
||||
<button
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
dropButtonProps.onOpenChange?.(false);
|
||||
void option.callback?.();
|
||||
}}
|
||||
key={option.label}
|
||||
className={styles.item}
|
||||
>
|
||||
{option.icon && (
|
||||
<Icon className={styles.itemIcon} iconName={option.icon} />
|
||||
)}
|
||||
{option.label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</DropButton>
|
||||
);
|
||||
};
|
||||
@@ -1,42 +0,0 @@
|
||||
.simpleContent {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--c--theme--spacings--st);
|
||||
}
|
||||
|
||||
.listOption {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.item:not(:last-child) {
|
||||
border-bottom: 1px solid var(--c--theme--colors--greyscale-200);
|
||||
}
|
||||
}
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--c--theme--spacings--200W);
|
||||
border: none;
|
||||
background-color: white;
|
||||
font-size: var(--c--theme--font--sizes--sm);
|
||||
color: var(--c--theme--colors--primary-600);
|
||||
font-weight: 500;
|
||||
padding: var(--c--theme--spacings--100W) var(--c--theme--spacings--200W);
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--c--theme--colors--greyscale-050);
|
||||
}
|
||||
|
||||
.itemIcon {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.withArrowContainer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { useState } from 'react';
|
||||
|
||||
export const useDropdownMenu = () => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
const onOpenChange = (isOpen: boolean) => {
|
||||
setIsOpen(isOpen);
|
||||
};
|
||||
|
||||
return {
|
||||
isOpen,
|
||||
onOpenChange,
|
||||
};
|
||||
};
|
||||
@@ -1,34 +0,0 @@
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
|
||||
import { Box } from '../Box';
|
||||
|
||||
export enum SeparatorVariant {
|
||||
LIGHT = 'light',
|
||||
DARK = 'dark',
|
||||
}
|
||||
|
||||
type Props = {
|
||||
variant?: SeparatorVariant;
|
||||
};
|
||||
|
||||
export const HorizontalSeparator = ({
|
||||
variant = SeparatorVariant.LIGHT,
|
||||
}: Props) => {
|
||||
const { colorsTokens, themeTokens } = useCunninghamTheme();
|
||||
const colors = colorsTokens();
|
||||
const spacings = themeTokens().spacings;
|
||||
return (
|
||||
<Box
|
||||
$css={`
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
margin: ${spacings?.['300W'] ?? '0.5rem'} 0 ;
|
||||
background-color: ${
|
||||
variant === SeparatorVariant.LIGHT
|
||||
? colors['greyscale-200']
|
||||
: colors['greyscale-800']
|
||||
};
|
||||
`}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -1,29 +0,0 @@
|
||||
import { PropsWithChildren } from 'react';
|
||||
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
|
||||
import { Box } from '../Box';
|
||||
|
||||
type Props = {
|
||||
showSeparator?: boolean;
|
||||
};
|
||||
|
||||
export const SeparatedSection = ({
|
||||
showSeparator = true,
|
||||
children,
|
||||
}: PropsWithChildren<Props>) => {
|
||||
const theme = useCunninghamTheme();
|
||||
const colors = theme.colorsTokens();
|
||||
return (
|
||||
<Box
|
||||
className="toto"
|
||||
$padding={{ vertical: '100V' }}
|
||||
$css={`
|
||||
padding: 12px 0;
|
||||
${showSeparator ? `border-bottom: 1px solid ${(colors?.['greyscale-200'] as string) ?? '#E5E5E5'};` : ''}
|
||||
`}
|
||||
>
|
||||
{children}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@ export const tokens = {
|
||||
'secondary-700': '#97A3AE',
|
||||
'secondary-800': '#757E87',
|
||||
'secondary-900': '#596067',
|
||||
'info-text': '#fff',
|
||||
'info-text': '#FFFFFF',
|
||||
'info-100': '#EBF2FC',
|
||||
'info-200': '#8CB5EA',
|
||||
'info-300': '#5894E1',
|
||||
@@ -32,7 +32,7 @@ export const tokens = {
|
||||
'greyscale-700': '#555F6B',
|
||||
'greyscale-800': '#303C4B',
|
||||
'greyscale-900': '#0C1A2B',
|
||||
'greyscale-000': '#fff',
|
||||
'greyscale-000': '#FFFFFF',
|
||||
'primary-100': '#EDF5FA',
|
||||
'primary-200': '#8CB5EA',
|
||||
'primary-300': '#5894E1',
|
||||
@@ -69,34 +69,29 @@ export const tokens = {
|
||||
'danger-700': '#9B0000',
|
||||
'danger-800': '#780000',
|
||||
'danger-900': '#5C0000',
|
||||
'primary-text': '#fff',
|
||||
'success-text': '#fff',
|
||||
'warning-text': '#fff',
|
||||
'danger-text': '#fff',
|
||||
'card-border': '#E5E5E5',
|
||||
'primary-text': '#FFFFFF',
|
||||
'success-text': '#FFFFFF',
|
||||
'warning-text': '#FFFFFF',
|
||||
'danger-text': '#FFFFFF',
|
||||
'card-border': '#ededed',
|
||||
'primary-bg': '#FAFAFA',
|
||||
'primary-150': '#E5EEFA',
|
||||
'info-150': '#E5EEFA',
|
||||
'greyscale-1000': '#161616',
|
||||
},
|
||||
font: {
|
||||
sizes: {
|
||||
h1: '32px',
|
||||
h2: '28px',
|
||||
h3: '24px',
|
||||
h4: '22px',
|
||||
h5: '20px',
|
||||
h6: '18px',
|
||||
h1: '2.2rem',
|
||||
h2: '1.7rem',
|
||||
h3: '1.37rem',
|
||||
h4: '1.15rem',
|
||||
h5: '1rem',
|
||||
h6: '0.87rem',
|
||||
l: '1rem',
|
||||
m: '0.8125rem',
|
||||
s: '0.75rem',
|
||||
ml: '0.938rem',
|
||||
xl: '1.50rem',
|
||||
t: '0.6875rem',
|
||||
xl: '20px',
|
||||
lg: '18px',
|
||||
md: '16px',
|
||||
sm: '14px',
|
||||
xs: '12px',
|
||||
},
|
||||
weights: {
|
||||
thin: 100,
|
||||
@@ -135,21 +130,6 @@ export const tokens = {
|
||||
auto: 'auto',
|
||||
bx: '2.2rem',
|
||||
full: '100%',
|
||||
'050V': '2px',
|
||||
'100V': '4px',
|
||||
'150V': '6px',
|
||||
'100W': '8px',
|
||||
'300V': '12px',
|
||||
'200W': '16px',
|
||||
'300W': '24px',
|
||||
'400W': '32px',
|
||||
'500W': '40px',
|
||||
'600W': '48px',
|
||||
'700W': '56px',
|
||||
'800W': '64px',
|
||||
'900W': '72px',
|
||||
'1200W': '96px',
|
||||
'1500W': '120px',
|
||||
},
|
||||
transitions: {
|
||||
'ease-in': 'cubic-bezier(0.32, 0, 0.67, 0)',
|
||||
@@ -222,7 +202,7 @@ export const tokens = {
|
||||
focus: 'var(--c--components--forms-select--border-radius)',
|
||||
},
|
||||
'font-size': 'var(--c--theme--font--sizes--ml)',
|
||||
'menu-background-color': '#fff',
|
||||
'menu-background-color': '#ffffff',
|
||||
'item-background-color': {
|
||||
hover: 'var(--c--theme--colors--primary-300)',
|
||||
},
|
||||
@@ -243,7 +223,7 @@ export const tokens = {
|
||||
'border-color-hover': 'var(--c--theme--colors--greyscale-200)',
|
||||
},
|
||||
},
|
||||
modal: { 'background-color': '#fff' },
|
||||
modal: { 'background-color': '#ffffff' },
|
||||
button: {
|
||||
'border-radius': {
|
||||
active: 'var(--c--components--button--border-radius)',
|
||||
@@ -353,23 +333,6 @@ export const tokens = {
|
||||
},
|
||||
dsfr: {
|
||||
theme: {
|
||||
spacings: {
|
||||
'050V': '2px',
|
||||
'100V': '4px',
|
||||
'150V': '6px',
|
||||
'100W': '8px',
|
||||
'300V': '12px',
|
||||
'200W': '16px',
|
||||
'300W': '24px',
|
||||
'400W': '32px',
|
||||
'500W': '40px',
|
||||
'600W': '48px',
|
||||
'700W': '56px',
|
||||
'800W': '64px',
|
||||
'900W': '72px',
|
||||
'1200W': '96px',
|
||||
'1500W': '120px',
|
||||
},
|
||||
colors: {
|
||||
'card-border': '#ededed',
|
||||
'primary-text': '#000091',
|
||||
@@ -383,7 +346,7 @@ export const tokens = {
|
||||
'primary-700': '#272747',
|
||||
'primary-800': '#21213f',
|
||||
'primary-900': '#1c1a36',
|
||||
'secondary-text': '#fff',
|
||||
'secondary-text': '#FFFFFF',
|
||||
'secondary-100': '#fee9ea',
|
||||
'secondary-200': '#fedfdf',
|
||||
'secondary-300': '#fdbfbf',
|
||||
@@ -394,16 +357,16 @@ export const tokens = {
|
||||
'secondary-800': '#341f1f',
|
||||
'secondary-900': '#2b1919',
|
||||
'greyscale-text': '#303C4B',
|
||||
'greyscale-000': '#fff',
|
||||
'greyscale-050': '#F6F6F6',
|
||||
'greyscale-100': '#eee',
|
||||
'greyscale-200': '#E5E5E5',
|
||||
'greyscale-250': '#ddd',
|
||||
'greyscale-300': '#CECECE',
|
||||
'greyscale-400': '#929292',
|
||||
'greyscale-500': '#666',
|
||||
'greyscale-700': '#3A3A3A',
|
||||
'greyscale-1000': '#161616',
|
||||
'greyscale-000': '#f6f6f6',
|
||||
'greyscale-100': '#eeeeee',
|
||||
'greyscale-200': '#e5e5e5',
|
||||
'greyscale-300': '#e1e1e1',
|
||||
'greyscale-400': '#dddddd',
|
||||
'greyscale-500': '#cecece',
|
||||
'greyscale-600': '#7b7b7b',
|
||||
'greyscale-700': '#666666',
|
||||
'greyscale-800': '#2a2a2a',
|
||||
'greyscale-900': '#1e1e1e',
|
||||
'success-text': '#1f8d49',
|
||||
'success-100': '#dffee6',
|
||||
'success-200': '#b8fec9',
|
||||
@@ -445,25 +408,7 @@ export const tokens = {
|
||||
'danger-800': '#412121',
|
||||
'danger-900': '#3a1c1c',
|
||||
},
|
||||
font: {
|
||||
families: { accent: 'Marianne', base: 'Marianne' },
|
||||
size: {
|
||||
ml: '0.938rem',
|
||||
t: '0.6875rem',
|
||||
s: '0.75rem',
|
||||
xl: '20px',
|
||||
lg: '18px',
|
||||
md: '16px',
|
||||
sm: '14px',
|
||||
xs: '12px',
|
||||
h1: '32px',
|
||||
h2: '28px',
|
||||
h3: '24px',
|
||||
h4: '22px',
|
||||
h5: '20px',
|
||||
h6: '18px',
|
||||
},
|
||||
},
|
||||
font: { families: { accent: 'Marianne', base: 'Marianne' } },
|
||||
logo: {
|
||||
src: '/assets/logo-gouv.svg',
|
||||
widthHeader: '110px',
|
||||
@@ -482,9 +427,9 @@ export const tokens = {
|
||||
'color-hover': '#1212ff',
|
||||
'color-active': '#2323ff',
|
||||
},
|
||||
color: '#fff',
|
||||
'color-hover': '#fff',
|
||||
'color-active': '#fff',
|
||||
color: '#ffffff',
|
||||
'color-hover': '#ffffff',
|
||||
'color-active': '#ffffff',
|
||||
},
|
||||
'primary-text': {
|
||||
background: {
|
||||
@@ -541,7 +486,7 @@ export const tokens = {
|
||||
},
|
||||
'forms-input': {
|
||||
'border-radius': '4px',
|
||||
'background-color': '#fff',
|
||||
'background-color': '#ffffff',
|
||||
'border-color': 'var(--c--theme--colors--primary-text)',
|
||||
'box-shadow-color': 'var(--c--theme--colors--primary-text)',
|
||||
'value-color': 'var(--c--theme--colors--primary-text)',
|
||||
@@ -557,7 +502,7 @@ export const tokens = {
|
||||
'item-font-size': '14px',
|
||||
'border-radius': '4px',
|
||||
'border-radius-hover': '4px',
|
||||
'background-color': '#fff',
|
||||
'background-color': '#ffffff',
|
||||
'border-color': 'var(--c--theme--colors--primary-text)',
|
||||
'border-color-hover': 'var(--c--theme--colors--primary-text)',
|
||||
'box-shadow-color': 'var(--c--theme--colors--primary-text)',
|
||||
|
||||
@@ -5,7 +5,6 @@ import { tokens } from './cunningham-tokens';
|
||||
|
||||
type Tokens = typeof tokens.themes.default & Partial<typeof tokens.themes.dsfr>;
|
||||
type ColorsTokens = Tokens['theme']['colors'];
|
||||
type SpacingsTokens = Tokens['theme']['spacings'];
|
||||
type ComponentTokens = Tokens['components'];
|
||||
type Theme = 'default' | 'dsfr';
|
||||
|
||||
@@ -14,7 +13,6 @@ interface AuthStore {
|
||||
setTheme: (theme: Theme) => void;
|
||||
themeTokens: () => Partial<Tokens['theme']>;
|
||||
colorsTokens: () => Partial<ColorsTokens>;
|
||||
spacingsTokens: () => SpacingsTokens;
|
||||
componentTokens: () => ComponentTokens;
|
||||
}
|
||||
|
||||
@@ -27,7 +25,6 @@ const useCunninghamTheme = create<AuthStore>((set, get) => {
|
||||
themeTokens: () => currentTheme().theme,
|
||||
colorsTokens: () => currentTheme().theme.colors,
|
||||
componentTokens: () => currentTheme().components,
|
||||
spacingsTokens: () => currentTheme().theme.spacings,
|
||||
setTheme: (theme: Theme) => {
|
||||
set({ theme });
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Alert, Loader, VariantType } from '@openfun/cunningham-react';
|
||||
import { useRouter as useNavigate } from 'next/navigation';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useEffect } from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Box, Card, Text, TextErrors } from '@/components';
|
||||
@@ -58,10 +58,10 @@ export const DocEditor = ({ doc }: DocEditorProps) => {
|
||||
)}
|
||||
<Box
|
||||
$background={colorsTokens()['primary-bg']}
|
||||
$height="100%"
|
||||
$direction="row"
|
||||
$width="100%"
|
||||
$margin={{ all: isMobile ? 'tiny' : 'small', top: 'none' }}
|
||||
$css="overflow-x: clip; flex: 1;"
|
||||
$css="overflow-x: clip;"
|
||||
$position="relative"
|
||||
>
|
||||
<Card
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Fragment } from 'react';
|
||||
import React, { Fragment } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Box, Card, StyledLink, Text } from '@/components';
|
||||
@@ -32,7 +32,6 @@ export const DocHeader = ({ doc, versionId }: DocHeaderProps) => {
|
||||
return (
|
||||
<>
|
||||
<Card
|
||||
$width="100%"
|
||||
$margin={isMobile ? 'tiny' : 'small'}
|
||||
aria-label={t('It is the card information about the document.')}
|
||||
>
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
UseQueryOptions,
|
||||
useInfiniteQuery,
|
||||
useQuery,
|
||||
} from '@tanstack/react-query';
|
||||
import { UseQueryOptions, useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { APIError, APIList, errorCauses, fetchAPI } from '@/api';
|
||||
|
||||
@@ -56,14 +52,3 @@ export function useDocs(
|
||||
...queryConfig,
|
||||
});
|
||||
}
|
||||
|
||||
export const useInfiniteDocs = (params: DocsParams) => {
|
||||
return useInfiniteQuery({
|
||||
initialPageParam: 1,
|
||||
queryKey: [KEY_LIST_DOC, 'infinite', params],
|
||||
queryFn: ({ pageParam }) => getDocs({ ...params, page: pageParam }),
|
||||
getNextPageParam: (lastPage, allPages) => {
|
||||
return lastPage.next ? allPages.length + 1 : undefined;
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<svg width="32" height="36" viewBox="0 0 32 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="2.01394" y="1.23611" width="25.9722" height="33.5278" rx="3.54167" fill="white"/>
|
||||
<rect x="2.01394" y="1.23611" width="25.9722" height="33.5278" rx="3.54167" stroke="#DCDCFC" stroke-width="0.472222"/>
|
||||
<path d="M6.5 8.55556H15" stroke="#6A6AF4" stroke-width="1.88889" stroke-linecap="round"/>
|
||||
<path d="M6.5 11.3889H23.5M6.5 14.2222H23.5M6.5 17.0556H23.5M6.5 19.8889H23.5M6.5 22.7222H20.6667" stroke="#CACAFB" stroke-width="1.88889" stroke-linecap="round"/>
|
||||
<rect x="7" y="10" width="16" height="16" rx="8" fill="#6A6AF4"/>
|
||||
<rect x="7" y="10" width="16" height="16" rx="8" stroke="white" stroke-width="1.5"/>
|
||||
<path d="M16.8 18L18 19.2V20.1H15.45V22.95L15 23.4L14.55 22.95V20.1H12V19.2L13.2 18V14.7H12.6V13.8H17.4V14.7H16.8V18Z" fill="white"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 853 B |
@@ -1,6 +0,0 @@
|
||||
<svg width="28" height="34" viewBox="0 0 28 34" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="1.01394" y="0.236111" width="25.9722" height="33.5278" rx="3.54167" fill="white"/>
|
||||
<rect x="1.01394" y="0.236111" width="25.9722" height="33.5278" rx="3.54167" stroke="#DCDCFC" stroke-width="0.472222"/>
|
||||
<path d="M5.5 7.55554H14" stroke="#6A6AF4" stroke-width="1.88889" stroke-linecap="round"/>
|
||||
<path d="M5.5 10.3889H22.5M5.5 13.2222H22.5M5.5 16.0556H22.5M5.5 18.8889H22.5M5.5 21.7222H22.5M5.5 24.5556H22.5M5.5 27.3889H22.5M5.5 30.2222H22.5M5.5 33.0556H22.5" stroke="#CACAFB" stroke-width="1.88889" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 635 B |
-60
@@ -1,60 +0,0 @@
|
||||
import { ReactNode } from 'react';
|
||||
import styled, { css } from 'styled-components';
|
||||
|
||||
import { Box, Text } from '@/components';
|
||||
import { Doc } from '@/features/docs';
|
||||
import PinnedDocumentIcon from '@/features/docs/doc-management/assets/pinned-document.svg';
|
||||
import SimpleFileIcon from '@/features/docs/doc-management/assets/simple-document.svg';
|
||||
|
||||
const ItemContainer = styled(Box)`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: var(--c--theme--spacings--100W);
|
||||
border-radius: var(--c--theme--spacings--100V);
|
||||
padding: var(--c--theme--spacings--150V);
|
||||
cursor: pointer;
|
||||
`;
|
||||
|
||||
const ItemTextCss = css`
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: initial;
|
||||
display: -webkit-box;
|
||||
line-clamp: 1;
|
||||
-webkit-line-clamp: 1;
|
||||
-webkit-box-orient: vertical;
|
||||
`;
|
||||
|
||||
type Props = {
|
||||
doc: Doc;
|
||||
isPinned?: boolean;
|
||||
subText?: ReactNode | string;
|
||||
};
|
||||
|
||||
export const SimpleDocItem = ({ doc, isPinned = false, subText }: Props) => {
|
||||
return (
|
||||
<ItemContainer>
|
||||
<Box
|
||||
$css={`
|
||||
background-color: transparent;
|
||||
filter: drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.05));
|
||||
display: flex;
|
||||
align-items: center;
|
||||
`}
|
||||
>
|
||||
{isPinned ? <PinnedDocumentIcon /> : <SimpleFileIcon />}
|
||||
</Box>
|
||||
<div>
|
||||
<Text $weight={500} $variation="1000" $size="sm" $css={ItemTextCss}>
|
||||
{doc.title}
|
||||
</Text>
|
||||
|
||||
<Text $variation="500" $size="xs" $css={ItemTextCss}>
|
||||
{subText ??
|
||||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel ante libero. Interdum et malesuada fames ac ante ipsum primis in faucibus. Sed imperdiet neque quam, sed euismod metus mollis ut. '}
|
||||
</Text>
|
||||
</div>
|
||||
</ItemContainer>
|
||||
);
|
||||
};
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Box, BoxButton, Text } from '@/components';
|
||||
@@ -49,7 +49,7 @@ export const TableContent = ({ doc, headings }: TableContentProps) => {
|
||||
}
|
||||
};
|
||||
|
||||
document.getElementById('mainContent')?.addEventListener('scroll', () => {
|
||||
window.addEventListener('scroll', () => {
|
||||
setTimeout(() => {
|
||||
handleScroll();
|
||||
}, 300);
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { Doc } from '../../doc-management';
|
||||
import { SimpleDocItem } from '../../doc-management/components/items/SimpleDocItem';
|
||||
|
||||
type Props = {
|
||||
doc: Doc;
|
||||
};
|
||||
|
||||
export const DocGridListItem = ({ doc }: Props) => {
|
||||
return (
|
||||
<div>
|
||||
<SimpleDocItem doc={doc} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import { Button } from '@openfun/cunningham-react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Box } from '@/components';
|
||||
import { useCreateDoc, useTrans } from '@/features/docs/doc-management/';
|
||||
import { useResponsiveStore } from '@/stores';
|
||||
|
||||
import { DocsGrid } from './DocsGrid';
|
||||
|
||||
export const DocsGridContainer = () => {
|
||||
const { t } = useTranslation();
|
||||
const { untitledDocument } = useTrans();
|
||||
const router = useRouter();
|
||||
const { isMobile } = useResponsiveStore();
|
||||
|
||||
const { mutate: createDoc } = useCreateDoc({
|
||||
onSuccess: (doc) => {
|
||||
router.push(`/docs/${doc.id}`);
|
||||
},
|
||||
});
|
||||
|
||||
const handleCreateDoc = () => {
|
||||
createDoc({ title: untitledDocument });
|
||||
};
|
||||
|
||||
return (
|
||||
<Box $overflow="auto">
|
||||
<Box
|
||||
$align="flex-end"
|
||||
$justify="center"
|
||||
$margin={isMobile ? 'small' : 'big'}
|
||||
>
|
||||
<Button onClick={handleCreateDoc}>{t('Create a new document')}</Button>
|
||||
</Box>
|
||||
<DocsGrid />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
@@ -1,75 +0,0 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { css } from 'styled-components';
|
||||
|
||||
import { Box, Card, Text } from '@/components';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { useInfiniteDocs } from '@/features/docs/doc-management/api/useDocs';
|
||||
import { LEFT_PANEL_WIDTH } from '@/features/left-pannel/conf';
|
||||
import { useResponsiveStore } from '@/stores';
|
||||
|
||||
import { DocGridListItem } from './DocGridListItem';
|
||||
|
||||
export const DocsGridList = () => {
|
||||
const { themeTokens, spacingsTokens, colorsTokens } = useCunninghamTheme();
|
||||
const spacings = spacingsTokens();
|
||||
const colors = colorsTokens();
|
||||
|
||||
const { t } = useTranslation();
|
||||
const { isResponsive } = useResponsiveStore();
|
||||
|
||||
const { data, isFetching, isLoading, fetchNextPage, hasNextPage } =
|
||||
useInfiniteDocs({
|
||||
page: 1,
|
||||
});
|
||||
const loading = isFetching || isLoading;
|
||||
|
||||
const loadMore = (inView: boolean) => {
|
||||
if (!inView) {
|
||||
return;
|
||||
}
|
||||
void fetchNextPage();
|
||||
};
|
||||
|
||||
return (
|
||||
<Card
|
||||
$css={`
|
||||
width: 960px;
|
||||
max-width: calc(100dvw - ${isResponsive ? 34 : LEFT_PANEL_WIDTH}px);
|
||||
padding: ${spacings['300W']};
|
||||
`}
|
||||
>
|
||||
<Text
|
||||
$margin={{ bottom: `${spacings['100W']}` }}
|
||||
$css="margin-block: 0"
|
||||
as="h4"
|
||||
>
|
||||
{t('All docs')}
|
||||
</Text>
|
||||
<section>
|
||||
<Box
|
||||
as="header"
|
||||
$css={css`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin-bottom: ${spacings['100W']};
|
||||
font-size: ${themeTokens().font?.sizes.xs};
|
||||
color: ${colors['greyscale-500']};
|
||||
padding-bottom: ${spacings['150V']} ${spacings['100W']};
|
||||
`}
|
||||
>
|
||||
<Box $flex={7}>{t('Name')}</Box>
|
||||
|
||||
{!isResponsive && <Box $flex={1}>{t('Update at')}</Box>}
|
||||
<Box $flex={1} />
|
||||
</Box>
|
||||
</section>
|
||||
<Box $gap={`${spacings['150V']}`}>
|
||||
{data?.pages.map((currentPage) => {
|
||||
return currentPage.results.map((doc) => (
|
||||
<DocGridListItem doc={doc} key={doc.id} />
|
||||
));
|
||||
})}
|
||||
</Box>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export * from './DocsGridContainer';
|
||||
@@ -0,0 +1 @@
|
||||
export * from './components';
|
||||
@@ -1,4 +1,31 @@
|
||||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M21.6305 28.8312C22.7983 28.5038 23.9166 27.9062 24.6505 26.8503C25.3749 25.8163 25.5789 24.5047 25.5789 23.2425V4.75099C25.5789 4.42358 25.5611 4.09557 25.5216 3.77148C26.1016 3.99961 26.5486 4.37658 26.8626 4.90239C27.2331 5.50024 27.4184 6.28757 27.4184 7.26435V26.0464C27.4184 27.3684 27.0942 28.3578 26.4458 29.0146C25.7974 29.6714 24.8207 29.9998 23.5155 29.9998H16.4209C16.5889 29.9704 16.7574 29.9401 16.9262 29.909C18.4067 29.6444 19.9713 29.2854 21.6185 28.8346L21.6305 28.8312Z" fill="#C9191E"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.58203 25.655V6.8477C4.58203 5.70251 4.88938 4.83519 5.50408 4.24575C6.1272 3.65631 6.95242 3.33212 7.97972 3.27318C9.49542 3.18055 10.9311 3.05425 12.2868 2.89425C13.6425 2.72584 14.9393 2.53217 16.1771 2.31324C17.4234 2.0943 18.6359 1.85011 19.8148 1.58065C21.0274 1.29435 21.9578 1.4375 22.6062 2.0101C23.2546 2.58269 23.5788 3.49632 23.5788 4.75099V23.2425C23.5788 24.3456 23.3893 25.1666 23.0104 25.7055C22.6315 26.2529 21.9915 26.6528 21.0905 26.9054C19.4906 27.3433 17.9833 27.6886 16.5687 27.9412C15.154 28.2022 13.7731 28.4001 12.4258 28.5348C11.0785 28.6696 9.69751 28.7748 8.28286 28.8506C7.11241 28.918 6.20299 28.6738 5.5546 28.118C4.90622 27.5707 4.58203 26.7497 4.58203 25.655ZM9.20865 10.2624C11.0635 10.1444 12.7632 9.96305 14.3075 9.71831C14.6822 9.65722 15.0564 9.5936 15.4291 9.52759C15.8192 9.45851 16.1013 9.11859 16.1013 8.72337C16.1013 8.21154 15.638 7.82609 15.135 7.91189C14.846 7.96118 14.5555 8.00909 14.2635 8.05562C12.7346 8.29923 11.0452 8.47998 9.19523 8.5977C8.91819 8.61558 8.69776 8.70188 8.55608 8.87391C8.42209 9.03661 8.35645 9.23229 8.35645 9.45535C8.35645 9.68212 8.43296 9.87951 8.58568 10.0418L8.58783 10.0439C8.75336 10.2095 8.96369 10.2811 9.20865 10.2624ZM9.20801 14.456C11.0631 14.338 12.763 14.1566 14.3075 13.9119C15.8588 13.6589 17.3936 13.3638 18.9112 13.0266C19.2191 12.9581 19.4498 12.8503 19.5652 12.683C19.6786 12.5221 19.7347 12.3376 19.7347 12.1332C19.7347 11.9026 19.6469 11.704 19.476 11.5426C19.2921 11.3689 19.0348 11.3284 18.7304 11.3911L18.7285 11.3915C17.2823 11.7194 15.794 12.0053 14.2635 12.2492C12.7346 12.4928 11.0452 12.6735 9.19523 12.7913C8.91819 12.8091 8.69776 12.8954 8.55608 13.0675C8.42276 13.2294 8.35645 13.4205 8.35645 13.6363C8.35645 13.8703 8.43209 14.0723 8.58558 14.2354L8.59 14.2396C8.75499 14.3949 8.96316 14.4655 9.20551 14.4562L9.20801 14.456ZM9.20847 18.6494C11.0634 18.5229 12.7631 18.3374 14.3075 18.0927C15.8589 17.8482 17.3934 17.5573 18.9112 17.22C19.2199 17.1514 19.4508 17.0391 19.566 16.8627C19.6783 16.7029 19.7347 16.5233 19.7347 16.3266C19.7347 16.0961 19.6469 15.8974 19.476 15.7361C19.2921 15.5623 19.0348 15.5218 18.7304 15.5845L18.729 15.5848C17.2827 15.9043 15.7942 16.1861 14.2635 16.43C12.7345 16.6736 11.045 16.8586 9.19495 16.9847C8.91804 17.0026 8.69771 17.0889 8.55608 17.2609C8.42276 17.4228 8.35645 17.6139 8.35645 17.8297C8.35645 18.0637 8.43209 18.2658 8.58558 18.4289L8.59 18.433C8.75499 18.5883 8.96316 18.6589 9.20551 18.6496L9.20847 18.6494ZM14.3075 22.257C12.7632 22.5018 11.0635 22.6831 9.20867 22.8012C8.9637 22.8198 8.75337 22.7482 8.58783 22.5826L8.58572 22.5805C8.433 22.4182 8.35645 22.2208 8.35645 21.9941C8.35645 21.771 8.42209 21.5753 8.55608 21.4126C8.69776 21.2406 8.91827 21.1543 9.19531 21.1364C11.0453 21.0187 12.7346 20.838 14.2635 20.5943C14.5555 20.5478 14.846 20.4999 15.135 20.4506C15.638 20.3648 16.1013 20.7503 16.1013 21.2621C16.1013 21.6573 15.8192 21.9972 15.4291 22.0663C15.0564 22.1323 14.6822 22.1959 14.3075 22.257Z" fill="#000091"/>
|
||||
<svg viewBox="0 0 36 42" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_5_830)">
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
d="M26.5706 16.681V20.756H9.59985V16.681H26.5706ZM26.5706 23.0467V27.1215H9.59985V23.0467H26.5706ZM19.5375 29.2926V33.3674H9.59985V29.2926H19.5375Z"
|
||||
fill="#E1000F"
|
||||
/>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
d="M35.6982 16.7351V33.2911C35.6826 33.2845 35.667 33.2756 35.6492 33.269V37.4663C35.6492 39.8874 33.641 41.8683 31.1867 41.8683H4.461C2.00664 41.8683 -0.00146484 39.8874 -0.00146484 37.4663V4.45137C-0.00146484 2.03028 2.00664 0.0493774 4.461 0.0493774H18.723V4.45137H4.461V37.4663H31.1867V16.7351H35.6982Z"
|
||||
fill="#000091"
|
||||
/>
|
||||
<path
|
||||
d="M33.9524 0.0360107H23.626C22.6794 0.0360107 21.9049 0.799997 21.9049 1.73376V11.9202C21.9049 12.854 22.6794 13.618 23.626 13.618H33.9524C34.899 13.618 35.6735 12.854 35.6735 11.9202V1.73376C35.6735 0.799997 34.899 0.0360107 33.9524 0.0360107ZM26.6378 6.40257C26.6378 7.10713 26.0613 7.67588 25.347 7.67588H24.4865V8.73697C24.4865 9.08501 24.1939 9.37362 23.8411 9.37362C23.4883 9.37362 23.1957 9.08501 23.1957 8.73697V5.12925C23.1957 4.66237 23.5829 4.28038 24.0562 4.28038H25.347C26.0613 4.28038 26.6378 4.84913 26.6378 5.55369V6.40257ZM30.9405 8.10031C30.9405 8.80488 30.364 9.37362 29.6497 9.37362H27.9286C27.6877 9.37362 27.4984 9.18687 27.4984 8.94919V4.70482C27.4984 4.46713 27.6877 4.28038 27.9286 4.28038H29.6497C30.364 4.28038 30.9405 4.84913 30.9405 5.55369V8.10031ZM34.3827 4.91704C34.3827 5.26507 34.0901 5.55369 33.7373 5.55369H33.0919V6.40257H33.7373C34.0901 6.40257 34.3827 6.69118 34.3827 7.03922C34.3827 7.38726 34.0901 7.67588 33.7373 7.67588H33.0919V8.73697C33.0919 9.08501 32.7993 9.37362 32.4465 9.37362C32.0936 9.37362 31.8011 9.08501 31.8011 8.73697V5.12925C31.8011 4.66237 32.1883 4.28038 32.6616 4.28038H33.7373C34.0901 4.28038 34.3827 4.569 34.3827 4.91704ZM24.4865 6.40257H25.347V5.55369H24.4865V6.40257ZM28.7892 8.10031H29.6497V5.55369H28.7892V8.10031Z"
|
||||
fill="#000091"
|
||||
/>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
d="M35.6734 10.0666V13.6574H32.4942V10.0666H35.6734ZM25.0866 0.0441895V3.59171H21.9041V0.0441895H25.0866Z"
|
||||
fill="#000091"
|
||||
/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_5_830">
|
||||
<rect width="36" height="42" fill="white" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 2.4 KiB |
@@ -1,91 +1,90 @@
|
||||
import { Button } from '@openfun/cunningham-react';
|
||||
import Image from 'next/image';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Box, Icon, StyledLink, Text } from '@/components/';
|
||||
import { Box, StyledLink, Text } from '@/components/';
|
||||
import { ButtonLogin } from '@/core/auth';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { LanguagePicker } from '@/features/language';
|
||||
import { useResponsiveStore } from '@/stores';
|
||||
|
||||
import { default as IconDocs } from '../assets/icon-docs.svg?url';
|
||||
import { HEADER_HEIGHT } from '../conf';
|
||||
|
||||
import { DropdownMenu } from './DropdownMenu';
|
||||
import { LaGaufre } from './LaGaufre';
|
||||
|
||||
export const Header = () => {
|
||||
const { t } = useTranslation();
|
||||
const theme = useCunninghamTheme();
|
||||
const tokens = theme.themeTokens();
|
||||
const colors = theme.colorsTokens();
|
||||
const { isResponsive, toggleMobileMenu } = useResponsiveStore();
|
||||
const { isSmallMobile } = useResponsiveStore();
|
||||
|
||||
return (
|
||||
<Box
|
||||
as="header"
|
||||
$css={`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: ${HEADER_HEIGHT}px;
|
||||
min-height: ${HEADER_HEIGHT}px;
|
||||
padding: 0 ${tokens.spacings?.['300V'] ?? '1rem'};
|
||||
background-color: ${colors?.['greyscale-000'] ?? '#FFFFFF'};
|
||||
border-bottom: 1px solid ${(colors?.['greyscale-200'] as string) ?? '#E5E5E5'};
|
||||
`}
|
||||
$justify="center"
|
||||
$width="100%"
|
||||
$zIndex="100"
|
||||
$padding={{ vertical: 'xtiny' }}
|
||||
$css="box-shadow: 0 1px 4px #00000040;"
|
||||
>
|
||||
{isResponsive && (
|
||||
<Button
|
||||
size="medium"
|
||||
onClick={toggleMobileMenu}
|
||||
aria-label={t('Open the header menu')}
|
||||
color="primary-text"
|
||||
icon={<Icon iconName="menu" />}
|
||||
/>
|
||||
)}
|
||||
|
||||
<StyledLink href="/">
|
||||
<Box
|
||||
$align="center"
|
||||
$gap={(tokens.spacings?.['100V'] as string) ?? '0.8rem'}
|
||||
$direction="row"
|
||||
$position="relative"
|
||||
$height="fit-content"
|
||||
$margin={{ top: 'auto' }}
|
||||
>
|
||||
<Image priority src={IconDocs} alt={t('Docs Logo')} width={25} />
|
||||
|
||||
<Text
|
||||
$margin="none"
|
||||
as="h2"
|
||||
$color="#000091"
|
||||
$zIndex={1}
|
||||
$size="1.30rem"
|
||||
$css="font-family: 'Marianne'"
|
||||
>
|
||||
{t('Docs')}
|
||||
</Text>
|
||||
<Box
|
||||
$margin={{
|
||||
left: 'big',
|
||||
right: isSmallMobile ? 'none' : 'big',
|
||||
}}
|
||||
$align="center"
|
||||
$justify="space-between"
|
||||
$direction="row"
|
||||
>
|
||||
<Box>
|
||||
<StyledLink href="/">
|
||||
<Box
|
||||
$align="center"
|
||||
$gap="0.8rem"
|
||||
$direction="row"
|
||||
$position="relative"
|
||||
$height="fit-content"
|
||||
$margin={{ top: 'auto' }}
|
||||
>
|
||||
<Image priority src={IconDocs} alt={t('Docs Logo')} width={25} />
|
||||
<Text
|
||||
$padding="2px 3px"
|
||||
$size="8px"
|
||||
$background="#368bd6"
|
||||
$color="white"
|
||||
$position="absolute"
|
||||
$radius="5px"
|
||||
$css={`
|
||||
bottom: 13px;
|
||||
right: -17px;
|
||||
`}
|
||||
>
|
||||
BETA
|
||||
</Text>
|
||||
<Text
|
||||
$margin="none"
|
||||
as="h2"
|
||||
$color="#000091"
|
||||
$zIndex={1}
|
||||
$size="1.30rem"
|
||||
$css="font-family: 'Marianne'"
|
||||
>
|
||||
{t('Docs')}
|
||||
</Text>
|
||||
</Box>
|
||||
</StyledLink>
|
||||
</Box>
|
||||
</StyledLink>
|
||||
{isResponsive ? (
|
||||
<Box
|
||||
$direction="row"
|
||||
$gap={(tokens.spacings?.['300V'] as string) ?? '0.625rem'}
|
||||
>
|
||||
<LaGaufre />
|
||||
</Box>
|
||||
) : (
|
||||
<Box
|
||||
$align="center"
|
||||
$gap={(tokens.spacings?.['300V'] as string) ?? '0.625rem'}
|
||||
$direction="row"
|
||||
>
|
||||
<ButtonLogin />
|
||||
<LanguagePicker />
|
||||
<LaGaufre />
|
||||
</Box>
|
||||
)}
|
||||
{isSmallMobile ? (
|
||||
<Box $direction="row" $gap="2rem">
|
||||
<LaGaufre />
|
||||
<DropdownMenu />
|
||||
</Box>
|
||||
) : (
|
||||
<Box $align="center" $gap="2vw" $direction="row">
|
||||
<ButtonLogin />
|
||||
<LanguagePicker />
|
||||
<LaGaufre />
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export const HEADER_HEIGHT = 52;
|
||||
@@ -1,114 +0,0 @@
|
||||
import { Button } from '@openfun/cunningham-react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { PropsWithChildren, ReactNode } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Box, Icon } from '@/components';
|
||||
import { HorizontalSeparator } from '@/components/separators/HorizontalSeparator';
|
||||
import { SeparatedSection } from '@/components/separators/SeparatedSection';
|
||||
import { ButtonLogin } from '@/core';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { useCreateDoc } from '@/features/docs';
|
||||
import { HEADER_HEIGHT } from '@/features/header/conf';
|
||||
import { LanguagePicker } from '@/features/language';
|
||||
import { useResponsiveStore } from '@/stores';
|
||||
|
||||
export const LeftPanel = ({ children }: PropsWithChildren) => {
|
||||
const { t } = useTranslation();
|
||||
const router = useRouter();
|
||||
const { isResponsive, isMobileMenuOpen, toggleMobileMenu } =
|
||||
useResponsiveStore();
|
||||
const theme = useCunninghamTheme();
|
||||
const colors = theme.colorsTokens();
|
||||
|
||||
const { mutate: createDoc } = useCreateDoc({
|
||||
onSuccess: (doc) => {
|
||||
router.push(`/docs/${doc.id}`);
|
||||
toggleMobileMenu();
|
||||
},
|
||||
});
|
||||
|
||||
const goToHome = () => {
|
||||
router.push('/');
|
||||
toggleMobileMenu();
|
||||
};
|
||||
|
||||
const createNewDoc = () => {
|
||||
createDoc({ title: t('Untitled document') });
|
||||
};
|
||||
|
||||
const getContent = (): ReactNode => {
|
||||
return (
|
||||
<div>
|
||||
<SeparatedSection>
|
||||
<Box
|
||||
$padding={{ horizontal: '300V' }}
|
||||
$direction="row"
|
||||
$justify="space-between"
|
||||
$align="center"
|
||||
>
|
||||
<Box $direction="row" $gap="2px">
|
||||
<Button
|
||||
onClick={goToHome}
|
||||
size="medium"
|
||||
color="primary-text"
|
||||
icon={<Icon iconName="house" />}
|
||||
/>
|
||||
</Box>
|
||||
<Button onClick={createNewDoc}>{t('New doc')}</Button>
|
||||
</Box>
|
||||
</SeparatedSection>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{!isResponsive && (
|
||||
<Box
|
||||
data-testid="left-panel-desktop"
|
||||
$css={`
|
||||
height: calc(100vh - ${HEADER_HEIGHT}px);
|
||||
width: 300px;
|
||||
min-width: 300px;
|
||||
border-right: 1px solid ${(colors?.['greyscale-200'] as string) ?? '#E5E5E5'};
|
||||
`}
|
||||
>
|
||||
{getContent()}
|
||||
</Box>
|
||||
)}
|
||||
{isResponsive && (
|
||||
<Box
|
||||
data-testid="left-panel-mobile"
|
||||
$css={`
|
||||
z-index: 1000;
|
||||
width: 100dvw;
|
||||
height: calc(100dvh - ${HEADER_HEIGHT}px);
|
||||
position: fixed;
|
||||
transition: 0.15s;
|
||||
background-color: ${(colors?.['greyscale-000'] as string) ?? '#fff'};
|
||||
left: ${isMobileMenuOpen ? '0' : '-100dvw'};
|
||||
`}
|
||||
>
|
||||
{getContent()}
|
||||
|
||||
<Box
|
||||
$css={`
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: var(--c--theme--spacings--200W);
|
||||
`}
|
||||
>
|
||||
{children && <HorizontalSeparator />}
|
||||
<ButtonLogin />
|
||||
<LanguagePicker />
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -1 +0,0 @@
|
||||
export const LEFT_PANEL_WIDTH = 300;
|
||||
@@ -1,62 +1,36 @@
|
||||
import { PropsWithChildren, ReactNode } from 'react';
|
||||
import { PropsWithChildren } from 'react';
|
||||
|
||||
import { Box } from '@/components';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { Footer } from '@/features/footer';
|
||||
import { Header } from '@/features/header';
|
||||
import { HEADER_HEIGHT } from '@/features/header/conf';
|
||||
import { LeftPanel } from '@/features/left-pannel/components/LeftPanel';
|
||||
import { useResponsiveStore } from '@/stores';
|
||||
|
||||
export enum MainLayoutBackgroundColor {
|
||||
WHITE = 'white',
|
||||
GREY = 'grey',
|
||||
interface MainLayoutProps {
|
||||
withoutFooter?: boolean;
|
||||
}
|
||||
|
||||
type MainLayoutProps = {
|
||||
backgroundColor?: MainLayoutBackgroundColor;
|
||||
leftPanelContent?: ReactNode;
|
||||
};
|
||||
|
||||
export function MainLayout({
|
||||
children,
|
||||
backgroundColor = MainLayoutBackgroundColor.WHITE,
|
||||
leftPanelContent,
|
||||
withoutFooter,
|
||||
}: PropsWithChildren<MainLayoutProps>) {
|
||||
const { isResponsive } = useResponsiveStore();
|
||||
const { themeTokens, colorsTokens } = useCunninghamTheme();
|
||||
const tokens = themeTokens();
|
||||
const colors = colorsTokens();
|
||||
const { colorsTokens } = useCunninghamTheme();
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Header />
|
||||
<Box $direction="row" $width="100%">
|
||||
<LeftPanel>{leftPanelContent}</LeftPanel>
|
||||
<Box
|
||||
as="main"
|
||||
id="mainContent"
|
||||
$padding={{
|
||||
vertical: !isResponsive
|
||||
? ((tokens.spacings?.['200W'] as string) ?? '1.12rem')
|
||||
: ((tokens.spacings?.['100V'] as string) ?? '0.5rem'),
|
||||
horizontal: !isResponsive
|
||||
? ((tokens.spacings?.['1200W'] as string) ?? '5.62rem')
|
||||
: ((tokens.spacings?.['100V'] as string) ?? '0.5rem'),
|
||||
}}
|
||||
$css={`
|
||||
display: flex;
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
height: calc(100dvh - ${HEADER_HEIGHT}px);
|
||||
overflow-y: scroll;
|
||||
background-color: ${backgroundColor === MainLayoutBackgroundColor.WHITE ? colors['greyscale-000'] : colors['greyscale-050']};
|
||||
`}
|
||||
>
|
||||
{children}
|
||||
<Box>
|
||||
<Box $minHeight="100vh">
|
||||
<Header />
|
||||
<Box $css="flex: 1;" $direction="row">
|
||||
<Box
|
||||
as="main"
|
||||
$minHeight="100vh"
|
||||
$width="100%"
|
||||
$background={colorsTokens()['primary-bg']}
|
||||
>
|
||||
{children}
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
</div>
|
||||
{!withoutFooter && <Footer />}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export function DocLayout() {
|
||||
<Head>
|
||||
<meta name="robots" content="noindex" />
|
||||
</Head>
|
||||
<MainLayout>
|
||||
<MainLayout withoutFooter>
|
||||
<DocPage id={id} />
|
||||
</MainLayout>
|
||||
</>
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
import type { ReactElement } from 'react';
|
||||
|
||||
import { DocsGridList } from '@/features/docs/docs-grid/components/DocsGridList';
|
||||
import { MainLayout, MainLayoutBackgroundColor } from '@/layouts';
|
||||
import { DocsGridContainer } from '@/features/docs/docs-grid';
|
||||
import { MainLayout } from '@/layouts';
|
||||
import { NextPageWithLayout } from '@/types/next';
|
||||
|
||||
const Page: NextPageWithLayout = () => {
|
||||
return <DocsGridList />;
|
||||
return <DocsGridContainer />;
|
||||
};
|
||||
|
||||
Page.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<MainLayout backgroundColor={MainLayoutBackgroundColor.GREY}>
|
||||
{page}
|
||||
</MainLayout>
|
||||
);
|
||||
return <MainLayout>{page}</MainLayout>;
|
||||
};
|
||||
|
||||
export default Page;
|
||||
|
||||
@@ -4,74 +4,41 @@ export type ScreenSize = 'small-mobile' | 'mobile' | 'tablet' | 'desktop';
|
||||
|
||||
export interface UseResponsiveStore {
|
||||
isMobile: boolean;
|
||||
isTablet: boolean;
|
||||
isMobileMenuOpen: boolean;
|
||||
isSmallMobile: boolean;
|
||||
screenSize: ScreenSize;
|
||||
screenWidth: number;
|
||||
setScreenSize: (size: ScreenSize) => void;
|
||||
toggleMobileMenu: () => void;
|
||||
isResponsive: boolean;
|
||||
initializeResizeListener: () => () => void;
|
||||
}
|
||||
|
||||
const initialState = {
|
||||
isMobile: false,
|
||||
isTablet: false,
|
||||
isSmallMobile: false,
|
||||
isResponsive: false,
|
||||
isMobileMenuOpen: false,
|
||||
screenSize: 'desktop' as ScreenSize,
|
||||
screenWidth: 0,
|
||||
};
|
||||
|
||||
export const useResponsiveStore = create<UseResponsiveStore>((set) => ({
|
||||
isMobile: initialState.isMobile,
|
||||
isTablet: initialState.isTablet,
|
||||
isSmallMobile: initialState.isSmallMobile,
|
||||
screenSize: initialState.screenSize,
|
||||
isMobileMenuOpen: initialState.isMobileMenuOpen,
|
||||
screenWidth: initialState.screenWidth,
|
||||
setScreenSize: (size: ScreenSize) => set(() => ({ screenSize: size })),
|
||||
isResponsive: initialState.isResponsive,
|
||||
toggleMobileMenu: () => {
|
||||
set((old) => ({ isMobileMenuOpen: !old.isMobileMenuOpen }));
|
||||
},
|
||||
initializeResizeListener: () => {
|
||||
const resizeHandler = () => {
|
||||
const width = window.innerWidth;
|
||||
if (width < 560) {
|
||||
set({
|
||||
isResponsive: true,
|
||||
screenSize: 'small-mobile',
|
||||
isMobile: true,
|
||||
isTablet: false,
|
||||
isSmallMobile: true,
|
||||
});
|
||||
} else if (width < 768) {
|
||||
set({
|
||||
isResponsive: true,
|
||||
screenSize: 'mobile',
|
||||
isTablet: false,
|
||||
isMobile: true,
|
||||
isSmallMobile: false,
|
||||
});
|
||||
set({ screenSize: 'mobile', isMobile: true, isSmallMobile: false });
|
||||
} else if (width >= 768 && width < 1024) {
|
||||
set({
|
||||
isResponsive: true,
|
||||
screenSize: 'tablet',
|
||||
isTablet: true,
|
||||
isMobile: false,
|
||||
isSmallMobile: false,
|
||||
});
|
||||
set({ screenSize: 'tablet', isMobile: false, isSmallMobile: false });
|
||||
} else {
|
||||
set({
|
||||
isResponsive: false,
|
||||
screenSize: 'desktop',
|
||||
isTablet: false,
|
||||
isMobile: false,
|
||||
isSmallMobile: false,
|
||||
});
|
||||
set({ screenSize: 'desktop', isMobile: false, isSmallMobile: false });
|
||||
}
|
||||
|
||||
set({ screenWidth: width });
|
||||
|
||||
+1024
-59
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user