Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

chore: add storybook #2

Merged
merged 19 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
4 changes: 1 addition & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module.exports = {
extends: [
'@yext/slapshot/typescript'
]
extends: ["plugin:storybook/recommended", "@yext/eslint-config"],
};
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This workflow will run our tests, generate an lcov code coverage file,
# and send that coverage to Coveralls
# and send that coverage to Coveralls

name: Code Coverage

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/percy_snapshots.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

name: Percy Snapshots

on:
on:
push:
branches-ignore: dev/*
pull_request:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/run_linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ on:
pull_request:
branches:
- main
workflow_call:
tatimblin marked this conversation as resolved.
Show resolved Hide resolved
lint_script:
required: false
type: string
default: npm run lint && npm run prettier-write

jobs:
linting:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/sync_sites_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Sync Main to Storybook Site Branch

on:
push:
branches:
- main
jobs:
sync-branches:
tatimblin marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
name: Syncing branches
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: mtanzi/action-automerge@v1
with:
source: "${{ github.event.repository.default_branch }}"
target: "storybook-site"
github_token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/third_party_notices_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ jobs:
call_notices_check:
uses: yext/slapshot-reusable-workflows/.github/workflows/third_party_notices_check.yml@v1
secrets:
REPO_SCOPED_TOKEN: ${{ secrets.BOT_REPO_SCOPED_TOKEN }}
REPO_SCOPED_TOKEN: ${{ secrets.BOT_REPO_SCOPED_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/update_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ jobs:
call_update_docs:
uses: yext/slapshot-reusable-workflows/.github/workflows/update_docs.yml@v1
secrets:
REPO_SCOPED_TOKEN: ${{ secrets.BOT_REPO_SCOPED_TOKEN }}
REPO_SCOPED_TOKEN: ${{ secrets.BOT_REPO_SCOPED_TOKEN }}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy-peer-deps=true
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
22 changes: 22 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
stories: ["../tests/**/*.stories.tsx"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/addon-a11y",
{
name: "@storybook/addon-coverage",
options: {
istanbul: {
include: ["src/components/**"],
},
},
},
],
framework: "@storybook/react",
core: {
builder: "@storybook/builder-vite",
},
staticDirs: ["./public"],
};
1 change: 1 addition & 0 deletions .storybook/manager-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<link rel="icon" href="./yextIcon.svg" />
5 changes: 5 additions & 0 deletions .storybook/manager.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { addons } = require("@storybook/addons");

addons.setConfig({
theme: require("./yextTheme.cjs"),
});
21 changes: 21 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { runOnly } from "./wcagConfig";

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
tatimblin marked this conversation as resolved.
Show resolved Hide resolved
date: /Date$/,
},
},
a11y: {
options: {
runOnly,
},
},
options: {
storySort: {
order: ["Address"],
},
},
};
Binary file added .storybook/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions .storybook/public/yextIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { injectAxe, checkA11y } from "axe-playwright";
import { Page } from "playwright-core";
import { runOnly } from "./wcagConfig";

/**
* See https://storybook.js.org/docs/react/writing-tests/test-runner#test-hook-api-experimental
* to learn more about the test-runner hooks API.
*/
const renderFunctions = {
async preRender(page: Page) {
await injectAxe(page);
},
async postRender(page: Page, context) {
await checkA11y(page, "#root", {
axeOptions: {
runOnly,
rules: {
"color-contrast": { enabled: context.name !== "Loading" },
},
},
detailedReport: true,
detailedReportOptions: {
html: true,
},
});
},
};

export default renderFunctions;
6 changes: 6 additions & 0 deletions .storybook/wcagConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { axeOptionsConfig } from "axe-playwright";

export const runOnly: axeOptionsConfig["axeOptions"]["runOnly"] = {
type: "tag",
values: ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"],
};
32 changes: 32 additions & 0 deletions .storybook/yextTheme.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { create } = require("@storybook/theming");

module.exports = create({
base: "light",
colorPrimary: "#eeeff0",
colorSecondary: "#2563eb",

// UI
appBg: "#fafafa",
appContentBg: "white",
appBorderColor: "#eeeff0",
appBorderRadius: 6,

// Text colors
textColor: "black",
textMutedColor: "#4b5563",

// Toolbar colors
barTextColor: "#4b5563",
barBg: "#eeeff0",

// Form
inputBg: "white",
inputTextColor: "black",
inputBorder: "#9ca3af",
inputBorderRadius: 4,

// Brand logo
brandTitle: "Yext Component Library",
brandUrl: "https://github.com/yext/react-components",
brandImage: "./logo.png",
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
});
6 changes: 2 additions & 4 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"plugins": [
"stylelint-scss"
],
"plugins": ["stylelint-scss"],
"rules": {
"color-no-invalid-hex": true,
"function-calc-no-invalid": true,
Expand All @@ -18,4 +16,4 @@
"scss/at-import-no-partial-leading-underscore": true,
"scss/at-import-partial-extension": "never"
}
}
}
3 changes: 3 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Contains information from the language-subtag-registry JSON Database (https://github.com/mattcg/language-subtag-registry/tree/master/data/json)
which is made available under the ODC Attribution License (https://github.com/mattcg/language-subtag-registry/blob/master/LICENSE.md).

The React Component files listed in this repository are licensed under the below license. All other features and products are subject to separate agreements
and certain functionality requires paid subscriptions to Yext products.

Expand Down
36 changes: 33 additions & 3 deletions THIRD-PARTY-NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,41 @@ THE SOFTWARE.

-----------

The following NPM package may be included in this product:

- [email protected]

This package contains the following license and notice below:

The MIT License (MIT)

Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

-----------

The following NPM packages may be included in this product:

- react-dom@18.2.0
- react@18.2.0
- scheduler@0.23.0
- react-dom@17.0.2
- react@17.0.2
- scheduler@0.20.2

These packages each contain the following license and notice below:

Expand Down
6 changes: 3 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Needed for es6 imports and TS support in jest
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
["@babel/preset-env", { targets: { node: "current" } }],
"@babel/preset-typescript",
],
};
};
Loading