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

feat(#vil-496): indice culture #954

Merged
merged 1 commit into from
Jun 24, 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
27 changes: 20 additions & 7 deletions src/components/StepsButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,57 @@ import React from 'react';

import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
import { Button } from '@mui/material';
import { Box, Button } from '@mui/material';

export interface StepsButtonProps {
prev?: string | (() => void);
next?: string | (() => void);
}

export const StepsButton = ({ prev, next }: StepsButtonProps) => {
const justifyContent = prev && next ? 'space-between' : prev ? 'start' : 'end';
return (
<div style={{ width: '100%', margin: '3rem 0', minHeight: '2rem' }}>
<Box
sx={{
width: '100%',
display: 'flex',
justifyContent: justifyContent,
gap: {
xs: '0.2rem',
sm: '1rem',
},
margin: '3rem 0',
minHeight: '2rem',
}}
>
{prev !== undefined &&
(typeof prev === 'string' ? (
<Link href={prev} passHref>
<Button component="a" href={prev} variant="outlined" color="primary">
<Button component="a" style={{ maxWidth: '200px', flexBasis: '50%' }} href={prev} variant="outlined" color="primary">
<ChevronLeftIcon />
Étape précédente
</Button>
</Link>
) : (
<Button onClick={prev} variant="outlined" color="primary">
<Button style={{ maxWidth: '200px', flexBasis: '50%' }} onClick={prev} variant="outlined" color="primary">
<ChevronLeftIcon />
Étape précédente
</Button>
))}
{next !== undefined &&
(typeof next === 'string' ? (
<Link href={next} passHref>
<Button component="a" href={next} variant="outlined" style={{ float: 'right' }} color="primary">
<Button component="a" href={next} variant="outlined" style={{ maxWidth: '200px', flexBasis: '50%' }} color="primary">
Étape suivante
<ChevronRightIcon />
</Button>
</Link>
) : (
<Button onClick={next} variant="outlined" style={{ float: 'right' }} color="primary">
<Button onClick={next} variant="outlined" style={{ maxWidth: '200px', flexBasis: '50%' }} color="primary">
Étape suivante
<ChevronRightIcon />
</Button>
))}
</div>
</Box>
);
};
13 changes: 11 additions & 2 deletions src/components/activities/ActivityChoice/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,17 @@ interface ActivityChoiceProps {

export const ActivityChoice = ({ activities }: ActivityChoiceProps) => {
return (
<div style={{ width: '100%', padding: '1rem' }}>
<div style={{ margin: '0 auto', width: '100%', maxWidth: '750px', display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: '1rem 1rem' }}>
<div style={{ width: '100%' }}>
<div
style={{
margin: '0 auto',
width: '100%',
maxWidth: '640px',
display: 'grid',
gridTemplateColumns: 'repeat(auto-fit, minmax(150px, 1fr))',
gap: '1rem 1rem',
}}
>
{activities.map((activity) => {
if (activity.disabled && activity.disabledText) {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/buttons/BackButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const BackButton = ({ href, label = 'Retour' }: BackButtonProps) => {
};

return (
<div style={{ position: 'relative' }}>
<a className="text" style={{ position: 'absolute', left: 0, top: 0, zIndex: 2 }} onClick={onBack}>
<div>
<a className="text" onClick={onBack}>
<span style={{ marginRight: '0.5rem' }}>
<ArrowRight style={{ height: '0.6rem', width: '0.6rem', transform: 'rotate(180deg)' }} />
</span>
Expand Down
14 changes: 11 additions & 3 deletions src/pages/indice-culturel/1.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRouter } from 'next/router';
import React from 'react';

import { TextField } from '@mui/material';
import { Box, TextField } from '@mui/material';

import { getIndice } from 'src/activity-types/indice.constants';
import type { IndiceData } from 'src/activity-types/indice.types';
Expand Down Expand Up @@ -60,7 +60,15 @@ const IndiceStep1 = () => {

return (
<Base>
<div style={{ width: '100%', padding: '0.5rem 1rem 1rem 1rem' }}>
<Box
sx={{
width: '100%',
padding: {
xs: '0',
md: '0.5rem 1rem 1rem 1rem',
},
}}
>
{!isEdit && <BackButton href="/indice-culturel" />}
<Steps
steps={[getIndice(activity.subType, data).step1 || 'Indice', "Créer l'indice", 'Prévisualiser']}
Expand Down Expand Up @@ -109,7 +117,7 @@ const IndiceStep1 = () => {
</div>
)}
</div>
</div>
</Box>
</Base>
);
};
Expand Down
14 changes: 12 additions & 2 deletions src/pages/indice-culturel/2.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useRouter } from 'next/router';
import React from 'react';

import { Box } from '@mui/material';

import { isIndice } from 'src/activity-types/anyActivity';
import { getIndice } from 'src/activity-types/indice.constants';
import type { IndiceData } from 'src/activity-types/indice.types';
Expand Down Expand Up @@ -45,7 +47,15 @@ const IndiceStep2 = () => {

return (
<Base>
<div style={{ width: '100%', padding: '0.5rem 1rem 1rem 1rem' }}>
<Box
sx={{
width: '100%',
padding: {
xs: '0',
md: '0.5rem 1rem 1rem 1rem',
},
}}
>
<Steps
steps={[getIndice(activity.subType, data).step1, "Créer l'indice", 'Prévisualiser']}
urls={['/indice-culturel/1?edit', '/indice-culturel/2', '/indice-culturel/3']}
Expand All @@ -63,7 +73,7 @@ const IndiceStep2 = () => {
<ContentEditor content={activity.content} updateContent={updateContent} addContent={addContent} deleteContent={deleteContent} />
<StepsButton prev="/indice-culturel/1?edit" next={onNext} />
</div>
</div>
</Box>
</Base>
);
};
Expand Down
14 changes: 11 additions & 3 deletions src/pages/indice-culturel/3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Link from 'next/link';
import { useRouter } from 'next/router';
import React from 'react';

import { Tooltip } from '@mui/material';
import { Box, Tooltip } from '@mui/material';
import Backdrop from '@mui/material/Backdrop';
import Button from '@mui/material/Button';
import CircularProgress from '@mui/material/CircularProgress';
Expand Down Expand Up @@ -64,7 +64,15 @@ const IndiceStep3 = () => {

return (
<Base>
<div style={{ width: '100%', padding: '0.5rem 1rem 1rem 1rem' }}>
<Box
sx={{
width: '100%',
padding: {
xs: '0',
md: '0.5rem 1rem 1rem 1rem',
},
}}
>
<Steps
steps={[getIndice(activity.subType, data).step1, "Créer l'indice", 'Prévisualiser']}
urls={['/indice-culturel/1?edit', '/indice-culturel/2', '/indice-culturel/3']}
Expand Down Expand Up @@ -141,7 +149,7 @@ const IndiceStep3 = () => {

<StepsButton prev="/indice-culturel/2" />
</div>
</div>
</Box>
<Backdrop style={{ zIndex: 2000, color: 'white' }} open={isLoading}>
<CircularProgress color="inherit" />
</Backdrop>
Expand Down
14 changes: 12 additions & 2 deletions src/pages/indice-culturel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';

import { Box } from '@mui/material';

import { Base } from 'src/components/Base';
import { ActivityChoice } from 'src/components/activities/ActivityChoice';
import ArtIcon from 'src/svg/indice-culturel/art.svg';
Expand Down Expand Up @@ -80,7 +82,15 @@ const indices = [
const Indice = () => {
return (
<Base>
<div style={{ width: '100%', padding: '0.5rem 1rem 1rem 1rem' }}>
<Box
sx={{
width: '100%',
padding: {
xs: '0',
md: '0.5rem 1rem 1rem 1rem',
},
}}
>
<div className="width-900">
<h1 style={{ marginTop: '0.5rem' }}>Quel aspect de culture allez-vous présenter ?</h1>
<p className="text">
Expand All @@ -93,7 +103,7 @@ const Indice = () => {
</p>
<ActivityChoice activities={indices} />
</div>
</div>
</Box>
</Base>
);
};
Expand Down
14 changes: 11 additions & 3 deletions src/pages/indice-culturel/success.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Link from 'next/link';
import React from 'react';

import { Button } from '@mui/material';
import { Box, Button } from '@mui/material';

import { Base } from 'src/components/Base';
import { bgPage } from 'src/styles/variables.const';
Expand All @@ -10,7 +10,15 @@ import PelicoSouriant from 'src/svg/pelico/pelico-souriant.svg';
const IndiceSuccess = () => {
return (
<Base>
<div style={{ width: '100%', padding: '1rem 1rem 1rem 1rem' }}>
<Box
sx={{
width: '100%',
padding: {
xs: '0',
md: '0.5rem 1rem 1rem 1rem',
},
}}
>
<div style={{ width: '100%', maxWidth: '20rem', margin: '4rem auto', backgroundColor: bgPage, padding: '1rem', borderRadius: '10px' }}>
<p className="text">Votre indice culturel a bien été publié !</p>
<PelicoSouriant style={{ width: '60%', height: 'auto', margin: '0 20%' }} />
Expand All @@ -22,7 +30,7 @@ const IndiceSuccess = () => {
</Button>
</Link>
</div>
</div>
</Box>
</Base>
);
};
Expand Down
Loading