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

chore: add storybook initial config #2657

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,5 @@ packages/core/@generated/persisted-documents.json
/package-lock.json
/tmp
oclif.manifest.json

*storybook.log
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
".vscode/",
".cache/",
"__generated__",
"@generated"
"@generated",
"storybook-static"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

storybook's output

]
},
"formatter": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"version": "0.0.0",
"volta": {
"node": "18.19.0",
"yarn": "1.19.1"
"yarn": "1.22.22"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required by storybook

},
"dependencies": {},
"packageManager": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"volta": {
"node": "18.19.0",
"yarn": "1.19.1"
"yarn": "1.22.22"
},
"sideEffects": false,
"dependencies": {
Expand Down
28 changes: 28 additions & 0 deletions packages/storybook/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { join, dirname } from 'path'

/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value) {
return dirname(require.resolve(join(value, 'package.json')))
}

/** @type { import('@storybook/nextjs').StorybookConfig } */
const config = {
stories: [
'../stories/**/*.mdx',
'../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
],
addons: [
getAbsolutePath('@storybook/addon-onboarding'),
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('@chromatic-com/storybook'),
getAbsolutePath('@storybook/addon-interactions'),
],
framework: {
name: getAbsolutePath('@storybook/nextjs'),
options: {},
},
}
export default config
15 changes: 15 additions & 0 deletions packages/storybook/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import './styles.scss'

/** @type { import('@storybook/react').Preview } */
const preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
}

export default preview
3 changes: 3 additions & 0 deletions packages/storybook/.storybook/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import '@faststore/ui/src/styles/base/utilities.scss';
@import '@faststore/ui/src/styles/global.scss';
@import '@faststore/ui/src/styles/components.scss';
34 changes: 34 additions & 0 deletions packages/storybook/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@fatstore/storybook",
"version": "0.0.0",
"private": true,
"devDependencies": {
"@chromatic-com/storybook": "^3.2.4",
"@storybook/addon-essentials": "^8.5.2",
"@storybook/addon-interactions": "^8.5.2",
"@storybook/addon-onboarding": "^8.5.2",
"@storybook/blocks": "^8.5.2",
"@storybook/nextjs": "^8.5.2",
"@storybook/react": "^8.5.2",
"@storybook/test": "^8.5.2",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.21",
"sass": "^1.83.4",
"storybook": "^8.5.2"
},
"volta": {
"node": "18.19.0",
"yarn": "1.22.22"
},
"scripts": {
"dev": "storybook dev -p 6006",
"build": "storybook build"
},
"dependencies": {
"@faststore/components": "3.11.4",
"@faststore/ui": "3.11.4",
"next": "^15.1.6",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}
10 changes: 10 additions & 0 deletions packages/storybook/stories/badge.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react'
import { Badge } from '@faststore/ui'

export default {
title: 'Badge',
}

export function Default() {
return <Badge>New arrival</Badge>
}
14 changes: 14 additions & 0 deletions packages/storybook/stories/button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'
import { Button } from '@faststore/ui'

export default {
title: 'Button',
}

export function Default() {
return <Button>Click</Button>
}

export function Primary() {
return <Button variant="primary">Primary action</Button>
}
4 changes: 4 additions & 0 deletions packages/storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["stories"]
}
Loading
Loading