Skip to content

Commit

Permalink
Mep (#34)
Browse files Browse the repository at this point in the history
* fix: display correct status

* fix: edit banner spacings

* feat: set edit banner sticky on mobile

* fix: return arrow size

* feat: set menu title position to sticky

* fix: some styles

* fix: simplify header

* fix: show reports on 2 columns from 6 items

* feat: add info messages

* feat: display report item on 3 rows

* fix: new colors

* fix: informative message mb

* fix: set printable colors

* fix(pdf): set header sticky on desktop

* fix: recipients textarea styles

* fix: menu header padding and more

* fix: remove *

* fix: form labels

* fix: date picker

* fix: margins

* gitignore

* fix: pdf styles can now be italic and bold

* fix: align tab title with content on firefox
  • Loading branch information
ledouxm authored Sep 12, 2024
1 parent ef2e2da commit e83aa71
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 66 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
dev-dist
vite.config.ts.timestamp*
# dependencies
node_modules
/.pnp
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/chips/SpaceTypeChips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const SpaceTypeChips = (props: FlexProps & { disabled?: boolean }) => {
value={selected}
{...props}
onChange={(values) => form.setValue("projectSpaceType", values.join(","))}
label="Type d'espace"
label="Type d'espace protégé"
/>
);
};
12 changes: 6 additions & 6 deletions packages/frontend/src/features/InfoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const InfoForm = () => {
<Input
className={css({ flex: { base: "none", lg: 1 }, mb: { base: "16px", lg: "16px" } })}
disabled={isFormDisabled}
label="Nom du demandeur*"
label="Nom du demandeur"
nativeInputProps={form.register("applicantName")}
/>
</Stack>
Expand Down Expand Up @@ -142,7 +142,7 @@ export const InfoForm = () => {
<Input
className={css({ flex: { base: "none", lg: 2 }, mt: "16px", mb: { base: "24px", lg: undefined } })}
disabled={isFormDisabled}
label="Adresse du projet"
label="Adresse"
nativeInputProps={form.register("applicantAddress")}
/>
<Stack gap={{ base: "0", lg: "16px" }} direction={{ base: "column", lg: "row" }}>
Expand All @@ -156,16 +156,16 @@ export const InfoForm = () => {
<Input
className={css({ flex: { base: "none", lg: 1 }, mb: { base: "24px", lg: undefined } })}
disabled={isFormDisabled}
label="Commune*"
label="Commune"
// hintText="Ce champ apparaitra dans la liste des compte-rendus"
nativeInputProps={form.register("city")}
/>
</Stack>
<Stack gap={{ base: "0", lg: "16px" }} direction={{ base: "column", lg: "row" }}>
<Input
className={css({ flex: { base: "none", lg: 1 }, mb: "16px" })}
className={css({ flex: { base: "none", lg: 1 }, mb: "24px" })}
disabled={isFormDisabled}
label="Référence cadastrale du projet"
label="Référence cadastrale"
nativeInputProps={form.register("projectCadastralRef")}
/>
<Box
Expand All @@ -182,7 +182,7 @@ export const InfoForm = () => {
<SpaceTypeChips className={css({ flex: { base: "none", lg: 1 } })} disabled={isFormDisabled} />
</InputGroupWithTitle>

<Center justifyContent={{ base: "center", lg: "flex-start" }} mt={{ base: "80px", lg: 0 }} mb="120px">
<Center justifyContent={{ base: "center", lg: "flex-start" }} mt={{ base: "80px", lg: "50px" }} mb="120px">
<Button
type="button"
iconId="ri-arrow-right-line"
Expand Down
12 changes: 4 additions & 8 deletions packages/frontend/src/features/ReportList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ const NoReport = () => {
);
};

const nbPerColumn = 10;

export const ReportList = ({
reports,
page,
Expand All @@ -135,7 +133,7 @@ export const ReportList = ({
}) => {
const error = reports.length === 0 ? <NoReport /> : null;

const columns = chunk(reports, nbPerColumn);
const columns = reports.length < 6 ? [reports] : chunk(reports, Math.ceil(reports.length / 2));

return (
<Stack w="100%" mt={{ base: "20px", lg: "30px" }}>
Expand Down Expand Up @@ -199,8 +197,6 @@ const ReportListItem = ({
const forText = report.applicantName ? uppercaseFirstLetterIf(`pour ${report.applicantName}`, !whereText) : null;
const byText = uppercaseFirstLetterIf(`par ${report.redactedBy ?? report.user?.name ?? ""}`, !whereText && !forText);

const description = [whereText, forText, byText].filter(Boolean).join(" ");

return (
<Flex position="relative" direction="column" w="100%">
<Link
Expand Down Expand Up @@ -230,9 +226,9 @@ const ReportListItem = ({
<styled.span ml={"5px"}>{new Date(report.meetDate).toLocaleDateString()}</styled.span>
) : null}
</Flex>
<styled.div lineClamp={2}>
<styled.span>{description}</styled.span>
</styled.div>
<styled.div nowrap>{whereText}</styled.div>
<styled.div nowrap>{forText}</styled.div>
<styled.div nowrap>{byText}</styled.div>
<styled.div mt="8px">
<ReportBadge status={report.pdf ? "published" : "draft"} />
</styled.div>
Expand Down
59 changes: 38 additions & 21 deletions packages/frontend/src/features/menu/ClauseMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,21 @@ export const ClauseMenu = ({ isNational, ...props }: { isNational: boolean } & M
if (isNational)
return (
<>
<ClauseTitle isNational={isNational} buttons={null} {...props} />
<ClauseList clauses={(clausesQuery.results as any) ?? []} isEditing={false} />
<ClauseTitle
isNational={isNational}
buttons={null}
alert={
<ClauseFormBanner
status="idle"
icon={fr.cx("fr-icon-alert-fill")}
text={`Ces clauses sont communes à toutes les UDAP et ne peuvent pas être modifiées.`}
/>
}
{...props}
/>
<styled.div px="20px">
<ClauseList clauses={(clausesQuery.results as any) ?? []} isEditing={false} />
</styled.div>
</>
);

Expand Down Expand Up @@ -76,7 +89,10 @@ const ClauseForm = ({
...props
}: { clauses: Clause_v2[]; isNational: boolean } & ModalContentProps) => {
const [mode, setMode] = useState<Mode>("view");
const [bannerProps, setBannerProps] = useState<{ status: BannerStatus; text: string; icon: string } | null>(null);
const [bannerProps, setBannerProps] = useState<{ status: BannerStatus; text: string; icon: string } | null>({
...initialBannerProps,
text: "Ces clauses sont spécifiques à votre UDAP et modifiables.",
});

const isEditing = mode === "edit";
const isAdding = mode === "add";
Expand Down Expand Up @@ -202,33 +218,34 @@ const ClauseForm = ({
{...props}
alert={bannerProps ? <ClauseFormBanner {...bannerProps} /> : null}
/>

{isAdding ? (
<ClauseAdd
onSuccess={() => {
setBannerProps({ status: "success", text: "Clause ajoutée", icon: "ri-check-fill" });
setMode("view");
}}
isNational={isNational}
/>
) : null}
<FormProvider {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} id="edit-form">
<ClauseList clauses={fieldsWithIndex} isEditing={isEditing} />
</form>
</FormProvider>
<styled.div px="20px">
{isAdding ? (
<ClauseAdd
onSuccess={() => {
setBannerProps({ status: "success", text: "Clause ajoutée", icon: "ri-check-fill" });
setMode("view");
}}
isNational={isNational}
/>
) : null}
<FormProvider {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} id="edit-form">
<ClauseList clauses={fieldsWithIndex} isEditing={isEditing} />
</form>
</FormProvider>
</styled.div>
</>
);
};

type BannerStatus = "idle" | "success";

const ClauseFormBanner = ({ status, icon, text }: { text: string; icon: string; status: BannerStatus }) => {
export const ClauseFormBanner = ({ status, icon, text }: { text: string; icon: string; status: BannerStatus }) => {
const bgColor = status === "idle" ? "#E8EDFF" : "#B8FEC9";
const iconColor = status === "idle" ? "#0063CB" : "#18753C";

return (
<Flex ml="-32px" mr="-32px" py="16px" px="32px" bgColor={bgColor}>
<Flex mb="24px" py="16px" px="32px" bgColor={bgColor}>
<i className={cx(icon, css({ color: iconColor }))} />
<styled.div
dangerouslySetInnerHTML={{ __html: transformBold(text) }}
Expand All @@ -240,7 +257,7 @@ const ClauseFormBanner = ({ status, icon, text }: { text: string; icon: string;
);
};

function transformBold(str: string) {
export function transformBold(str: string) {
return str.replace(/\*\*(.*?)\*\*/g, "<b>$1</b>");
}

Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/features/menu/HelpMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export const HelpMenu = ({ backButtonOnClick }: { backButtonOnClick: () => void
<>
<MenuTitle backButtonOnClick={backButtonOnClick}>Assistance technique</MenuTitle>
<Divider height="2px" my={{ base: "27px", lg: "44px" }} color="#C1C1FB" />
<Stack>
<Stack px="20px">
<styled.div mb="10px">
Si vous n'arrivez pas à vous connecter, essayez de réinitialiser les données locales :
Vous ne voyez pas vos dernières informations enregistrées ? Essayez de réinitialiser les données locales :
</styled.div>
<Button onClick={() => deleteLocalData()}>Réinitialiser</Button>
</Stack>
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/features/menu/MenuButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ const MenuModal = ({ menu, isOpen, className }: { menu: NestedMenu | null; isOpe
maxHeight: "100%",
p: 0,
},
"& .fr-modal__content": {
pl: 0,
pr: 0,
},
"& .fr-col-12": {
flex: { base: 1, lg: "unset" },
width: { base: "100%", lg: "unset" },
Expand Down
21 changes: 17 additions & 4 deletions packages/frontend/src/features/menu/Share.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { ToggleSwitch } from "@codegouvfr/react-dsfr/ToggleSwitch";
import { useMutation } from "@tanstack/react-query";
import { css } from "#styled-system/css";
import { MenuTitle } from "./MenuTitle";
import { ClauseFormBanner } from "./ClauseMenu";
import { fr } from "@codegouvfr/react-dsfr";

export const ShareReport = ({ backButtonOnClick }: { backButtonOnClick: () => void }) => {
const user = useUser()!;
Expand Down Expand Up @@ -41,15 +43,26 @@ export const ShareReport = ({ backButtonOnClick }: { backButtonOnClick: () => vo

return (
<>
<MenuTitle backButtonOnClick={backButtonOnClick}>Partage des CR</MenuTitle>
<Divider hideFrom="lg" height="2px" my={{ base: "20px", lg: "44px" }} color="#C1C1FB" />
<MenuTitle
backButtonOnClick={backButtonOnClick}
alert={
<ClauseFormBanner
status="idle"
icon={fr.cx("fr-icon-alert-fill")}
text={`Tous les agents de l'UDAP peuvent voir et télécharger les compte-rendus envoyés. Seuls ceux à qui vous avez donné le droit peuvent créer, modifier, et supprimer vos compte-rendus. Le compte-rendu est attribué à un agent via le champ "rédigé par" du formulaire.`}
/>
}
>
Partage des CR
</MenuTitle>
{/* <Divider hideFrom="lg" height="2px" my={{ base: "20px", lg: "44px" }} color="#C1C1FB" /> */}

<Stack w="100%">
<Stack w="100%" px="20px">
<styled.div>Ces personnes peuvent créer, modifier et supprimer vos CR : </styled.div>
<ManageDelegations coworkers={coworkersQuery.results ?? []} delegations={delegationsQuery.results ?? []} />
</Stack>

<Stack mt="49px" color="#757575">
<Stack mt="49px" px="20px" color="#757575">
<styled.div>Ces personnes vous permettent de créer, modifier et supprimer leurs CR :</styled.div>
<styled.ul>
{delegatedToMeQuery.results?.map((delegation) => (
Expand Down
25 changes: 10 additions & 15 deletions packages/frontend/src/features/text-editor/TextEditorToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const TextEditorToolbar = () => {
className={toolbarButtonRecipe({
active: editor.isActive("bold"),
})}
size="small"
size="medium"
priority="tertiary no outline"
iconId="fr-icon-bold"
type="button"
Expand All @@ -45,7 +45,7 @@ export const TextEditorToolbar = () => {
className={toolbarButtonRecipe({
active: editor.isActive("italic"),
})}
size="small"
size="medium"
priority="tertiary no outline"
type="button"
iconId="fr-icon-italic"
Expand All @@ -58,7 +58,7 @@ export const TextEditorToolbar = () => {
className={toolbarButtonRecipe({
active: editor.isActive("underline"),
})}
size="small"
size="medium"
priority="tertiary no outline"
iconId="ri-underline"
type="button"
Expand Down Expand Up @@ -91,7 +91,7 @@ const ColorInput = () => {
<Popover.Trigger>
<Button
className={toolbarButtonRecipe({})}
size="small"
size="medium"
priority="tertiary no outline"
iconId="ri-palette-line"
type="button"
Expand All @@ -105,18 +105,13 @@ const ColorInput = () => {
<Stack p="8px">
<Stack gap="8px" flexDir="row" justifyContent="space-around" w="100%">
<ColorButton value={currentValue} color="black" />
<ColorButton value={currentValue} color="#c9191e" />
<ColorButton value={currentValue} color="#666666" />
<ColorButton value={currentValue} color="#e1000f" />
<ColorButton value={currentValue} color="#d64d00" />
</Stack>
<Stack gap="8px" flexDir="row" justifyContent="space-around" w="100%">
<ColorButton value={currentValue} color="#cecece" />
<ColorButton value={currentValue} color="#0078f3" />
<ColorButton value={currentValue} color="#1f8d49" />
</Stack>
<Stack gap="8px" flexDir="row" justifyContent="space-around" w="100%">
<ColorButton value={currentValue} color="#68a532" />
<ColorButton value={currentValue} color="#e4794a" />
<ColorButton value={currentValue} color="#272747" />
<Stack flexDir="row" w="100%">
<ColorButton value={currentValue} color="#000091" />
<ColorButton value={currentValue} color="#118d49" />
<div />
</Stack>
</Stack>
</Popover.Content>
Expand Down
6 changes: 5 additions & 1 deletion packages/frontend/src/routes/edit.$reportId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,17 @@ const WithReport = ({ report }: { report: Report }) => {
document.getElementById("root")!.scrollTo(0, 0);
};

// @ts-ignore
const isChrome = !!window.chrome;

const options = [
{
id: "info",
label: "RDV",
className: css({
position: "absolute",
left: "max(calc((100vw - 800px) / 2 + 8px), 16px)",
// there is a difference in padding between chrome and other browsers due to scrollbar width (i guess)
left: isChrome ? "max(calc((100vw - 800px) / 2 + 8px), 16px)" : "max(calc((100vw - 800px) / 2 + 16px), 16px)",
}),
},
{
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const Index = () => {
id: `report-${v4()}`,
createdBy: user.id,
createdAt: new Date(),
meetDate: new Date(),
disabled: false,
udap_id: user.udap.id,
redactedBy: user.name,
Expand Down
Loading

0 comments on commit e83aa71

Please sign in to comment.