Skip to content

Commit

Permalink
add storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
kepta committed Jul 23, 2023
1 parent 816be3d commit d36584e
Show file tree
Hide file tree
Showing 175 changed files with 4,774 additions and 13,031 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# .github/workflows/chromatic.yml

# Workflow name
name: 'Chromatic'

# 👇 Workflow event to trigger execution
on:
push:
branches-ignore:
- 'production'
- 'staging'

jobs:
chromatic-deployment:
# Operating System
runs-on: ubuntu-latest
# Job steps
steps:
- uses: actions/checkout@v1
- name: Install dependencies
# 👇 Install dependencies with the same package manager used in the project (replace it as needed), e.g. yarn, npm, pnpm
run: yarn
# 👇 Adds Chromatic as a step in the workflow
- name: Publish to Chromatic
uses: chromaui/action@v1
# Chromatic GitHub Action options
with:
# 👇 Chromatic projectToken, refer to the manage page to obtain it.
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
workingDir: tooling/storybook
2,426 changes: 2,369 additions & 57 deletions .pnp.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"custom-property-pattern": "^(BV|BC)-[a-z0-9A-Z\\-\\_]+$",
"length-zero-no-unit": [true, { "ignore": ["custom-properties"] }],
"selector-class-pattern": [
"^(B-core-editor|B-core-extension|B-core-theme|B-editor|B-editor-container|B-inline-backlink|B-inline-emoji|B-note-tags|B-search-notes|B-style|B-ui-components|B-ui-dhancha|BU)_[a-z0-9A-Z\\-]+$",
"^(B-activitybar|B-core-editor|B-core-extension|B-core-theme|B-editor|B-editor-container|B-inline-backlink|B-inline-emoji|B-note-tags|B-search-notes|B-style|B-ui-components|B-ui-dhancha|BU)_[a-z0-9A-Z\\-]+$",
{
"message": "Selector should start with the package name followed by an underscore and then the selector name containing only lowercase letters, numbers and hyphens."
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
59 changes: 59 additions & 0 deletions app/activitybar/Button.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import type { StoryObj } from '@storybook/react';
import { Meta } from '@storybook/react';

import { Button } from './Button';

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
const meta = {
title: 'Example/Button',
component: Button,
parameters: {
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
layout: 'centered',
},
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
tags: ['autodocs'],
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
argTypes: {
backgroundColor: { control: 'color' },
},
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>;

// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
export const Primary: Story = {
args: {
primary: true,
label: 'Button',
},
};

export const Secondary: Story = {
args: {
label: 'Button',
},
};

export const Large: Story = {
args: {
size: 'large',
label: 'Button',
},
};

export const Small: Story = {
args: {
size: 'small',
label: 'Button',
},
};

export const Warning: Story = {
args: {
primary: true,
label: 'Delete now',
backgroundColor: 'red',
},
};
50 changes: 50 additions & 0 deletions app/activitybar/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';

interface ButtonProps {
/**
* Is this the principal call to action on the page?
*/
primary?: boolean;
/**
* What background color to use
*/
backgroundColor?: string;
/**
* How large should the button be?
*/
size?: 'small' | 'medium' | 'large';
/**
* Button contents
*/
label: string;
/**
* Optional click handler
*/
onClick?: () => void;
}

/**
* Primary UI component for user interaction
*/
export const Button = ({
primary = false,
size = 'medium',
backgroundColor,
label,
...props
}: ButtonProps) => {
const mode = primary
? 'storybook-button--primary'
: 'storybook-button--secondary';

return (
<button
type="button"
className="mr-24 bg-colorSecondarySolid"
style={{ backgroundColor }}
{...props}
>
{label}
</button>
);
};
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
/>
<%- sentry %>
<!-- -->

<link rel="stylesheet" href="/core-theme.css" />
<title>Bangle App</title>
</head>
Expand Down
100 changes: 0 additions & 100 deletions tooling/storybook/.storybook/main.js

This file was deleted.

60 changes: 60 additions & 0 deletions tooling/storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import path from 'path';
import Unocss from '@unocss/vite';
import { mergeConfig } from 'vite';
import getEnvVars from '@bangle.io/env-vars';

import type { StorybookConfig } from '@storybook/react-vite';
import { ALL_TOP_LEVEL_DIRS } from '@bangle.io/yarn-workspace-helpers';

const config: StorybookConfig = {
stories: [
...ALL_TOP_LEVEL_DIRS.map(
(dir) => `../../../${dir}/**/*.stories.@(js|jsx|ts|tsx)`,
),
],
addons: [
path.dirname(
require.resolve(path.join('@storybook/addon-links', 'package.json')),
),
path.dirname(
require.resolve(path.join('@storybook/addon-essentials', 'package.json')),
),
path.dirname(
require.resolve(path.join('@storybook/addon-onboarding', 'package.json')),
),
path.dirname(
require.resolve(
path.join('@storybook/addon-interactions', 'package.json'),
),
),
],
framework: {
name: path.dirname(
require.resolve(path.join('@storybook/react-vite', 'package.json')),
),
options: {},
},
docs: {
autodocs: 'tag',
},
core: {
builder: '@storybook/builder-vite',
},

async viteFinal(config, { configType }) {
const isProduction = configType === 'PRODUCTION';

const envVars = await getEnvVars({
isProduction: isProduction,
isVite: true,
isStorybook: true,
});
return mergeConfig(config, {
plugins: [Unocss()],
define: {
...envVars.appEnvs,
},
});
},
};
export default config;
3 changes: 0 additions & 3 deletions tooling/storybook/.storybook/preview-body.html

This file was deleted.

69 changes: 0 additions & 69 deletions tooling/storybook/.storybook/preview.js

This file was deleted.

Loading

0 comments on commit d36584e

Please sign in to comment.