Skip to content

Commit edaced5

Browse files
committed
initial commit
0 parents  commit edaced5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+9805
-0
lines changed

.github/workflows/release.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release
2+
3+
on: [push]
4+
5+
jobs:
6+
release:
7+
runs-on: ubuntu-latest
8+
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- name: Prepare repository
13+
run: git fetch --unshallow --tags
14+
15+
- name: Use Node.js 16.x
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: 16.x
19+
20+
- name: Install dependencies
21+
run: yarn install --ignore-scripts
22+
23+
- name: Create Release
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
27+
run: |
28+
yarn release

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dist/
2+
node_modules/
3+
storybook-static/
4+
build-storybook.log
5+
.DS_Store
6+
.env

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.storybook/local-preset.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* to load the built addon in this test Storybook
3+
*/
4+
function previewAnnotations(entry = []) {
5+
return [...entry, require.resolve("../dist/preview.mjs")];
6+
}
7+
8+
function managerEntries(entry = []) {
9+
return [...entry, require.resolve("../dist/manager.mjs")];
10+
}
11+
12+
module.exports = {
13+
managerEntries,
14+
previewAnnotations,
15+
};

.storybook/main.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { StorybookConfig } from "@storybook/react-vite";
2+
const config: StorybookConfig = {
3+
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
4+
addons: [
5+
"@storybook/addon-links",
6+
"@storybook/addon-essentials",
7+
"@storybook/addon-interactions",
8+
"./local-preset.js",
9+
],
10+
framework: {
11+
name: "@storybook/react-vite",
12+
options: {},
13+
},
14+
docs: {
15+
autodocs: "tag",
16+
},
17+
};
18+
export default config;

.storybook/preview-head.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<script>
2+
window.global = window;
3+
</script>

.storybook/preview.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { Preview } from "@storybook/react";
2+
3+
const preview: Preview = {
4+
parameters: {
5+
backgrounds: {
6+
default: "light",
7+
},
8+
actions: { argTypesRegex: "^on[A-Z].*" },
9+
controls: {
10+
matchers: {
11+
color: /(background|color)$/i,
12+
date: /Date$/,
13+
},
14+
},
15+
},
16+
};
17+
18+
export default preview;

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Storybook contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Storybook Addon StackBlitz
2+
Create a one-click Pull Request environment right from your component
3+
4+
### Development scripts
5+
6+
- `yarn start` runs babel in watch mode and starts Storybook
7+
- `yarn build` build and package your addon code
8+
9+
### Switch from TypeScript to JavaScript
10+
11+
Don't want to use TypeScript? We offer a handy eject command: `yarn eject-ts`
12+
13+
This will convert all code to JS. It is a destructive process, so we recommended running this before you start writing any code.
14+
15+
## What's included?
16+
17+
![Demo](https://user-images.githubusercontent.com/42671/107857205-e7044380-6dfa-11eb-8718-ad02e3ba1a3f.gif)
18+
19+
The addon code lives in `src`. It demonstrates all core addon related concepts. The three [UI paradigms](https://storybook.js.org/docs/react/addons/addon-types#ui-based-addons)
20+
21+
- `src/Tool.tsx`
22+
- `src/Panel.tsx`
23+
- `src/Tab.tsx`
24+
25+
Which, along with the addon itself, are registered in `src/manager.ts`.
26+
27+
Managing State and interacting with a story:
28+
29+
- `src/withGlobals.ts` & `src/Tool.tsx` demonstrates how to use `useGlobals` to manage global state and modify the contents of a Story.
30+
- `src/withRoundTrip.ts` & `src/Panel.tsx` demonstrates two-way communication using channels.
31+
- `src/Tab.tsx` demonstrates how to use `useParameter` to access the current story's parameters.
32+
33+
Your addon might use one or more of these patterns. Feel free to delete unused code. Update `src/manager.ts` and `src/preview.ts` accordingly.
34+
35+
Lastly, configure you addon name in `src/constants.ts`.
36+
37+
### Metadata
38+
39+
Storybook addons are listed in the [catalog](https://storybook.js.org/addons) and distributed via npm. The catalog is populated by querying npm's registry for Storybook-specific metadata in `package.json`. This project has been configured with sample data. Learn more about available options in the [Addon metadata docs](https://storybook.js.org/docs/react/addons/addon-catalog#addon-metadata).
40+
41+
## Release Management
42+
43+
### Setup
44+
45+
This project is configured to use [auto](https://github.com/intuit/auto) for release management. It generates a changelog and pushes it to both GitHub and npm. Therefore, you need to configure access to both:
46+
47+
- [`NPM_TOKEN`](https://docs.npmjs.com/creating-and-viewing-access-tokens#creating-access-tokens) Create a token with both _Read and Publish_ permissions.
48+
- [`GH_TOKEN`](https://github.com/settings/tokens) Create a token with the `repo` scope.
49+
50+
Then open your `package.json` and edit the following fields:
51+
52+
- `name`
53+
- `author`
54+
- `repository`
55+
56+
#### Local
57+
58+
To use `auto` locally create a `.env` file at the root of your project and add your tokens to it:
59+
60+
```bash
61+
GH_TOKEN=<value you just got from GitHub>
62+
NPM_TOKEN=<value you just got from npm>
63+
```
64+
65+
Lastly, **create labels on GitHub**. You’ll use these labels in the future when making changes to the package.
66+
67+
```bash
68+
npx auto create-labels
69+
```
70+
71+
If you check on GitHub, you’ll now see a set of labels that `auto` would like you to use. Use these to tag future pull requests.
72+
73+
#### GitHub Actions
74+
75+
This template comes with GitHub actions already set up to publish your addon anytime someone pushes to your repository.
76+
77+
Go to `Settings > Secrets`, click `New repository secret`, and add your `NPM_TOKEN`.
78+
79+
### Creating a release
80+
81+
To create a release locally you can run the following command, otherwise the GitHub action will make the release for you.
82+
83+
```sh
84+
yarn release
85+
```
86+
87+
That will:
88+
89+
- Build and package the addon code
90+
- Bump the version
91+
- Push a release to GitHub and npm
92+
- Push a changelog to GitHub

0 commit comments

Comments
 (0)