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

Frontend environment tag, Storybook update, Fixes after code review, Merge pull requests for Docker enhancements #473

Merged
merged 5 commits into from
Mar 13, 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
48 changes: 28 additions & 20 deletions govtool/frontend/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import React from "react";
import type { Preview } from "@storybook/react";
import { ThemeProvider } from "@emotion/react";
import { theme } from "../src/theme";
import { MemoryRouter, Routes, Route } from "react-router-dom";
import { QueryClient, QueryClientProvider } from "react-query";
import { I18nextProvider } from "react-i18next";
import i18n from "../src/i18n";
import { ModalProvider } from "../src/context/modal";

const queryClient = new QueryClient();

Expand All @@ -19,26 +23,30 @@ const preview: Preview = {
decorators: [
(Story) => (
<QueryClientProvider client={queryClient}>
<ThemeProvider theme={theme}>
<MemoryRouter>
<Routes>
<Route
path="/*"
element={
<div
style={{
margin: "0px",
padding: "0px",
position: "relative",
}}
>
<Story />
</div>
}
/>
</Routes>
</MemoryRouter>
</ThemeProvider>
<ModalProvider>
<I18nextProvider i18n={i18n}>
<ThemeProvider theme={theme}>
<MemoryRouter>
<Routes>
<Route
path="/*"
element={
<div
style={{
margin: "0px",
padding: "0px",
position: "relative",
}}
>
<Story />
</div>
}
/>
</Routes>
</MemoryRouter>
</ThemeProvider>
</I18nextProvider>
</ModalProvider>
</QueryClientProvider>
),
],
Expand Down
2 changes: 1 addition & 1 deletion govtool/frontend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ endif
.DEFAULT_GOAL := push-frontend

# image tags
frontend_image_tag := $(shell git log -n 1 --format="%H" -- $(root_dir)/govtool/frontend)
frontend_image_tag := $(shell git log -n 1 --format="%H" -- $(root_dir)/govtool/frontend)-$(env)

.PHONY: build-frontend
build-frontend: docker-login
Expand Down
17 changes: 11 additions & 6 deletions govtool/frontend/src/stories/DashboardCard.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export const DashboardCardComponent: Story = {
args: {
description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
firstButtonLabel: "first button",
imageHeight: 80,
imageURL: IMAGES.govActionDelegateImage,
imageWidth: 115,
secondButtonLabel: "second button",
title: "Action card",
},
Expand All @@ -38,13 +36,22 @@ export const DashboardCardComponent: Story = {
},
};

export const WithDRepIdDashboardCardComponent: Story = {
args: {
description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
firstButtonLabel: "first button",
imageURL: IMAGES.govActionDelegateImage,
secondButtonLabel: "second button",
title: "Action card",
cardId: "drep1gwsw9ckkhuwscj9savt5f7u9xsrudw209hne7pggcktzuw5sv32",
},
};

export const isLoadingDashboardCard: Story = {
args: {
description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
firstButtonLabel: "first button",
imageHeight: 80,
imageURL: IMAGES.govActionDelegateImage,
imageWidth: 115,
secondButtonLabel: "second button",
title: "Action card",
isLoading: true,
Expand All @@ -62,9 +69,7 @@ export const isProgressDashboardCard: Story = {
args: {
description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
firstButtonLabel: "first button",
imageHeight: 80,
imageURL: IMAGES.govActionDelegateImage,
imageWidth: 115,
secondButtonLabel: "second button",
title: "Action card",
inProgress: true,
Expand Down
16 changes: 1 addition & 15 deletions govtool/frontend/src/stories/DashboardTopNav.stories.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react";

import { DashboardTopNav } from "@organisms";
import { IMAGES } from "@/consts";
import { within, userEvent, waitFor, screen } from "@storybook/testing-library";
import { expect } from "@storybook/jest";

Expand All @@ -15,7 +14,7 @@ export default meta;
type Story = StoryObj<typeof meta>;

export const DashboardTopNavComponent: Story = {
args: { title: "Example title", isDrawer: true },
args: { title: "Example title" },
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
expect(canvas.getByText("Example title")).toBeInTheDocument();
Expand All @@ -31,16 +30,3 @@ export const DashboardTopNavComponent: Story = {
});
},
};

export const DashboardTopNavWithIcon: Story = {
args: {
title: "Example title",
isDrawer: true,
imageSRC: IMAGES.appLogoWithoutText,
imageHeight: 24,
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
expect(canvas.getByRole("img")).toBeInTheDocument();
},
};
16 changes: 16 additions & 0 deletions govtool/frontend/src/stories/DelegateActionRadio.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,19 @@ export const ActionRadioActive: Story = {
);
},
};

export const ActionRadioOnlyTitle: Story = {
args: {
title: "Title",
value: "",
isChecked: false,
},
};

export const ActionRadioOnlyTitleChecked: Story = {
args: {
title: "Title",
value: "",
isChecked: true,
},
};
12 changes: 12 additions & 0 deletions govtool/frontend/src/stories/Input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,15 @@ ErrorAndLabel.play = async ({ canvasElement }) => {
expect(canvas.getByText("Label")).toBeInTheDocument();
expect(canvas.getByTestId("error-message-error")).toBeInTheDocument();
};

export const WithHelpfulText = Template.bind({});
WithHelpfulText.args = {
helpfulText: "Helpful text",
};

export const WithAllProps = Template.bind({});
WithAllProps.args = {
label: "Label",
helpfulText: "Helpful text",
errorMessage: "Error message",
};
26 changes: 26 additions & 0 deletions govtool/frontend/src/stories/LinkWithIcon.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Meta, StoryObj } from "@storybook/react";
import { LinkWithIcon } from "@molecules";
import { ICONS } from "@consts";

const meta: Meta<typeof LinkWithIcon> = {
title: "Example/LinkWithIcon",
component: LinkWithIcon,
parameters: {
layout: "centered",
},
};

export default meta;

export const Default: StoryObj<typeof LinkWithIcon> = {
args: {
label: "Default Link",
},
};

export const WithCustomIcon: StoryObj<typeof LinkWithIcon> = {
args: {
label: "Custom Icon Link",
icon: <img src={ICONS.link} />,
},
};
31 changes: 31 additions & 0 deletions govtool/frontend/src/stories/LoadingButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { Meta, StoryObj } from "@storybook/react";

import { LoadingButton } from "@atoms";

const meta = {
title: "Example/LoadingButton",
component: LoadingButton,
parameters: {
layout: "centered",
},
tags: ["autodocs"],
} satisfies Meta<typeof LoadingButton>;

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

export const Primary: Story = {
args: {
children: "Button",
variant: "contained",
isLoading: false,
},
};

export const Loading: Story = {
args: {
children: "Button",
variant: "contained",
isLoading: true,
},
};
62 changes: 62 additions & 0 deletions govtool/frontend/src/stories/Step.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Meta, StoryObj } from "@storybook/react";
import { Button } from "@atoms";
import OpenInNewIcon from "@mui/icons-material/OpenInNew";

import { Field, Step } from "@molecules";

const meta: Meta<typeof Step> = {
title: "Example/Step",
component: Step,
parameters: {
layout: "centered",
},
};

export default meta;

export const WithButton: StoryObj<typeof Step> = {
args: {
label: "Download this file",
stepNumber: 1,
component: (
<Button size="extraLarge" sx={{ width: "fit-content" }}>
Info.jsonld
</Button>
),
},
};

export const WithIconButton: StoryObj<typeof Step> = {
args: {
label:
"Save this file in a location that provides a public URL (ex. github)",
stepNumber: 2,
component: (
<Button
endIcon={
<OpenInNewIcon
sx={{
color: "primary",
height: 17,
width: 17,
}}
/>
}
size="extraLarge"
sx={{ width: "fit-content" }}
variant="text"
>
Read full guide
</Button>
),
},
};

export const WithInput: StoryObj<typeof Step> = {
args: {
label:
"Save this file in a location that provides a public URL (ex. github)",
stepNumber: 2,
component: <Field.Input name="storingURL" placeholder={"URL"} />,
},
};
49 changes: 49 additions & 0 deletions govtool/frontend/src/stories/TextArea.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { Meta, StoryFn } from "@storybook/react";

import { Field } from "@molecules";
import { ComponentProps } from "react";

const meta: Meta<typeof Field.TextArea> = {
title: "Example/TextArea",
component: Field.TextArea,
parameters: {
layout: "centered",
},
tags: ["autodocs"],
};

export default meta;

const Template: StoryFn<ComponentProps<typeof Field.TextArea>> = (args) => {
return <Field.TextArea {...args} />;
};

export const Default = Template.bind({});

export const WithLabel = Template.bind({});
WithLabel.args = {
label: "Label",
};

export const WithHelpfulText = Template.bind({});
WithHelpfulText.args = {
helpfulText: "Helpful text here",
};

export const Error = Template.bind({});
Error.args = {
errorMessage: "Error message",
};

export const ErrorAndLabel = Template.bind({});
ErrorAndLabel.args = {
errorMessage: "Error message",
label: "Label",
};

export const WithAllProps = Template.bind({});
WithAllProps.args = {
label: "Label",
helpfulText: "Helpful text",
errorMessage: "Error message",
};
Loading
Loading