Skip to content
Permalink
Browse files
add storybook
  • Loading branch information
Touchless Inc committed Aug 11, 2022
1 parent a2e1e14 commit bd73e4ebbf9c0e980e30dc2add666512176b1a1e
Show file tree
Hide file tree
Showing 26 changed files with 273 additions and 35 deletions.
@@ -0,0 +1,12 @@
import type { StorybookConfig } from '@storybook/core-common';

export const rootMain: StorybookConfig = {
stories: [],
addons: ['@storybook/addon-essentials'],
// webpackFinal: async (config, { configType }) => {
// // Make whatever fine-grained changes you need that should apply to all storybook configs

// // Return the altered config
// return config;
// },
};
@@ -0,0 +1,14 @@
{
"extends": "../tsconfig.base.json",
"exclude": [
"../**/*.spec.js",
"../**/*.test.js",
"../**/*.spec.ts",
"../**/*.test.ts",
"../**/*.spec.tsx",
"../**/*.test.tsx",
"../**/*.spec.jsx",
"../**/*.test.jsx"
],
"include": ["../**/*"]
}
@@ -0,0 +1,10 @@
{
"extends": ["plugin:cypress/recommended", "../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
}
]
}
@@ -0,0 +1,6 @@
import { defineConfig } from 'cypress';
import { nxE2EStorybookPreset } from '@nrwl/storybook/presets/cypress';

export default defineConfig({
e2e: nxE2EStorybookPreset(__dirname),
});
@@ -0,0 +1,29 @@
{
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/storybook-e2e/shared-ui-e2e/src",
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "apps/storybook-e2e/shared-ui-e2e/cypress.config.ts",
"devServerTarget": "shared-ui:storybook",
"testingType": "e2e"
},
"configurations": {
"ci": {
"devServerTarget": "shared-ui:storybook:ci"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/storybook-e2e/shared-ui-e2e/**/*.{js,ts}"]
}
}
},
"tags": [],
"implicitDependencies": ["shared-ui"]
}
@@ -0,0 +1,4 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]"
}
@@ -0,0 +1,33 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************

// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
login(email: string, password: string): void;
}
}
//
// -- This is a parent command --
Cypress.Commands.add('login', (email, password) => {
console.log('Custom command example: Login', email, password);
});
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands';
@@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../../dist/out-tsc",
"allowJs": true,
"types": ["cypress", "node"]
},
"include": ["src/**/*.ts", "src/**/*.js", "cypress.config.ts"]
}

This file was deleted.

File renamed without changes.
File renamed without changes.
@@ -0,0 +1,27 @@
import { rootMain } from '../../../.storybook/main';
import type { StorybookConfig, Options } from '@storybook/core-common';

const config: StorybookConfig = {
...rootMain,

core: { ...rootMain.core, builder: 'webpack5' },

stories: [
...rootMain.stories,
'../src/lib/**/*.stories.mdx',
'../src/lib/**/*[email protected](js|jsx|ts|tsx)',
],
addons: [...(rootMain.addons || []), '@nrwl/react/plugins/storybook'],
webpackFinal: async (config, { configType }: Options) => {
// apply any global webpack configs that might have been specified in .storybook/main.ts
if (rootMain.webpackFinal) {
config = await rootMain.webpackFinal(config, { configType } as Options);
}

// add your own webpack tweaks if needed

return config;
},
};

module.exports = config;
Empty file.
@@ -0,0 +1,28 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"emitDecoratorMetadata": true,
"outDir": ""
},
"files": [
"../../../node_modules/@nrwl/react/typings/styled-jsx.d.ts",
"../../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
"../../../node_modules/@nrwl/react/typings/image.d.ts"
],

"exclude": [
"../**/*.spec.ts",
"../**/*.spec.js",
"../**/*.spec.tsx",
"../**/*.spec.jsx"
],
"include": [
"../src/**/*.stories.ts",
"../src/**/*.stories.js",
"../src/**/*.stories.jsx",
"../src/**/*.stories.tsx",
"../src/**/*.stories.mdx",
"*.ts",
"*.js"
]
}
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,54 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/shared-ui/src",
"projectType": "library",
"tags": [],
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/shared-ui/**/*.{ts,tsx,js,jsx}"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/libs/shared-ui"],
"options": {
"jestConfig": "libs/shared-ui/jest.config.ts",
"passWithNoTests": true
}
},
"storybook": {
"executor": "@nrwl/storybook:storybook",
"options": {
"uiFramework": "@storybook/react",
"port": 4400,
"config": {
"configFolder": "libs/shared-ui/.storybook"
}
},
"configurations": {
"ci": {
"quiet": true
}
}
},
"build-storybook": {
"executor": "@nrwl/storybook:build",
"outputs": ["{options.outputPath}"],
"options": {
"uiFramework": "@storybook/react",
"outputPath": "dist/storybook/shared-ui",
"config": {
"configFolder": "libs/shared-ui/.storybook"
}
},
"configurations": {
"ci": {
"quiet": true
}
}
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -20,6 +20,9 @@
},
{
"path": "./tsconfig.spec.json"
},
{
"path": "./.storybook/tsconfig.json"
}
]
}
@@ -17,7 +17,11 @@
"**/*.spec.js",
"**/*.test.js",
"**/*.spec.jsx",
"**/*.test.jsx"
"**/*.test.jsx",
"**/*.stories.ts",
"**/*.stories.js",
"**/*.stories.jsx",
"**/*.stories.tsx"
],
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
}
File renamed without changes.
@@ -29,9 +29,11 @@
"windstitch": "^0.2.0"
},
"devDependencies": {
"@babel/core": "7.12.13",
"@babel/plugin-syntax-jsx": "^7.18.6",
"@babel/preset-env": "^7.18.10",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "7.12.13",
"@nrwl/cli": "14.5.4",
"@nrwl/cypress": "14.5.4",
"@nrwl/eslint-plugin-nx": "14.5.4",
@@ -40,8 +42,15 @@
"@nrwl/linter": "14.5.4",
"@nrwl/nx-cloud": "latest",
"@nrwl/react": "^14.5.4",
"@nrwl/storybook": "14.5.4",
"@nrwl/web": "14.5.4",
"@nrwl/workspace": "14.5.4",
"@storybook/addon-essentials": "~6.5.9",
"@storybook/builder-webpack5": "~6.5.9",
"@storybook/core-server": "~6.5.9",
"@storybook/manager-webpack5": "~6.5.9",
"@storybook/react": "~6.5.9",
"@svgr/webpack": "^5.4.0",
"@testing-library/react": "13.3.0",
"@types/jest": "27.4.1",
"@types/node": "16.11.7",
@@ -51,6 +60,7 @@
"@typescript-eslint/parser": "^5.29.0",
"autoprefixer": "10.4.8",
"babel-jest": "28.1.3",
"babel-loader": "8.1.0",
"babel-plugin-module-resolver": "4.1.0",
"babel-preset-gatsby": "2.20.0",
"cypress": "^10.2.0",
@@ -69,6 +79,7 @@
"tailwindcss": "3.1.7",
"ts-jest": "27.1.4",
"ts-node": "~10.8.0",
"typescript": "~4.7.2"
"typescript": "~4.7.2",
"url-loader": "^3.0.0"
}
}

0 comments on commit bd73e4e

Please sign in to comment.