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: initialize storybook using nx command #97

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
eff4183
chore: initialize storybook using nx command
MFarabi619 Sep 10, 2024
007e188
chore(deps): upversion storybook to 8.3.0
MFarabi619 Sep 14, 2024
5d9aab0
feat(libs/storybook-host): intialize library
MFarabi619 Sep 14, 2024
33007a4
feat(libs/storybook-host): configure library to use storybook
MFarabi619 Sep 14, 2024
1ff9815
chore(libs/storybook-host): migrate all storybook packages to latest
MFarabi619 Sep 14, 2024
b1a65a7
chore(libs/storybook-host): create basic button for testing purposes
MFarabi619 Sep 14, 2024
6dccbbc
chore(deps): add storybook measure addon
MFarabi619 Sep 14, 2024
f5f3cb7
chore(deps): add storybook viewports addon
MFarabi619 Sep 14, 2024
7098ea3
chore(deps): add storybook outline addon
MFarabi619 Sep 14, 2024
ff0a22e
chore(deps): add storybook dark mode addon
MFarabi619 Sep 14, 2024
2bae181
chore(deps): add storybook themes addon
MFarabi619 Sep 14, 2024
f002570
chore(deps): add storybook backgrounds addon
MFarabi619 Sep 14, 2024
06a34c2
chore(deps): add storybook accessibility addon
MFarabi619 Sep 14, 2024
6d8712f
chore(deps): add storybook controls and designs addons
MFarabi619 Sep 14, 2024
31119b7
chore(deps): add storybook actions addon
MFarabi619 Sep 14, 2024
e4f4bdc
chore(deps): add storybook links addon
MFarabi619 Sep 14, 2024
2c87bbf
chore(deps): add storybook docs addon
MFarabi619 Sep 14, 2024
3914bdb
chore(deps): add storybook html addon
MFarabi619 Sep 14, 2024
e4f003b
perf(deps): move storybook measure, and viewport addons to dev depend…
MFarabi619 Sep 14, 2024
12dfc41
feat(ui/storybook-host): create preview file with layout, actions, co…
MFarabi619 Sep 14, 2024
c052e92
feat(ui/storybook-host): add custom viewports
MFarabi619 Sep 14, 2024
f6c7230
chore(config/storybook-host): add type module to package.json
MFarabi619 Sep 14, 2024
30b746f
feat(ui/storybook-host): add custom background colors
MFarabi619 Sep 14, 2024
66c9eab
chore(deps): add storybook blocks and theming
MFarabi619 Sep 14, 2024
54a947d
chore(deps): add next-themes
MFarabi619 Sep 14, 2024
6a38a85
feat(ui/storybook-host): add dark mode with cuhacking logo
MFarabi619 Sep 14, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ Thumbs.db
# Next.js
.next
out


storybook-static
3 changes: 3 additions & 0 deletions apps/website/app/components/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function Button() {
return <button type="button">Button</button>
}
12 changes: 12 additions & 0 deletions libs/storybook-host/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nx/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
Binary file added libs/storybook-host/.storybook/cuhacking-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions libs/storybook-host/.storybook/custom-viewports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport'

export const customViewports = {
...INITIAL_VIEWPORTS,
'720p': {
name: '720p',
styles: {
width: '1280px',
height: '720px',
},
},
'1080p': {
name: '1080p',
styles: {
width: '1920px',
height: '1080px',
},
},
'2k': {
name: '2K',
styles: {
width: '2560px',
height: '1440px',
},
},
'4k': {
name: '4K',
styles: {
width: '3840px',
height: '2160px',
},
},
'21/9': {
name: '21/9',
styles: {
width: '2560px',
height: '1080px',
},
},
}
222 changes: 222 additions & 0 deletions libs/storybook-host/.storybook/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
@config '../../../apps/website/tailwind.config.ts';
@tailwind base;
@tailwind components;
@tailwind utilities;

/*Easily customize theme: https://zippystarter.com/tools/shadcn-ui-theme-generator*/
/*Explore the Shadcn/ui ecosystem: https://github.com/birobirobiro/awesome-shadcn-ui*/

/*'primary': '#00A3E0',*/
/*'primary-content': '#000a12',*/
/*'secondary': '#00629b',*/
/*'secondary-content': '#d0dfec',*/
/*'accent': '#FFD100',*/
/*'accent-content': '#161000',*/
/*'neutral': '#00843d',*/
/*'neutral-content': '#d3e6d7',*/
/*// "base-100": "#002855",*/
/*'base-100': '#000000',*/
/*'base-200': '#002149',*/
/*'base-300': '#001b3d',*/
/*'base-content': '#c8d1dc',*/
/*'info': '#009CA6',*/
/*'info-content': '#00090a',*/
/*'success': '#78be21',*/
/*'success-content': '#050d00',*/
/*'warning': '#ffa400',*/
/*'warning-content': '#160a00',*/
/*'error': '#BA0C2F',*/
/*'error-content': '#f8d4d3',*/

@layer base {
:root {
--background: 196 100% 95%;
/* hsl(196, 100%, 95%) */
--foreground: 196 5% 0%;
/* hsl(196, 5%, 0%) */
--card: 196 50% 90%;
/* hsl(196, 50%, 90%) */
--card-foreground: 196 5% 10%;
/* hsl(196, 5%, 10%) */
--popover: 196 100% 95%;
/* hsl(196, 100%, 95%) */
--popover-foreground: 196 100% 0%;
/* hsl(196, 100%, 0%) */

--primary: 196 100% 43.9%;
/* hsl(196, 100%, 43.9%) */
--primary-foreground: 0 0% 100%;
/* hsl(0, 0%, 100%) */
--auxiliary: 203, 100%, 37%;
/* hsl(203, 100%, 37%) */
--auxiliary-foreground: 213, 13%, 91%;
/* hsl(213, 13%, 91%) */
--tertiary: 52, 100%, 50%;
/* hsl(52, 100%, 50%) */
--tertiary-foreground: 60, 4%, 9%;
/* hsl(60, 4%, 9%) */
--neutral: 143, 100%, 26%;
/* hsl(143, 100%, 26%) */
--neutral-foreground: 141, 13%, 85%;
/* hsl(141, 13%, 85%) */
/*// "base-100": "#002855",*/
/*'base-100': '#000000',*/
/*'base-200': '#002149',*/
/*'base-300': '#001b3d',*/
/*'base-content': '#c8d1dc',*/
--info: 183, 100%, 33%;
/* hsl(183, 100%, 33%) */
--info-foreground: 180, 100%, 3%;
/* hsl(180, 100%, 3%) */
--success: 83, 100%, 25%;
/* hsl(83, 100%, 25%) */
--success-foreground: 120, 100%, 2%;
/* hsl(120, 100%, 2%) */
--warning: 38, 100%, 50%;
/* hsl(38, 100%, 50%) */
--warning-foreground: 30, 100%, 5%;
/* hsl(30, 100%, 5%) */

--secondary: 196 30% 70%;
/* hsl(196, 30%, 70%) */
--secondary-foreground: 0 0% 0%;
/* hsl(0, 0%, 0%) */
--muted: 158 30% 85%;
/* hsl(158, 30%, 85%) */
--muted-foreground: 196 5% 35%;
/* hsl(196, 5%, 35%) */
--accent: 158 30% 80%;
/* hsl(158, 30%, 80%) */
--accent-foreground: 196 5% 10%;
/* hsl(196, 5%, 10%) */
--destructive: 0 100% 30%;
/* hsl(0, 100%, 30%) */
--destructive-foreground: 196 5% 90%;
/* hsl(196, 5%, 90%) */
--border: 196 30% 50%;
/* hsl(196, 30%, 50%) */
--input: 196 30% 18%;
/* hsl(196, 30%, 18%) */
--ring: 196 100% 43.9%;
/* hsl(196, 100%, 43.9%) */
--radius: 0.75rem;
--chart-1: 12 76% 61%;
/* hsl(12, 76%, 61%) */
--chart-2: 173 58% 39%;
/* hsl(173, 58%, 39%) */
--chart-3: 197 37% 24%;
/* hsl(197, 37%, 24%) */
--chart-4: 43 74% 66%;
/* hsl(43, 74%, 66%) */
--chart-5: 27 87% 67%;
/* hsl(27, 87%, 67%) */
}

.dark {
--background: 218 100% 1%;
/* hsl(218, 100%, 1%) */
--foreground: 196 5% 90%;
/* hsl(196, 5%, 90%) */
--card: 196 50% 0%;
/* hsl(196, 50%, 0%) */
--card-foreground: 196 5% 90%;
/* hsl(196, 5%, 90%) */
--popover: 196 50% 5%;
/* hsl(196, 50%, 5%) */
--popover-foreground: 196 5% 90%;
/* hsl(196, 5%, 90%) */
--primary: 196 100% 43.9%;
/* hsl(196, 100%, 43.9%) */
--primary-foreground: 0 0% 100%;
/* hsl(0, 0%, 100%) */

--auxiliary: 203, 100%, 37%;
/* hsl(203, 100%, 37%) */
--auxiliary-foreground: 213, 13%, 91%;
/* hsl(213, 13%, 91%) */
--tertiary: 52, 100%, 50%;
/* hsl(52, 100%, 50%) */
--tertiary-foreground: 60, 4%, 9%;
/* hsl(60, 4%, 9%) */
--neutral: 143, 100%, 26%;
/* hsl(143, 100%, 26%) */
--neutral-foreground: 141, 13%, 85%;
/* hsl(141, 13%, 85%) */
/*// "base-100": "#002855",*/
/*'base-100': '#000000',*/
/*'base-200': '#002149',*/
/*'base-300': '#001b3d',*/
/*'base-content': '#c8d1dc',*/
--info: 183, 100%, 33%;
/* hsl(183, 100%, 33%) */
--info-foreground: 180, 100%, 3%;
/* hsl(180, 100%, 3%) */
--success: 83, 100%, 25%;
/* hsl(83, 100%, 25%) */
--success-foreground: 120, 100%, 2%;
/* hsl(120, 100%, 2%) */
--warning: 38, 100%, 50%;
/* hsl(38, 100%, 50%) */
--warning-foreground: 30, 100%, 5%;
/* hsl(30, 100%, 5%) */

--secondary: 196 30% 10%;
/* hsl(196, 30%, 10%) */
--secondary-foreground: 0 0% 100%;
/* hsl(0, 0%, 100%) */
--muted: 158 30% 15%;
/* hsl(158, 30%, 15%) */
--muted-foreground: 196 5% 60%;
/* hsl(196, 5%, 60%) */
--accent: 158 30% 15%;
/* hsl(158, 30%, 15%) */
--accent-foreground: 196 5% 90%;
/* hsl(196, 5%, 90%) */
--destructive: 0 100% 30%;
/* hsl(0, 100%, 30%) */
--destructive-foreground: 196 5% 90%;
/* hsl(196, 5%, 90%) */
--border: 196 30% 18%;
/* hsl(196, 30%, 18%) */
--input: 196 30% 18%;
/* hsl(196, 30%, 18%) */
--ring: 196 100% 43.9%;
/* hsl(196, 100%, 43.9%) */
--radius: 0.75rem;
--chart-1: 220 70% 50%;
/* hsl(220, 70%, 50%) */
--chart-2: 160 60% 45%;
/* hsl(160, 60%, 45%) */
--chart-3: 30 80% 55%;
/* hsl(30, 80%, 55%) */
--chart-4: 280 65% 60%;
/* hsl(280, 65%, 60%) */
--chart-5: 340 75% 55%;
/* hsl(340, 75%, 55%) */
}
}

@layer base {
* {
@apply border-border;
}

body {
@apply bg-background text-foreground;
}
}

.backdrop-blur-xs {
@apply backdrop-blur-[2px];
}

@keyframes bobbing {
0%,
100% {
transform: translateY(-2px);
}

50% {
transform: translateY(2px);
}
}
109 changes: 109 additions & 0 deletions libs/storybook-host/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import type { StorybookConfig } from '@storybook/react-vite'

import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'
import { mergeConfig } from 'vite'

const config: StorybookConfig = {
// Pick up any files ending in .mdx, or stories.{js,jsx,ts,tsx} as stories
stories: ['../src/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'],
// Did not use @storybook/addon-essentials due to lack of toolbar ordering API
addons: [
// --------------- TOOLBAR ICONS ---------------
// Ruler
'@storybook/addon-measure',
// Phone
'@storybook/addon-viewport',
// Dotted Outline
'@storybook/addon-outline',
// Sun/Moon icon. Toggle Manager, Preview Components, and Preview Background
'storybook-dark-mode',
// Pen. Toggle both Preview Components and Preview Background
'@storybook/addon-themes',
// Portrait. Toggle only Preview Background. Not affected by other two, use to 'lock' the background.
'@storybook/addon-backgrounds',
// Person inside circle icon. Also 'Accessibility' tab to action bar
'@storybook/addon-a11y',

// --------------- ACTION BAR ---------------
// https://storybook.js.org/docs/essentials/controls
'@storybook/addon-controls',
// Accessibility tab added by '@storybook/addon-a11y'
{
name: '@storybook/addon-designs', // Actually has amazing docs for once: https://storybookjs.github.io/addon-designs/?path=/docs/docs-quick-start--docs
options: {
// renderTarget: 'canvas' | 'tab'
},
},
// https://storybook.js.org/docs/essentials/actions
'@storybook/addon-actions',
// https://storybook.js.org/docs/essentials/interactions
'@storybook/addon-interactions', // Must be listed after @storybook/addon-actions or @storybook/addon-essentials

'@storybook/addon-links',

// Chromatic Visual Test Server
'@chromatic-com/storybook',

// Code for component story
// {
// name: '@storybook/addon-storysource',
// options: {
// rule: {
// test: [/\.stories\.tsx?$/],
// include: [path.resolve(__dirname, '../src')], // You can specify directories
// },
// loaderOptions: {
// parser: 'typescript',
// injectStoryParameters: false,
// prettierConfig: { printWidth: 80, singleQuote: false },
// },
// enforce: 'pre',
// },

// --------------- NO ICONS ---------------
// Onboarding flow
// '@storybook/addon-onboarding',
// Custom toolbars
// '@storybook/addon-toolbars',
// Auto-generate MDX/React/JSX documentation for components
// https://github.com/storybookjs/storybook/tree/next/code/addons/docs
{
name: '@storybook/addon-docs',
options: {
// csfPluginOptions: null,
// mdxPluginOptions: {
// mdxCompileOptions: {
// remarkPlugins: [],
// },
// },
sourceLoaderOptions: {
injectStoryParameters: false,
},
},
},
// HTML Tab in action bar
// https://github.com/whitespace-se/storybook-addon-html
// '@whitespace/storybook-addon-html',
],
framework: {
name: '@storybook/react-vite',
options: {},
},

viteFinal: async config =>
mergeConfig(config, {
plugins: [nxViteTsPaths()],
}),

docs: {},

typescript: {
reactDocgen: 'react-docgen-typescript',
},
}

export default config

// To customize your Vite configuration you can use the viteFinal field.
// Check https://storybook.js.org/docs/react/builders/vite#configuration
// and https://nx.dev/recipes/storybook/custom-builder-configs
Loading