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

feat: New storybook documentation structure #419

Merged
merged 24 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a4288c9
feat: introducing new storybook structure
tibuurcio Sep 18, 2024
b273b97
chore: new documentation pages
tibuurcio Sep 18, 2024
f1e6590
chore: new documentation pages
tibuurcio Sep 18, 2024
739f05f
chore: moving stories to the components section
tibuurcio Sep 18, 2024
74129b9
chore: latest changes in docs
tibuurcio Sep 18, 2024
ea9da7e
chore: testing new preview workflow
tibuurcio Sep 18, 2024
a31dcbe
chore: update preview workflow to include GITHUB_TOKEN credentials
tibuurcio Sep 18, 2024
c50124b
chore: tries removing permissions from the workflow
tibuurcio Sep 18, 2024
682ccd6
chore: trying the .nojekyll file creation approach
tibuurcio Sep 18, 2024
6fee641
chore: trying a new publishing storybook workflow
tibuurcio Sep 18, 2024
924ba44
chore: trying to remove remark-gfm dependency to see if gh-pages disp…
tibuurcio Sep 18, 2024
7b17923
chore: back to old publishing workflow again
tibuurcio Sep 18, 2024
8191712
chore: trying the preview.tsx approach
tibuurcio Sep 18, 2024
a3e59ea
chore: adds remark-gfm dependency again
tibuurcio Sep 18, 2024
331a5ad
chore: back again at newer version of publishing storybook workflow
tibuurcio Sep 18, 2024
defb539
chore: trying the .nojekyll approach again
tibuurcio Sep 18, 2024
5c3dc75
chore: better names for workflows
tibuurcio Sep 18, 2024
60678a5
chore: addressing reviews
tibuurcio Sep 20, 2024
d3c12c5
chore: puts foundations in front of components in left nav
tibuurcio Sep 20, 2024
71b9118
chore: adds new Date Range Picker candidate component docs
tibuurcio Sep 20, 2024
977140e
chore: added date and removed example code for Date Range Filter
tibuurcio Sep 25, 2024
7028945
Merge branch 'main' into feat/new-storybook-structure
tibuurcio Sep 25, 2024
d212218
chore: adding some ts-expect-errors for component candidate stories
tibuurcio Sep 25, 2024
a6cb11c
Merge branch 'feat/new-storybook-structure' of https://github.com/mPa…
tibuurcio Sep 25, 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
36 changes: 36 additions & 0 deletions .github/workflows/publish-storybook-pr-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy Storybook PR preview

on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed

concurrency: preview-${{ github.ref }}

jobs:
deploy-preview:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
GIT_AUTHOR_NAME: mparticle-automation
GIT_AUTHOR_EMAIL: developers@mparticle.com
GIT_COMMITTER_NAME: mparticle-automation
GIT_COMMITTER_EMAIL: developers@mparticle.com
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install and Build
if: github.event.action != 'closed' # You might want to skip the build if the PR has been closed
run: |
npm install
npm run build-storybook
touch ./storybook-static/.nojekyll
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed otherwise Github Pages fails to pick up some of the bundled JS files generated by Storybook's build process.

https://docs.github.com/en/pages/getting-started-with-github-pages/about-github-pages


- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./storybook-static/
28 changes: 17 additions & 11 deletions .github/workflows/publish-storybook.yml
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks terrible in unified view. Please use split for a better experience reviewing.

Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
name: Publish Storybook

on:
push:
branches:
- 'main' # change to the branch you wish to deploy from

- main
permissions:
contents: read
pages: write
id-token: write

contents: write
jobs:
deploy:
build-and-deploy:
concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
runs-on: ubuntu-latest
steps:
- id: build-publish
uses: bitovi/github-actions-storybook-to-github-pages@v1.0.3
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
run: |
npm ci
npm run build-storybook
touch ./storybook-static/.nojekyll

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
path: storybook-static
folder: storybook-static # The folder the action should deploy.
clean-exclude: pr-preview/
22 changes: 19 additions & 3 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { StorybookConfig } from '@storybook/react-vite'
import react from '@vitejs/plugin-react'
import { PluginOption, Plugin } from 'vite'
import { withoutVitePlugins } from '@storybook/builder-vite'
import remarkGfm from 'remark-gfm'

type StorybookVitePlugins = { plugins: (PluginOption[] | Plugin)[] }

Expand All @@ -11,9 +12,24 @@ const config: StorybookConfig & StorybookVitePlugins = {
options: {},
},

stories: ['../src/**/*.mdx', '../src/**/*.stories.@(ts|tsx)'],

addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions'],
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(ts|tsx)', '../docs/**/*.mdx'],

addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
{
name: '@storybook/addon-docs',
options: {
mdxPluginOptions: {
mdxCompileOptions: {
// needed for rendering markdown tables in .mdx
remarkPlugins: [remarkGfm],
},
},
},
},
],

docs: {
autodocs: true,
Expand Down
16 changes: 0 additions & 16 deletions .storybook/preview.ts

This file was deleted.

40 changes: 40 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { Preview } from '@storybook/react'

const preview: Preview = {
parameters: {
layout: 'centered',
options: {
storySort: {
order: [
'About',
['Introduction', 'Changelog', 'FAQ'],
'Component Process',
[
'Introduction',
'Components',
['Using components', 'Change process'],
'Candidate Components',
['Introducing new ones', 'Using existing ones', 'Promoting to a component'],
'Design Templates',
],
'Foundations',
'Components',
['Colors', 'Typography', 'Icons', 'Errors', 'Loading'],
'Candidate Components',
'Design Templates',
'Contributing',
['Introduction', 'Commits', 'Testing in the platforms', 'Release Process', 'Maintainers'],
],
},
},

controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
}

export default preview
7 changes: 7 additions & 0 deletions docs/About/Changelog.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Markdown } from "@storybook/blocks"

import changelog from '../../CHANGELOG.md?raw'

# CHANGELOG

<Markdown>{changelog}</Markdown>
6 changes: 6 additions & 0 deletions docs/About/FAQ.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# FAQ

### What should I do if I can't implement my design specs using Antd atoms?

Please ask questions about it in the #aquarium channel. Ideally have a branch with your work in progress and some Storybook
stories so that we can see what you're trying to do.
20 changes: 20 additions & 0 deletions docs/About/Introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Introduction

This is where all component related documentation will live at mParticle. This is mainly a work in progress at this point
and we are actively working on it.

## How to read this

TBD

## Glossary

| Term | Meaning |
| -------- | ------- |
| Component Candidate | TBD |
| Template | TBD |
| Eames | TBD |
| Aquarium | TBD |
| Antd | TBD |

---
3 changes: 3 additions & 0 deletions docs/Candidate Components/Directory/Component.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Component

TBD
3 changes: 3 additions & 0 deletions docs/Candidate Components/Introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Introduction

TBD
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Introducing new candidate components

TBD
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Promoting to a component

TBD
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example rendering a mermaid chart

image

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Mermaid } from 'mdx-mermaid/Mermaid';

# Using existings candidate components

<Mermaid chart={`graph TD;
classDef product stroke:#ddd;
classDef design fill:#E4CCFF, stroke:gray;
classDef engineering fill:#0D99FF, stroke:gray, color:white;

A[Project is prioritized for design]:::product --> B

B[Designer reviews the project needs and identifies a needs for customization or componetization]:::design --> C

C[Unify: Trigger source of truth update by creating a ticket to Unify squad for updating Storybook. Start tracking usage in the rule of 3.]:::engineering --> D

D[Design Handoff. Designer communicates to the project team that a new component candidate is introduced in the handoff]:::design --> E

E[Implement it using Aquarium atoms directly in the platforms]:::engineering
`} />
3 changes: 3 additions & 0 deletions docs/Component Process/Components/Change process.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Change process

TBD
3 changes: 3 additions & 0 deletions docs/Component Process/Components/Using components.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Using components

TBD
3 changes: 3 additions & 0 deletions docs/Component Process/Design Templates/Introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Design Templates

TBD
3 changes: 3 additions & 0 deletions docs/Component Process/Introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Introduction

TBD
41 changes: 41 additions & 0 deletions docs/Contributing/Commits.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Commits

## Commit conventions and PR titles

- We use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) to help automating the release process. Both PR titles and commit messages should follow this convention.
- [This repo is commitizen friendly](https://github.com/commitizen/cz-cli?tab=readme-ov-file#using-the-command-line-tool) so we can use `git cz` to commit changes.
`npx cz` is also available if you don't have commitizen installed globally.
- We also have a [commitlint](https://commitlint.js.org/) setup to enforce the commit message format.

The standard format for commit messages is as follows:

```
<type>[optional scope]: <description>

[optional body]

[optional footer]
```

The following lists the different `types` allowed in the commit message:

- feat: A new feature (automatic minor release)
- fix: A bug fix (automatic patch release)
- docs: Documentation only changes
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing or correcting existing tests
- chore: Changes that don't modify src or test files, such as automatic documentation generation, or building latest assets
- ci: Changes to CI configuration files/scripts
- revert: Revert commit
- build: Changes that affect the build system or other dependencies

In the footer, if there is a breaking change, start your footer with `BREAKING CHANGE:` followed by a description.

## Editor configuration

- **Prettier**: For configuring your editor to play nicely with Prettier, take a look at the [Editors doc page](https://prettier.io/docs/en/editors).
- Also, if you're using VSCode you might want to set prettier as the default formatter and also turn on "Format on Save" option.
- **ESLint**: Check [Integrations doc page](https://eslint.org/docs/latest/use/integrations)
- **Stylelint**: Check [Editor integrations doc page](https://stylelint.io/awesome-stylelint/#editor-integrations)
4 changes: 4 additions & 0 deletions docs/Contributing/Introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Introduction

Thanks for the interest in contributing to the Aquarium! Being a component library requires a different approach to development and testing.
This document will guide you through the process of contributing to the Aquarium.
3 changes: 3 additions & 0 deletions docs/Contributing/Maintainers.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Maintainers

TBD
32 changes: 32 additions & 0 deletions docs/Contributing/Release Process.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Release Process

We use [semantic-release](https://github.com/semantic-release/semantic-release) to automate the versioning and publishing
of the mParticle Aquarium component library. Everything is handled by semantic-release, including determining the next version number,
generating the release notes, and publishing to npm. You can use the Github Release Aquarium action from the `main` branch to release from it.

> [!IMPORTANT]
> Before releasing a version from main, send a message in the #aquarium Slack channel to align it and sync on other changes that can/should be included in the release.

## Contributing with the release process

To make changes to the release process, you can use the `--dry-run` from semantic-release flag to test the release
process without actually publishing a new version.

You will need two environment variables to run the release process locally:

- NPM_TOKEN: You can create a personal npm account and use a personal token.
Since we are using `--dry-run` it won't try to publish anything so having a valid read-only npm token works.

- GITHUB_TOKEN: Create a [github personal access token (classic)](https://github.com/settings/tokens)
and give it access to the mParticle organization via "Configure SSO" button.

After settings both variables locally, run the following locally:

```
npx semantic-release --dry-run
```

## Additional readings:

- [Semantic Release Workflow Configuration](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/workflow-configuration.md#workflow-configuration)
- [Understanding npm distribution channels](https://docs.npmjs.com/cli/v8/commands/npm-dist-tag#purpose)
30 changes: 30 additions & 0 deletions docs/Contributing/Testing in the platforms.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Testing in the platforms

## Testing in the CDP

In order to test your changes, you will need to link the local version of the library. To do this, run the following commands:

- Make sure to have the library built by running `npx vite build`. The linked version will use the build files from _dist/_ folder.
- Make sure the `resolve.symlinks` property in you webpack config is set to `false`
- `yarn link` in the root of the library
- `yarn link @mparticle/aquarium` in the root of Nancy
- Make sure your _/node_modules/@mparticle/aquarium_ folder contains all of the Aquarium code

## Testing in Analytics

TODO

## Testing by installing from a branch

Another way to test your changes is by installing the library from a branch. To do this, we need to push the _dist/_ folder to the remote
and install it directly from there with the following command:

```
yarn add https://github.com/mParticle/aquarium#<branch-name>
```

## Testing by releasing an ad-hoc version

To test ad-hoc versions of the Aquarium we use `feat/`, `fix/` or `chore/` branchs on Github and their corresponding distribution channels on npm.
This allows us to release specific versions for testing specific features and install them on the platforms. To release it,
just run the Github Action from the the branch you want to release.
3 changes: 3 additions & 0 deletions docs/Design Templates/Directory.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Directory

TBD
3 changes: 3 additions & 0 deletions docs/Foundations/Colors.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Colors

TBD
Loading
Loading