Skip to content

Commit

Permalink
feat: next-intl addon working
Browse files Browse the repository at this point in the history
  • Loading branch information
stevensacks committed Jul 22, 2024
1 parent b0b7019 commit f128c6c
Show file tree
Hide file tree
Showing 53 changed files with 4,110 additions and 4,232 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ jobs:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v2

- name: Prepare repository
run: git fetch --unshallow --tags

- name: Use Node.js 18.x
uses: actions/setup-node@v4
uses: actions/setup-node@v3
with:
node-version: 18.x

Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ node_modules/
storybook-static/
build-storybook.log
.DS_Store
.env
.env
.idea
.npmrc
6 changes: 5 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{}
{
"bracketSpacing": false,
"singleQuote": true,
"tabWidth": 4
}
9 changes: 5 additions & 4 deletions .storybook/local-preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
* to load the built addon in this test Storybook
*/
function previewAnnotations(entry = []) {
return [...entry, require.resolve("../dist/preview.js")];
return [...entry, require.resolve("../dist/preview.js")];
}

function managerEntries(entry = []) {
return [...entry, require.resolve("../dist/manager.js")];
return [...entry, require.resolve("../dist/manager.js")];
}

module.exports = {
managerEntries,
previewAnnotations,
managerEntries,
previewAnnotations,
};
8
28 changes: 14 additions & 14 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import type { StorybookConfig } from "@storybook/react-vite";
const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"./local-preset.js",
],
framework: {
name: "@storybook/react-vite",
options: {},
},
docs: {
autodocs: "tag",
},
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"./local-preset.js",
],
framework: {
name: "@storybook/react-vite",
options: {},
},
docs: {
autodocs: "tag",
},
};
export default config;
12 changes: 12 additions & 0 deletions .storybook/nextIntl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import en from '../src/stories/messages/en';
import fr from '../src/stories/messages/fr';
import ja from '../src/stories/messages/ja';

const messages: Record<string, any> = {en, fr, ja};

const nextIntl = {
defaultLocale: 'en',
messages,
};

export default nextIntl;
2 changes: 1 addition & 1 deletion .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<script>
window.global = window;
window.global = window;
</script>
32 changes: 21 additions & 11 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import type { Preview } from "@storybook/react";
import type {Preview} from '@storybook/react';
// @ts-ignore
import nextIntl from './nextIntl';

const preview: Preview = {
parameters: {
backgrounds: {
default: "light",
globals: {
locale: 'en',
locales: {
en: {icon: '🇺🇸', title: 'English', right: 'EN'},
fr: {icon: '🇫🇷', title: 'Français', right: 'FR'},
ja: {icon: '🇯🇵', title: '日本語', right: 'JP'},
},
},
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
parameters: {
backgrounds: {
default: 'light',
},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
nextIntl,
},
},
};

export default preview;
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Storybook contributors
Copyright (c) 2021 Storybook contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit f128c6c

Please sign in to comment.