Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
frontend: integrate storybook with i18n & cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sandhose committed Oct 19, 2023
1 parent 4364805 commit 6a453c9
Show file tree
Hide file tree
Showing 14 changed files with 3,321 additions and 6,304 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/translations-download.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: localazy/download@v1.1.0

- name: "Fix the owner of the downloaded files"
run: "sudo chown runner:docker translations/*.json"
run: "sudo chown runner:docker translations/*.json frontend/locales/*.json"

- name: Create Pull Request
id: cpr
Expand All @@ -29,6 +29,7 @@ jobs:
branch: actions/localazy-download
delete-branch: true
title: Localazy Download
commit-message: Translations updates

- name: Enable automerge
run: gh pr merge --merge --auto "$PR_NUMBER"
Expand Down
3 changes: 3 additions & 0 deletions frontend/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const config: StorybookConfig = {

// Theme switch toolbar
"@storybook/addon-toolbars",

// i18next integration
"storybook-react-i18next",
],

framework: "@storybook/react-vite",
Expand Down
19 changes: 18 additions & 1 deletion frontend/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { ArgTypes, Decorator, Parameters } from "@storybook/react";
import { ArgTypes, Decorator, Parameters, Preview } from "@storybook/react";
import { useLayoutEffect } from "react";

import "../src/main.css";
import i18n from "../src/i18n";

export const parameters: Parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
Expand Down Expand Up @@ -74,3 +76,18 @@ const withThemeProvider: Decorator = (Story, context) => {
};

export const decorators: Decorator[] = [withThemeProvider];

const preview: Preview = {
globals: {
locale: "en",
locales: {
en: "English",
fr: "Français",
},
},
parameters: {
i18n,
},
};

export default preview;
5 changes: 4 additions & 1 deletion frontend/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"action": {
"back": "Back",
"cancel": "Cancel",
"continue": "Continue",
"save": "Save"
Expand Down Expand Up @@ -131,9 +132,11 @@
},
"verify_email": {
"code_field_label": "6-digit code",
"enter_code_prompt": "Enter the 6-digit code sent to <1>{{email}</1>",
"enter_code_prompt": "Enter the 6-digit code sent to <2>{{email}}</2>",
"heading": "Verify your email",
"invalid_code_alert": "Invalid code",
"resend_email": "Resend email",
"sent": "Sent!",
"unknown_email": "Unknown email"
}
}
Expand Down
52 changes: 52 additions & 0 deletions frontend/package-lock.json

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

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"react-test-renderer": "^18.2.0",
"rimraf": "^5.0.5",
"storybook": "^7.5.0",
"storybook-react-i18next": "^2.0.9",
"tailwindcss": "^3.3.3",
"typescript": "5.2.2",
"vite": "^4.4.11",
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/components/VerifyEmail/VerifyEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const BackButton: React.FC = () => {
const { onClick, href, pending } = useNavigationLink({
type: "profile",
});
const { t } = useTranslation();

return (
<Button
Expand All @@ -122,7 +123,7 @@ const BackButton: React.FC = () => {
Icon={IconArrowLeft}
kind="tertiary"
>
{pending ? "Loading..." : "Back"}
{pending ? t("common.loading") : t("action.back")}
</Button>
);
};
Expand Down Expand Up @@ -187,7 +188,7 @@ const VerifyEmail: React.FC<{
<Trans i18nKey="frontend.verify_email.enter_code_prompt">
Enter the 6-digit code sent to{" "}
<Text as="span" size="lg" weight="semibold">
{{ codeEmail }}
{{ email: codeEmail }}
</Text>
</Trans>
</Text>
Expand Down Expand Up @@ -222,7 +223,9 @@ const VerifyEmail: React.FC<{
disabled={pending || emailSent}
onClick={onResendClick}
>
{emailSent ? "Sent!" : "Resend email"}
{emailSent
? t("frontend.verify_email.sent")
: t("frontend.verify_email.resend_email")}
</Button>
<BackButton />
</Form>
Expand Down
Loading

0 comments on commit 6a453c9

Please sign in to comment.