Skip to content

Commit

Permalink
feat: adding welcome & get started pages also customizing storybook UI
Browse files Browse the repository at this point in the history
  • Loading branch information
syauqi committed Jan 25, 2024
1 parent b40dba0 commit 03337ae
Show file tree
Hide file tree
Showing 15 changed files with 638 additions and 260 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@nx/vite": "17.1.2",
"@nx/web": "17.1.2",
"@size-limit/preset-small-lib": "^8.2.4",
"@storybook/addon-backgrounds": "^7.6.10",
"@storybook/addon-controls": "^7.5.3",
"@storybook/addon-essentials": "^7.6.0-alpha.4",
"@storybook/addon-interactions": "^7.6.0-alpha.4",
Expand All @@ -73,11 +74,13 @@
"@storybook/blocks": "^7.6.0-alpha.4",
"@storybook/core-server": "7.5.3",
"@storybook/jest": "^0.2.3",
"@storybook/manager-api": "^7.6.10",
"@storybook/react": "^7.6.0-alpha.4",
"@storybook/react-vite": "^7.6.0-alpha.4",
"@storybook/test": "^7.6.0-alpha.4",
"@storybook/test-runner": "^0.13.0",
"@storybook/testing-library": "^0.2.2",
"@storybook/theming": "^7.6.10",
"@swc-node/register": "~1.6.7",
"@swc/core": "~1.3.85",
"@testing-library/react": "14.0.0",
Expand Down Expand Up @@ -120,6 +123,7 @@
"dependencies": {
"@headlessui/react": "^1.7.17",
"@nrwl/react": "^17.1.2",
"@storybook/addon-docs": "^7.6.10",
"@tailwindcss/forms": "^0.5.6",
"clsx": "^2.0.0",
"react": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/typography/src/stories/Text.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default {
},
argTypes: {
type: {
description: "Size of the texts",
description: "Size of the text",
control: {
type: 'select'
},
Expand Down
11 changes: 11 additions & 0 deletions packages/ui/.storybook/BootwindTheme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { create } from '@storybook/theming/create';

export default create({
base: 'light',
brandTitle: `
<div style="display: flex; gap: 4px; align-items: center;">
<img src="https://res.cloudinary.com/dmww1p65r/image/upload/v1706181221/gxlbop2zywgiyzbujh7c.png"></img>
<span style="font-weight:bold;"> Bootwind UI</span>
</div>
`,
});
11 changes: 9 additions & 2 deletions packages/ui/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
import { mergeConfig } from 'vite';

const config: StorybookConfig = {
stories: ['../../**/*.stories.@(js|jsx|ts|tsx|mdx)'],
addons: ['@storybook/addon-essentials', '@storybook/addon-interactions'],
stories: [
'../../../pages/*.stories.mdx',
'../../**/*.stories.@(js|jsx|ts|tsx|mdx)',
],
addons: [
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-links',
],
framework: {
name: '@storybook/react-vite',
options: {},
Expand Down
128 changes: 128 additions & 0 deletions packages/ui/.storybook/manager-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<style>
#storybook-explorer-searchfield {
font-weight: 400 !important;
font-size: 14px !important;
letter-spacing: -0.01em !important;
line-height: 14px !important;
}

/*
* Hides "Addons" button from mobile view nav.
*/
nav > button:last-child {
display: none;
}

/*
Storybook has proposed a feature for this in https://github.com/storybookjs/storybook/issues/9209
which will configure stories to exist in deeplink URL format, but do not appear in the nav tree or the docs page
Usign suggested temporary workaround until storybook gets proper support
See https://github.com/microsoft/fluentui/blob/master/rfcs/convergence/authoring-stories.md#10-internal-stories-for-testing
*/
[id*='accessibility-stories'] {
display: none !important;
}

/* remove margin from sidebar logo */
.sidebar-header > div:first-of-type {
margin-right: 0;
}

/* remove sidebar shortcuts menu */
.sidebar-header > div:last-child {
display: none;
}

/* Add left side background color splash */
/* colors become distracting in mobile layout so scoped to where sidebar is visible */
@media (min-width: 600px) {
#root > div:before {
content: '';
position: absolute;
top: -200px;
left: -200px;
width: 400px;
height: 400px;
background: #6666ff;
opacity: 0.7;
filter: blur(150px);
z-index: 100;
}

/* Add right side background color splash */
#root > div:after {
content: '';
position: absolute;
top: -200px;
right: -200px;
width: 400px;
height: 400px;
background: #b3d4ff;
opacity: 0.8;
filter: blur(150px);
}
}

/* Give sidebar a transparent white background to match design */
.sidebar-container {
background: rgba(255, 255, 255, 0.63);
z-index: 101 !important;
}

/* remove background preventing color splash from showing */
#storybook-preview-wrapper {
background: transparent;
}

/*
* Set position fixed to create a layer and prevent iframe from jumping when content is
* larger than the viewport and the iframe itself
*/
[role='main'] {
position: fixed;
}

/* remove box shadow style from storybooks wrapper div */
[role='main'] > div {
box-shadow: none;
}

/* permanently hide toolbar so animation never appears on page load */
[role='main'] .os-host {
display: none;
}

/* stop offset from changing page dimensions when 't' is pressed and toolbar opened */
[role='main'] > div > div > div {
top: 0 !important;
height: 100% !important;
}

/* remove the docs wrapper bg to let page bg show through */
/* remove unnecessary padding now that theme switcher is not taking up space */
#docs-root .sbdocs-wrapper {
background: transparent !important;
padding-top: 0;
}

/* sb-show-main is missing during page transitions causing a page shift */
/* todo: cleanup once we no longer inherit docs-root */
.sb-show-main.sb-main-fullscreen,
.sb-main-fullscreen {
margin: 0;
padding: 0;
display: block;
}

.sbdocs .sbdocs-wrapper .css-k7lbue {
background-color: transparent !important;
}

/* remove loading overlay */
.sb-preparing-story,
.sb-preparing-docs,
.sb-nopreview,
.sb-errordisplay {
display: none !important;
}
</style>
7 changes: 7 additions & 0 deletions packages/ui/.storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { addons } from '@storybook/manager-api';
import BootwindTheme from './BootwindTheme';

addons.setConfig({
theme: BootwindTheme,
showPanel: false,
});
13 changes: 13 additions & 0 deletions packages/ui/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import '../src/scss/main.scss';
import type { Preview } from '@storybook/react';
import BootwindTheme from './BootwindTheme';

const preview: Preview = {
parameters: {
options: {
storySort: {
order: [
'Welcome',
'❖ • Core',
[
'Typography',
Expand Down Expand Up @@ -44,19 +46,30 @@ const preview: Preview = {
},
},
actions: { argTypesRegex: '^on[A-Z].*' },
enableShortcuts: false,
backgrounds: {
default: 'bootwind',
values: [
{
name: 'bootwind',
value: '#F3F4F6',
},
{
name: 'purple-bootwind',
value: '#6666FF',
},
],
},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
disabled: true,
expanded: true,
},
docs: {
theme: BootwindTheme,
},
},
};
Expand Down
77 changes: 77 additions & 0 deletions packages/ui/.storybook/shell.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/* remove margin from sidebar logo */
.sidebar-header > div:first-of-type {
margin-right: 0;
}

/* remove sidebar shortcuts menu */
.sidebar-header > div:last-child {
display: none;
}

/* Add left side background color splash */
/* colors become distracting in mobile layout so scoped to where sidebar is visible */
@media (min-width: 600px) {
#root > div:before {
content: '';
position: absolute;
top: -200px;
left: -200px;
width: 400px;
height: 400px;
background: #c989e8;
opacity: 0.5;
filter: blur(150px);
}

/* Add right side background color splash */
#root > div:after {
content: '';
position: absolute;
top: -200px;
right: -200px;
width: 400px;
height: 400px;
background: #b3d4ff;
opacity: 0.5;
filter: blur(150px);
}
}

/* Give sidebar a transparent white background to match design */
.sidebar-container {
background: rgba(255, 255, 255, 0.6);
}

/* remove background preventing color splash from showing */
#storybook-preview-wrapper {
background: transparent;
}

/*
* Set position fixed to create a layer and prevent iframe from jumping when content is
* larger than the viewport and the iframe itself
*/
[role='main'] {
position: fixed;
}

/* remove box shadow style from storybooks wrapper div */
[role='main'] > div {
box-shadow: none;
}

/* permanently hide toolbar so animation never appears on page load */
[role='main'] .os-host {
display: none;
}

/* stop offset from changing page dimensions when 't' is pressed and toolbar opened */
[role='main'] > div > div > div {
top: 0 !important;
height: 100% !important;
}

/* Remove 'Published on Chromatic' banner */
#back-to-chromatic {
display: none !important;
}
16 changes: 8 additions & 8 deletions packages/ui/src/scss/main.scss
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap');
@import "tailwind.scss";
@import "variables";
@import 'tailwind.scss';
@import 'variables';

body {
font-family: 'Inter';
font-family: 'Inter';
}
a {
@apply text-indigo-600 transition duration-150;
@apply text-indigo-600 transition duration-150;
}
.color-default {
@apply text-zinc-400
@apply text-zinc-400;
}
a.color-default {
@apply hover:text-zinc-800;
@apply hover:text-zinc-800;
}

.tooltip-wrapper:hover .tooltip-content {
display: block
}
display: block;
}
21 changes: 13 additions & 8 deletions packages/ui/src/scss/tailwind.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
body {
@apply bg-background text-foreground;
}
h1,h2,h3,h4,h5,h6 {
color: var(--heading-foreground);
}
}
body {
@apply bg-background text-foreground;
}
h1,
h2,
h3,
h4,
h5,
h6 {
color: var(--heading-foreground);
}
}
8 changes: 8 additions & 0 deletions pages/Getstarted.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Meta } from '@storybook/blocks';

<Meta title="Get Started" />

<div classname="content">
<h1>Get Started</h1>
<h3>Test</h3>
</div>
Loading

0 comments on commit 03337ae

Please sign in to comment.