Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️Fine tuning before release 1.5.0 #313

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to
- 💄(frontend) error alert closeable on editor #284
- ♻️(backend) Change email content #283
- 🛂(frontend) viewers and editors can access share modal #302
- ♻️(frontend) remove footer on doc editor #313

## Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ test.describe('Doc Visibility: Not loggued', () => {
await page.goto(urlDoc);

await expect(page.locator('h2').getByText(docTitle)).toBeVisible();
await expect(page.getByRole('button', { name: 'Share' })).toBeHidden();
});

test('A private doc redirect to the OIDC when not authentified.', async ({
Expand Down
77 changes: 77 additions & 0 deletions src/frontend/apps/e2e/__tests__/app-impress/footer.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';

import { Box, DropButton, IconOptions, Text } from '@/components';
import { useAuthStore } from '@/core';
import { usePanelEditorStore } from '@/features/docs/doc-editor/';
import {
Doc,
Expand All @@ -29,6 +30,7 @@ export const DocToolBox = ({ doc, versionId }: DocToolBoxProps) => {
const { setIsPanelOpen, setIsPanelTableContentOpen } = usePanelEditorStore();
const [isModalVersionOpen, setIsModalVersionOpen] = useState(false);
const { isSmallMobile } = useResponsiveStore();
const { authenticated } = useAuthStore();

return (
<Box
Expand All @@ -52,14 +54,16 @@ export const DocToolBox = ({ doc, versionId }: DocToolBoxProps) => {
</Box>
)}
<Box $direction="row" $margin={{ left: 'auto' }} $gap="1rem">
<Button
onClick={() => {
setIsModalShareOpen(true);
}}
size={isSmallMobile ? 'small' : 'medium'}
>
{t('Share')}
</Button>
{authenticated && (
<Button
onClick={() => {
setIsModalShareOpen(true);
}}
size={isSmallMobile ? 'small' : 'medium'}
>
{t('Share')}
</Button>
)}
<DropButton
button={
<IconOptions
Expand Down
166 changes: 166 additions & 0 deletions src/frontend/apps/impress/src/features/footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
import Image from 'next/image';
import React from 'react';
import { useTranslation } from 'react-i18next';
import styled from 'styled-components';

import { Box, StyledLink, Text } from '@/components/';
import { useCunninghamTheme } from '@/cunningham';

import IconLink from './assets/external-link.svg';

const BlueStripe = styled.div`
position: absolute;
height: 2px;
width: 100%;
background: var(--c--theme--colors--primary-600);
top: 0;
`;

export const Footer = () => {
const { t } = useTranslation();
const { themeTokens } = useCunninghamTheme();
const logo = themeTokens().logo;

return (
<Box $position="relative" as="footer">
<BlueStripe />
<Box $padding={{ top: 'large', horizontal: 'big', bottom: 'small' }}>
<Box
$direction="row"
$gap="1.5rem"
$align="center"
$justify="space-between"
$css="flex-wrap: wrap;"
>
<Box>
<Box $align="center" $gap="6rem" $direction="row">
{logo && (
<Image
priority
src={logo.src}
alt={logo.alt}
width={0}
height={0}
style={{ width: logo.widthFooter, height: 'auto' }}
/>
)}
</Box>
</Box>
<Box
$direction="row"
$css={`
column-gap: 1.5rem;
row-gap: .5rem;
flex-wrap: wrap;
`}
>
{[
{
label: 'legifrance.gouv.fr',
href: 'https://legifrance.gouv.fr/',
},
{
label: 'info.gouv.fr',
href: 'https://info.gouv.fr/',
},
{
label: 'service-public.fr',
href: 'https://service-public.fr/',
},
{
label: 'data.gouv.fr',
href: 'https://data.gouv.fr/',
},
].map(({ label, href }) => (
<StyledLink
key={label}
href={href}
target="__blank"
$css={`
gap:0.2rem;
transition: box-shadow 0.3s;
&:hover {
box-shadow: 0px 2px 0 0 var(--c--theme--colors--greyscale-text);
}
`}
>
<Text $weight="bold">{label}</Text>
<IconLink width={18} />
</StyledLink>
))}
</Box>
</Box>
<Box
$direction="row"
$margin={{ top: 'big' }}
$padding={{ top: 'tiny' }}
$css={`
flex-wrap: wrap;
border-top: 1px solid var(--c--theme--colors--greyscale-200);
column-gap: 1rem;
row-gap: .5rem;
`}
>
{[
{
label: t('Legal Notice'),
href: '/legal-notice',
},
{
label: t('Personal data and cookies'),
href: '/personal-data-cookies',
},
{
label: t('Accessibility'),
href: '/accessibility',
},
].map(({ label, href }) => (
<StyledLink
key={label}
href={href}
$css={`
padding-right: 1rem;
&:not(:last-child) {
box-shadow: inset -1px 0px 0px 0px var(--c--theme--colors--greyscale-200);
}
`}
>
<Text
$variation="600"
$size="m"
$transition="box-shadow 0.3s"
$css={`
&:hover {
box-shadow: 0px 2px 0 0 var(--c--theme--colors--greyscale-text);
}
`}
>
{label}
</Text>
</StyledLink>
))}
</Box>
<Text
as="p"
$size="m"
$margin={{ top: 'big' }}
$variation="600"
$display="inline"
>
{t('Unless otherwise stated, all content on this site is under')}{' '}
<StyledLink
href="https://github.com/etalab/licence-ouverte/blob/master/LO.md"
target="__blank"
$css={`
display:inline-flex;
box-shadow: 0px 1px 0 0 var(--c--theme--colors--greyscale-text);
`}
>
<Text $variation="600">licence etalab-2.0</Text>
<IconLink width={18} />
</StyledLink>
</Text>
</Box>
</Box>
);
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/frontend/apps/impress/src/features/footer/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Footer';
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ const precacheResources = [
'/',
'/index.html',
'/404/',
'/accessibility/',
'/legal-notice/',
'/personal-data-cookies/',
FALLBACK.offline,
FALLBACK.images,
FALLBACK.docs,
Expand Down
13 changes: 12 additions & 1 deletion src/frontend/apps/impress/src/layouts/MainLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import { PropsWithChildren } from 'react';

import { Box } from '@/components';
import { useCunninghamTheme } from '@/cunningham';
import { Footer } from '@/features/footer';
import { Header } from '@/features/header';

export function MainLayout({ children }: { children: React.ReactNode }) {
interface MainLayoutProps {
withoutFooter?: boolean;
}

export function MainLayout({
children,
withoutFooter,
}: PropsWithChildren<MainLayoutProps>) {
const { colorsTokens } = useCunninghamTheme();

return (
Expand All @@ -20,6 +30,7 @@ export function MainLayout({ children }: { children: React.ReactNode }) {
</Box>
</Box>
</Box>
{!withoutFooter && <Footer />}
</Box>
);
}
17 changes: 17 additions & 0 deletions src/frontend/apps/impress/src/layouts/PageLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { PropsWithChildren } from 'react';

import { Box } from '@/components';
import { Footer } from '@/features/footer';
import { Header } from '@/features/header';

export function PageLayout({ children }: PropsWithChildren) {
return (
<Box $minHeight="100vh">
<Header />
<Box as="main" $width="100%" $css="flex-grow:1;">
{children}
</Box>
<Footer />
</Box>
);
}
1 change: 1 addition & 0 deletions src/frontend/apps/impress/src/layouts/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './MainLayout';
export * from './PageLayout';
Loading
Loading