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: fiche dossier #28

Closed
wants to merge 9 commits into from
105 changes: 105 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const meta = {
control: 'select',
options: colorOptions,
},
onClick: { action: 'clicked' },
opened: { control: 'boolean' },
},
component: Cmp,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import type { Meta, StoryObj } from '@storybook/react';

import { Eye, Suitcase, User } from '@phosphor-icons/react';
import { action } from '@storybook/addon-actions';

import { FileSheet as Cmp } from './FileSheet';

const meta = {
argTypes: {
defaultMotifOpacity: {
control: { max: 1, min: 0, step: 0.1, type: 'number' },
},
},
component: Cmp,
tags: ['autodocs'],
title: '3-custom/Components/FileSheet',
} satisfies Meta<typeof Cmp>;

export default meta;
type IStory = StoryObj<typeof meta>;

export const FileSheet: IStory = {
args: {
cards: [
{
image: <User color="#0B7285" size={20} />,
onAction: (): void => {
action('Click on first card');
},
title: 'Individual contract',
},
{
image: <Suitcase color="#0B7285" size={20} />,
onAction: (): void => {
action('Click on second card');
},
title: '2 Lines text for example',
},
],
cardsColor: '',
content: (
<p
style={{
cursor: 'pointer',
display: 'flex',
fontWeight: 600,
margin: '0',
verticalAlign: 'center',
}}
>
<Eye size={18} style={{ margin: 'auto 10px auto 0' }} weight="bold" />
View the folder properties
</p>
),
defaultMotifColor: '',
defaultMotifOpacity: '',
dropZone: false,
motifVisible: true,
title: <h1>Jean-Michel DUPONT</h1>,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { renderWithProviders } from '../../../utils/tests';

import { FileSheet } from './FileSheet';

describe('FileSheet', () => {
it('matches snapshot', () => {
const { container } = renderWithProviders(<FileSheet dropZone={false} />);
expect(container).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
'use client';

import type { BoxProps } from '@mantine/core';
import type { ReactElement, ReactNode } from 'react';

import { Box } from '@mantine/core';
import { createStyles } from '@mantine/styles';

import Motif from './Motif';

interface ICard {
image?: ReactElement;
onAction?: (item: ICard) => void;
title?: string;
}

interface IFileSheetProps extends BoxProps {
vapersmile marked this conversation as resolved.
Show resolved Hide resolved
cards?: ICard[];
cardsColor?: string;
children?: ReactNode;
content?: ReactElement;
defaultMotifColor?: string;
defaultMotifOpacity?: string;
dropZone: boolean;
dropZoneContent?: ReactElement;
vapersmile marked this conversation as resolved.
Show resolved Hide resolved
motif?: ReactElement;
motifVisible?: boolean;
vapersmile marked this conversation as resolved.
Show resolved Hide resolved
title?: ReactElement;
}

export function FileSheet(props: IFileSheetProps): ReactElement {
vapersmile marked this conversation as resolved.
Show resolved Hide resolved
const {
children,
title,
cards = [],
cardsColor,
content,
defaultMotifColor,
defaultMotifOpacity,
dropZone,
dropZoneContent,
motif,
motifVisible = true,
...BoxProps
} = props;

const useStyles = createStyles((theme) => ({
card: {
alignItems: 'center',
background: cardsColor ? cardsColor : theme.colors.cyan[0],
vapersmile marked this conversation as resolved.
Show resolved Hide resolved
borderRadius: '4px',
cursor: 'pointer',
display: 'flex',
height: '40px',
justifyContent: 'center',
marginRight: '16px',
minWidth: '40px',
width: '40px',
},
cardGroupe: {
alignItems: 'center',
display: 'flex',
justifyContent: 'left',
marginBottom: '20px',
paddingRight: '20px',
width: '200px',
},
cards: {
display: 'flex',
flexWrap: 'wrap',
justifyContent: 'left',
},
container: {
position: 'relative',
zIndex: 1,
},
content: {},
fileSheet: {
borderRadius: '16px',
minHeight: '219px',
overflow: 'hidden',
padding: '32px 42px',
position: 'relative',
width: '100%',
},
leftContainer: {
maxWidth: '410px',
},
motif: {
left: 0,
position: 'absolute',
top: 0,
zIndex: 0,
},
rightContainer: {},
title: {
'h1, h2, h3, h4 h5, p': {
fontSize: '26px',
fontWeight: 700,
marginBottom: '24px',
},
},
}));
const { classes } = useStyles();
return (
<Box className={classes.fileSheet} color="primary" {...BoxProps}>
{Boolean(motifVisible) && (
<div className={classes.motif}>
{motif ? (
motif
) : (
<Motif color={defaultMotifColor} opacity={defaultMotifOpacity} />
)}
vapersmile marked this conversation as resolved.
Show resolved Hide resolved
</div>
)}
<div className={classes.container}>
<div className={classes.leftContainer}>
{Boolean(title) && <div className={classes.title}>{title}</div>}
{Boolean(cards.length > 0) && (
<div className={classes.cards}>
{cards.map((item, key) => (
<div key={`card-${key + key}`} className={classes.cardGroupe}>
{Boolean(item.image) && (
<div
aria-hidden="true"
className={classes.card}
onClick={() => item.onAction && item.onAction(item)}
>
{item.image}
</div>
)}
<span>{Boolean(item.title) && item.title}</span>
</div>
))}
</div>
)}
{Boolean(content) && <div className={classes.content}>{content}</div>}
vapersmile marked this conversation as resolved.
Show resolved Hide resolved
</div>
{Boolean(dropZone) && <div className={classes.rightContainer} />}
</div>
</Box>
);
}
Loading