Skip to content

Commit

Permalink
Merge branch 'feature/create-main-components-and-layout' into feature…
Browse files Browse the repository at this point in the history
…/create-basic-table-component
  • Loading branch information
fdelemarre committed Jun 28, 2024
2 parents 2101a8c + c9e0fb8 commit b3e13d5
Show file tree
Hide file tree
Showing 26 changed files with 348 additions and 354 deletions.
37 changes: 17 additions & 20 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-06-27T08:53:15.150Z\n"
"PO-Revision-Date: 2024-06-27T08:53:15.150Z\n"
"POT-Creation-Date: 2024-06-28T09:08:39.454Z\n"
"PO-Revision-Date: 2024-06-28T09:08:39.454Z\n"

msgid "Add new option"
msgstr ""
Expand Down Expand Up @@ -35,24 +35,6 @@ msgstr ""
msgid "Last updated: "
msgstr ""

msgid "Incident Management Team Builder"
msgstr ""

msgid "Cholera in NW Province, June 2023"
msgstr ""

msgid "Incident Action Plan"
msgstr ""

msgid "Team"
msgstr ""

msgid "Response Actions"
msgstr ""

msgid "Create Risk Assessment"
msgstr ""

msgid "Dashboard"
msgstr ""

Expand Down Expand Up @@ -83,12 +65,21 @@ msgstr ""
msgid "Risk Assessment"
msgstr ""

msgid "Create Risk Assessment"
msgstr ""

msgid "Risk assessment incomplete"
msgstr ""

msgid "Risks associated with this event have not yet been assessed."
msgstr ""

msgid "Incident Action Plan"
msgstr ""

msgid "Cholera in NW Province, June 2023"
msgstr ""

msgid "Response actions"
msgstr ""

Expand All @@ -101,8 +92,14 @@ msgstr ""
msgid "Edit Action Plan"
msgstr ""

msgid "Team"
msgstr ""

msgid "Edit Team"
msgstr ""

msgid "Incident Management Team Builder"
msgstr ""

msgid "Resources"
msgstr ""
35 changes: 16 additions & 19 deletions i18n/es.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
"POT-Creation-Date: 2024-06-27T08:53:15.150Z\n"
"POT-Creation-Date: 2024-06-28T09:08:39.454Z\n"
"PO-Revision-Date: 2018-10-25T09:02:35.143Z\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -35,24 +35,6 @@ msgstr ""
msgid "Last updated: "
msgstr ""

msgid "Incident Management Team Builder"
msgstr ""

msgid "Cholera in NW Province, June 2023"
msgstr ""

msgid "Incident Action Plan"
msgstr ""

msgid "Team"
msgstr ""

msgid "Response Actions"
msgstr ""

msgid "Create Risk Assessment"
msgstr ""

msgid "Dashboard"
msgstr ""

Expand Down Expand Up @@ -83,12 +65,21 @@ msgstr ""
msgid "Risk Assessment"
msgstr ""

msgid "Create Risk Assessment"
msgstr ""

msgid "Risk assessment incomplete"
msgstr ""

msgid "Risks associated with this event have not yet been assessed."
msgstr ""

msgid "Incident Action Plan"
msgstr ""

msgid "Cholera in NW Province, June 2023"
msgstr ""

msgid "Response actions"
msgstr ""

Expand All @@ -101,9 +92,15 @@ msgstr ""
msgid "Edit Action Plan"
msgstr ""

msgid "Team"
msgstr ""

msgid "Edit Team"
msgstr ""

msgid "Incident Management Team Builder"
msgstr ""

msgid "Resources"
msgstr ""

Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"d2": "31.10.2",
"d2-manifest": "1.0.0",
"font-awesome": "4.7.0",
"lodash": "^4.17.21",
"purify-ts": "1.2.0",
"purify-ts-extra-codec": "0.6.0",
"react": "^18.2.0",
Expand All @@ -50,7 +49,6 @@
"@testing-library/react": "^14.0.0",
"@types/classnames": "2.3.1",
"@types/isomorphic-fetch": "^0.0.36",
"@types/lodash": "^4.17.5",
"@types/material-ui": "^0.21.12",
"@types/node": "18",
"@types/node-localstorage": "^1.3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/webapp/components/add-new-option/AddNewOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type AddNewOptionProps = {
};

export const AddNewOption: React.FC<AddNewOptionProps> = React.memo(
({ id, label = "", onAddNewOption }) => {
({ id, label, onAddNewOption }) => {
return (
<Container onClick={onAddNewOption}>
<StyledAddIcon id={id} aria-label="Add new option" />
Expand Down
15 changes: 4 additions & 11 deletions src/webapp/components/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from "react";
import { Button as MUIButton } from "@material-ui/core";
import styled from "styled-components";

type ButtonProps = {
children?: React.ReactNode;
variant?: "contained" | "outlined";
color?: "primary" | "secondary" | "dark-secondary";
color?: "primary" | "secondary";
disabled?: boolean;
startIcon?: React.ReactNode;
onClick: () => void;
Expand All @@ -21,22 +20,16 @@ export const Button: React.FC<ButtonProps> = React.memo(
onClick,
}) => {
return (
<StyledButton
<MUIButton
variant={variant}
color={color === "dark-secondary" ? "secondary" : color}
color={color}
disabled={disabled}
startIcon={startIcon}
disableElevation
$darkBorder={color === "dark-secondary"}
onClick={onClick}
>
{children}
</StyledButton>
</MUIButton>
);
}
);

const StyledButton = styled(MUIButton)<{ $darkBorder: boolean }>`
border-color: ${props =>
props.$darkBorder ? props.theme.palette.button.borderDarkSecondary : "initial"};
`;
20 changes: 16 additions & 4 deletions src/webapp/components/date-picker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,28 @@ type DatePickerProps = {
errorText?: string;
disabled?: boolean;
error?: boolean;
required?: boolean;
};

export const DatePicker: React.FC<DatePickerProps> = React.memo(
({
id = "",
label = "",
id,
label,
value,
onChange,
disabled = false,
helperText = "",
errorText = "",
error = false,
required = false,
}) => {
return (
<Container>
{label && <Label htmlFor={id}>{label}</Label>}
{label && (
<Label className={required ? "required" : ""} htmlFor={id}>
{label}
</Label>
)}
<LocalizationProvider dateAdapter={AdapterDateFns}>
<StyledDatePicker
value={value}
Expand Down Expand Up @@ -61,10 +67,16 @@ const Container = styled.div`

const Label = styled(InputLabel)`
display: inline-block;
font-weight: 400;
font-weight: 700;
font-size: 0.875rem;
color: ${props => props.theme.palette.text.primary};
margin-block-end: 8px;
&.required::after {
content: "*";
color: ${props => props.theme.palette.common.red};
margin-inline-start: 4px;
}
`;

const StyledDatePicker = styled(DatePickerMUI)<{ error?: boolean; disabled?: boolean }>`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import i18n from "../../../utils/i18n";
import { Button } from "../button/Button";
import { Separator } from "../separator/Separator";

type FormPageProps = {
type FormLayoutProps = {
title?: string;
subtitle?: string;
saveLabel?: string;
Expand All @@ -15,14 +15,14 @@ type FormPageProps = {
onCancel?: () => void;
};

export const FormPage: React.FC<FormPageProps> = React.memo(
({ title, subtitle = "", saveLabel = "", cancelLabel = "", children, onSave, onCancel }) => {
export const FormLayout: React.FC<FormLayoutProps> = React.memo(
({ title, subtitle, saveLabel, cancelLabel, children, onSave, onCancel }) => {
return (
<StyledFormPage>
<StyledFormLayout>
<Header>
<TitleContainer>
{title ? <Title>{title}</Title> : null}
{subtitle ? <Subtitle>{subtitle}</Subtitle> : null}
{title && <Title>{title}</Title>}
{subtitle && <Subtitle>{subtitle}</Subtitle>}
</TitleContainer>
<RequiredText>{i18n.t("Indicates required")}</RequiredText>
</Header>
Expand All @@ -38,12 +38,12 @@ export const FormPage: React.FC<FormPageProps> = React.memo(
)}
</ButtonsFooter>
</Footer>
</StyledFormPage>
</StyledFormLayout>
);
}
);

const StyledFormPage = styled.div`
const StyledFormLayout = styled.div`
width: 100%;
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,38 @@ import { Separator } from "../separator/Separator";
import { IconButton } from "../icon-button/IconButton";

type FormSectionProps = {
title: string;
title?: string;
required?: boolean;
children: React.ReactNode;
hasSeparator?: boolean;
onClickInfo?: () => void;
direction?: "row" | "column";
};

export const FormSection: React.FC<FormSectionProps> = React.memo(
({ title, hasSeparator = false, children, onClickInfo, direction = "row" }) => {
({
title,
hasSeparator = false,
children,
onClickInfo,
direction = "row",
required = false,
}) => {
return (
<FormSectionContainer>
{hasSeparator && <Separator margin="12px" />}
<Container direction={direction}>
<TitleContainer>
<RequiredText>{title}</RequiredText>
{onClickInfo && <IconButton icon={<IconInfo24 />} onClick={onClickInfo} />}
</TitleContainer>
<FormContainer>{children}</FormContainer>
{title && (
<TitleContainer direction={direction}>
<RequiredText className={required ? "required" : ""}>
{title}
</RequiredText>
{onClickInfo && (
<IconButton icon={<IconInfo24 />} onClick={onClickInfo} />
)}
</TitleContainer>
)}
<FormContainer fulWidth={!title}>{children}</FormContainer>
</Container>
</FormSectionContainer>
);
Expand All @@ -41,24 +55,30 @@ const Container = styled.div<{ direction: string }>`
width: 100%;
gap: ${props => (props.direction === "row" ? "48px" : "24px")};
align-items: ${props => (props.direction === "row" ? "center" : "flex-start")};
@media (max-width: 600px) {
flex-direction: column;
align-items: flex-start;
}
`;

const TitleContainer = styled.div`
const TitleContainer = styled.div<{ direction: string }>`
display: flex;
align-items: center;
gap: 4px;
width: 30%;
`;

const FormContainer = styled.div`
width: 100%;
const FormContainer = styled.div<{ fulWidth: boolean }>`
width: ${props => (props.fulWidth ? "100%" : "70%")};
`;

const RequiredText = styled.span`
color: ${props => props.theme.palette.common.black};
font-size: 0.875rem;
font-weight: 700;
white-space: nowrap;
&::after {
&.required::after {
content: "*";
color: ${props => props.theme.palette.common.red};
margin-inline-start: 4px;
Expand Down
Loading

0 comments on commit b3e13d5

Please sign in to comment.