Skip to content

Commit

Permalink
feat: add icons storybook (#1815)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelAlev authored Apr 18, 2024
1 parent 54d2882 commit 3d6511e
Show file tree
Hide file tree
Showing 30 changed files with 505 additions and 31 deletions.
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ This Storybook instance is configured and served from the `/storybook-docs` pack
In the background, multiple instances of Storybook will start up, one for each component package in the monorepo.

- Storybook for `@frontify/fondue-components` will be available on port 6006
- Storybook for `@frontify/fondue-charts` will be available on port 6007
- Storybook for `@frontify/fondue` will be available on port 6008
- Storybook for `@frontify/fondue-icons` will be available on port 6007
- Storybook for `@frontify/fondue-charts` will be available on port 6008
- Storybook for `@frontify/fondue` will be available on port 6009

You can also start the Storybook instances for the individual packages by running `pnpm storybook` in the respective package directory.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"ci:version": "changeset version",
"lint": "pnpm --stream --filter {packages/**} lint",
"storybook": "concurrently 'pnpm storybook:packages' 'pnpm storybook:main'",
"storybook:main": "wait-on http://localhost:6006 http://localhost:6007 http://localhost:6008 && pnpm --stream --filter {storybook-docs} storybook",
"storybook:main": "wait-on http://localhost:6006 http://localhost:6007 http://localhost:6008 http://localhost:6009 && pnpm --stream --filter {storybook-docs} storybook",
"storybook:packages": "pnpm --parallel --filter {packages/*} storybook --no-open",
"typecheck": "pnpm --stream --filter {packages/*} typecheck",
"changeset": "changeset",
Expand Down
2 changes: 1 addition & 1 deletion packages/charts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"build": "vite build",
"build:watch": "vite build --watch",
"build:storybook": "storybook build",
"storybook": "storybook dev -p 6007",
"storybook": "storybook dev -p 6008",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"typecheck": "tsc --noEmit",
Expand Down
2 changes: 1 addition & 1 deletion packages/fondue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"test:browser": "cypress open --component",
"test:file": "cypress run --component --spec",
"typecheck": "tsc --noEmit",
"storybook": "storybook dev -p 6008",
"storybook": "storybook dev -p 6009",
"ci": "pnpm install --frozen-lockfile"
},
"peerDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/icons/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
icons
src/icons
storybook-static
2 changes: 2 additions & 0 deletions packages/icons/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,5 @@ dist

src/icons
!src/icons/.gitkeep

storybook-static
25 changes: 25 additions & 0 deletions packages/icons/.storybook/DocumentationTemplate.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ArgTypes, Canvas, Controls, Description, Markdown, Meta, Source, Stories, Title } from '@storybook/blocks';

<div className="tw-mx-5 sb-unstyled">

<Meta isTemplate />

<Title />

<Description />

## Preview

<Canvas sourceState="shown" />

## Controls

<Controls />

## API

<ArgTypes />

<Stories />

</div>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
71 changes: 71 additions & 0 deletions packages/icons/.storybook/frontifyTheme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { create } from '@storybook/theming/create';

export const light = create({
base: 'light',

colorPrimary: '#2d3232',
colorSecondary: '#825fff',

// UI
appBg: 'white',
appBorderColor: '#EAEBEE',
appBorderRadius: 4,

// Typography
fontBase:
"'Space Grotesk Frontify', Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'",
fontCode: 'Menlo, Courier, monospace',

// Text colors
textColor: '#2d3232',

// Toolbar default and active colors
barTextColor: '#2d3232',
barSelectedColor: '#2d3232',
barBg: '#FFFFFF',

// Form colors
inputBg: '#FFFFFF',
inputBorder: '#EAEBEE',
inputTextColor: '#2d3232',
inputBorderRadius: 4,

brandTitle: 'Frontify Storybook',
brandUrl: 'https://frontify.com',
brandImage: '/img/logo-charcoal.svg',
});

export const dark = create({
base: 'dark',

colorPrimary: '#fafafa',
colorSecondary: '#825fff',

// UI
appBg: '#1a1c1c',
appBorderColor: '#424747',
appBorderRadius: 4,

// Typography
fontBase:
"'Space Grotesk Frontify', Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'",
fontCode: 'Menlo, Courier, monospace',

// Text colors
textColor: '#fafafa',

// Toolbar default and active colors
barTextColor: '#fafafa',
barSelectedColor: '#fafafa',
barBg: '#1a1d1d',

// Form colors
inputBg: '#1a1c1c',
inputBorder: '#424747',
inputTextColor: '#fafafa',
inputBorderRadius: 4,

brandTitle: 'Frontify Storybook',
brandUrl: 'https://frontify.com',
brandImage: '/img/logo-white.svg',
});
30 changes: 30 additions & 0 deletions packages/icons/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { StorybookConfig } from '@storybook/react-vite';

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
staticDirs: ['assets'],
addons: [
'@etchteam/storybook-addon-status',
'@storybook/addon-a11y',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-links',
'storybook-dark-mode',
],
framework: {
name: '@storybook/react-vite',
options: {},
},
docs: {
autodocs: 'tag',
defaultName: 'Documentation',
},
viteFinal(config) {
// @ts-expect-error untyped name property
config.plugins = (config.plugins ?? []).filter((plugin) => plugin?.name !== 'vite:dts');

return config;
},
};

export default config;
13 changes: 13 additions & 0 deletions packages/icons/.storybook/manager-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Custom CSS for Storybook interface goes here -->
<style>
.sidebar-header {
/* Center dropdown button */
align-items: center !important;
}

.sidebar-header img {
/* Responsive sidebar header image */
width: 100%;
max-width: 200px;
}
</style>
8 changes: 8 additions & 0 deletions packages/icons/.storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* (c) Copyright Frontify Ltd., all rights reserved. */

import { addons } from '@storybook/manager-api';
import { light } from './frontifyTheme';

addons.setConfig({
theme: light,
});
74 changes: 74 additions & 0 deletions packages/icons/.storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<style>
@font-face {
font-display: swap;
font-family: 'Space Grotesk Frontify';
font-style: normal;
font-weight: 300;
src:
url('/fonts/SpaceGroteskFrontify-Light.woff2') format('woff2'),
url('/fonts/SpaceGroteskFrontify-Light.woff') format('woff');
}

@font-face {
font-display: swap;
font-family: 'Space Grotesk Frontify';
font-style: normal;
font-weight: 400;
src:
url('/fonts/SpaceGroteskFrontify-Regular.woff2') format('woff2'),
url('/fonts/SpaceGroteskFrontify-Regular.woff') format('woff');
}

@font-face {
font-display: swap;
font-family: 'Space Grotesk Frontify';
font-style: normal;
font-weight: 500;
src:
url('/fonts/SpaceGroteskFrontify-Medium.woff2') format('woff2'),
url('/fonts/SpaceGroteskFrontify-Medium.woff') format('woff');
}

@font-face {
font-display: swap;
font-family: 'Space Grotesk Frontify';
font-style: normal;
font-weight: 600;
src:
url('/fonts/SpaceGroteskFrontify-SemiBold.woff2') format('woff2'),
url('/fonts/SpaceGroteskFrontify-SemiBold.woff') format('woff');
}

@font-face {
font-display: swap;
font-family: 'Space Grotesk Frontify';
font-style: normal;
font-weight: 700;
src:
url('/fonts/SpaceGroteskFrontify-Bold.woff2') format('woff2'),
url('/fonts/SpaceGroteskFrontify-Bold.woff') format('woff');
}

.side-by-side {
display: grid;
grid-template-columns: 1fr 1fr;
height: 100%;
min-height: 100vh;
}

.light.theme {
background: white;
padding: 1rem;
}

.tw-dark.theme {
background: #1a1c1c;
padding: 1rem;
height: 100%;
min-height: 100vh;
}
</style>

<script>
const global = globalThis;
</script>
55 changes: 55 additions & 0 deletions packages/icons/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import '@frontify/fondue-tokens/styles';
import 'tailwindcss/tailwind.css';
import type { Preview } from '@storybook/react';
import DocumentationTemplate from './DocumentationTemplate.mdx';

const preview: Preview = {
parameters: {
docs: {
page: DocumentationTemplate,
toc: {
title: 'Table of contents',
headingSelector: 'h2, h3',
},
},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
layout: 'fullscreen',
status: {
type: 'legacy',
statuses: {
released: {
background: 'rgb(50, 210, 182)',
color: '#ffffff',
description: 'This component is stable and released',
},
in_progress: {
background: 'rgb(154, 126, 254)',
color: '#ffffff',
description: 'This component is in progress',
},
planned: {
background: 'rgb(254, 194, 50)',
color: '#ffffff',
description: 'This component is planned to be revamped',
},
legacy: {
background: 'rgb(129, 132, 132)',
color: '#ffffff',
description: 'This is a legacy component',
},
deprecated: {
background: 'rgb(153, 33, 54)',
color: '#ffffff',
description: 'This is a legacy component',
},
},
},
},
};

export default preview;
20 changes: 20 additions & 0 deletions packages/icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"build": "pnpm build:download-new-icons && pnpm build:generate-react-icons && vite build",
"build:download-new-icons": "dotenv tsx scripts/download_new_icons.ts",
"build:generate-react-icons": "tsx scripts/generate_react_icons.ts",
"build:storybook": "storybook build",
"storybook": "storybook dev -p 6007",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"typecheck": "tsc --noEmit"
Expand All @@ -46,19 +48,37 @@
"react": "^18"
},
"devDependencies": {
"@etchteam/storybook-addon-status": "^4.2.4",
"@frontify/eslint-config-react": "^0.17.6",
"@frontify/fondue-tokens": "workspace:^",
"@iconify/tools": "^4.0.4",
"@storybook/addon-a11y": "^8.0.8",
"@storybook/addon-essentials": "^8.0.8",
"@storybook/addon-interactions": "^8.0.8",
"@storybook/addon-links": "^8.0.8",
"@storybook/blocks": "^8.0.8",
"@storybook/manager-api": "^8.0.8",
"@storybook/preview-api": "^8.0.8",
"@storybook/react": "^8.0.8",
"@storybook/react-vite": "^8.0.8",
"@storybook/theming": "^8.0.8",
"@types/lodash": "^4.17.0",
"@types/node": "^20.12.7",
"@types/react": "^18.2.77",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.19",
"dotenv-cli": "^7.4.1",
"eslint": "^8.57.0",
"figma-api": "^1.11.0",
"fuzzysort": "^2.0.4",
"lodash": "^4.17.21",
"postcss": "^8.4.38",
"prettier": "^3.2.5",
"react": "^18.2.0",
"storybook": "^8.0.8",
"storybook-dark-mode": "^4.0.1",
"svgson": "^5.3.1",
"tailwindcss": "^3.4.3",
"tsx": "^4.7.2",
"typescript": "^5.4.5",
"vite": "^5.2.8",
Expand Down
8 changes: 8 additions & 0 deletions packages/icons/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* (c) Copyright Frontify Ltd., all rights reserved. */

module.exports = {
plugins: {
autoprefixer: {},
tailwindcss: {},
},
};
Loading

0 comments on commit 3d6511e

Please sign in to comment.