Skip to content

Commit

Permalink
feat: support Storybook 8
Browse files Browse the repository at this point in the history
  • Loading branch information
floriangosse committed Apr 16, 2024
1 parent 4512383 commit 23d99d6
Show file tree
Hide file tree
Showing 43 changed files with 9,729 additions and 9,272 deletions.
3 changes: 0 additions & 3 deletions .babelrc.js

This file was deleted.

File renamed without changes.
23 changes: 2 additions & 21 deletions .storybook/preview.js → .storybook/intl.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export const defaultLocales = ['en', 'de'];

// Provide your messages
const messages = {
export const messages = {
en: { message: 'Just some text.' },
de: { message: 'Nur etwas Text.' },
es: { message: 'Sólo un texto.' }
};

// Provide your formats (optional)
const formats = {
export const formats = {
en: {
date: {
custom: {
Expand All @@ -28,22 +28,3 @@ const formats = {
}
}
};

const getMessages = (locale) => messages[locale];
const getFormats = (locale) => formats[locale];

/**
* @type {import('@storybook/react').Preview}
*/
const preview = {
parameters: {
intl: {
locales: defaultLocales,
defaultLocale: 'en',
getMessages,
getFormats
}
}
};

export default preview;
4 changes: 2 additions & 2 deletions .storybook/local-preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* to load the built addon in this test Storybook
*/
function previewAnnotations(entry = []) {
return [...entry, require.resolve('../dist/preview/index.js')];
return [...entry, require.resolve('../dist/preview.js')];
}

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

module.exports = {
Expand Down
8 changes: 0 additions & 8 deletions .storybook/main.js

This file was deleted.

15 changes: 15 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { StorybookConfig } from '@storybook/react-vite';

const config: StorybookConfig = {
stories: ['../src/stories/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['storybook-addon-intl'],
framework: {
name: '@storybook/react-vite',
options: {}
},
docs: {
autodocs: 'tag'
}
};

export default config;
4 changes: 4 additions & 0 deletions .storybook/preview.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
html,
body {
font-family: sans-serif;
}
20 changes: 20 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { defaultLocales, formats, messages } from './intl';
import { Preview } from '@storybook/react';

import './preview.css';

const getMessages = (locale) => messages[locale];
const getFormats = (locale) => formats[locale];

const preview: Preview = {
parameters: {
intl: {
locales: defaultLocales,
defaultLocale: 'en',
getMessages,
getFormats
}
}
};

export default preview;
48 changes: 0 additions & 48 deletions .storybook/stories/01-Message.stories.js

This file was deleted.

12 changes: 0 additions & 12 deletions .storybook/stories/02-Date.stories.js

This file was deleted.

7 changes: 5 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
roots: ['<rootDir>/src']
export default {
roots: ['<rootDir>/src'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest'
}
};
2 changes: 1 addition & 1 deletion manager.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/manager');
import './dist/manager';
Loading

0 comments on commit 23d99d6

Please sign in to comment.