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

docs: drop docz and rewrite docs with storybook #428

Merged
merged 23 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
92c09cc
docs: drop docz and rewrite docs with storybook
tiagoalvesdulce Mar 23, 2022
ce95db0
docs: add themes switch and a few more docs
tiagoalvesdulce Mar 24, 2022
cf0c7c5
docs: add card and checkbox docs
tiagoalvesdulce Mar 24, 2022
f0abbe2
docs: add copyabletext and darklighttoggle docs
tiagoalvesdulce Mar 28, 2022
7a6098e
docs: add datepicker and dropdown docs
tiagoalvesdulce Mar 28, 2022
a8d9c0e
docs: add typography basic docs
tiagoalvesdulce Mar 28, 2022
8779d17
chore: remove docz and add storybook build and deploy
tiagoalvesdulce Mar 28, 2022
8a1cb1f
docs: replace docz ref with storybook
tiagoalvesdulce Mar 28, 2022
27c7421
docs: add Link and Icon stories
tiagoalvesdulce Mar 29, 2022
310f710
docs: add Message and NumberInput stories
tiagoalvesdulce Mar 29, 2022
71a9e82
docs: add Modal stories
tiagoalvesdulce Mar 29, 2022
c29a56c
docs: add paginator and radiobutton stories
tiagoalvesdulce Mar 29, 2022
44af732
docs: add select and slider stories
tiagoalvesdulce Mar 29, 2022
abfc340
docs: add StatusBar and Spinner stories
tiagoalvesdulce Mar 29, 2022
1968867
docs add statustag and table stories
tiagoalvesdulce Mar 29, 2022
a61878a
docs: add tabs stories
tiagoalvesdulce Mar 29, 2022
51059ba
docs: add textinput and textarea stories
tiagoalvesdulce Mar 30, 2022
932d9aa
docs: add toggle and tooltip stories
tiagoalvesdulce Mar 30, 2022
9151677
docs: add theme, layout and introduction. Remove old docs
tiagoalvesdulce Mar 30, 2022
375d628
chore: add .docz to gitignore
tiagoalvesdulce Mar 30, 2022
670fe33
fix: make statustag text prop a node again
tiagoalvesdulce Mar 30, 2022
ffb2dd3
docs: add empty string to PropTypes.node type props stories
tiagoalvesdulce Mar 30, 2022
9f2aa1d
docs: add empty string to prevent error
tiagoalvesdulce Mar 30, 2022
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
5 changes: 2 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ jobs:

- name: Install and Build
run: |
yarn
env DOCZ_BASE=/pi-ui/ yarn docz:build
yarn build-storybook

- name: Deploy
uses: JamesIves/[email protected]
with:
BRANCH: gh-pages
FOLDER: .docz/dist
FOLDER: storybook-static
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
CLEAN: true
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ jobs:
CI: true
- name: build
run: yarn build
- name: docz build
run: yarn docz:build
- name: storybook build
run: yarn build-storybook
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

#storybook
storybook-static

#docz
.docz
.docz
13 changes: 13 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@react-theming/storybook-addon",
],
framework: "@storybook/react",
core: {
builder: "webpack5",
},
};
32 changes: 32 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { addDecorator } from "@storybook/react";
import themeDecorator from "./themeDecorator";
import { withThemes } from "@react-theming/storybook-addon";
import {
DEFAULT_DARK_THEME_NAME,
DEFAULT_LIGHT_THEME_NAME,
defaultDarkTheme,
defaultLightTheme,
} from "../src/theme";
import providerFn from "./providerFn";

const themes = [
{ [DEFAULT_LIGHT_THEME_NAME]: defaultLightTheme },
{ [DEFAULT_DARK_THEME_NAME]: defaultDarkTheme },
];

addDecorator(
withThemes(null, themes, {
providerFn,
})
);

export const parameters = {
backgrounds: { disable: true },
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};
36 changes: 36 additions & 0 deletions .storybook/providerFn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { useEffect, useState } from "react";
import {
useTheme,
ThemeProvider,
DEFAULT_DARK_THEME_NAME,
DEFAULT_LIGHT_THEME_NAME,
defaultDarkTheme,
defaultLightTheme,
} from "../src/theme";

const themes = {
[DEFAULT_DARK_THEME_NAME]: defaultDarkTheme,
[DEFAULT_LIGHT_THEME_NAME]: defaultLightTheme,
};

function ThemeConsumer({ theme, children }) {
const { setThemeName, themeName } = useTheme();
const themeKey = Object.keys(theme)[0];
useEffect(() => {
if (themeName !== themeKey) {
setThemeName(themeKey);
}
}, [themeKey, setThemeName, themeName]);

return children;
}

function providerFn({ theme, children }) {
return (
<ThemeProvider themes={themes} defaultThemeName={DEFAULT_LIGHT_THEME_NAME}>
<ThemeConsumer theme={theme}>{children}</ThemeConsumer>
</ThemeProvider>
);
}

export default providerFn;
21 changes: 21 additions & 0 deletions .storybook/themeDecorator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from "react";
import {
ThemeProvider,
DEFAULT_DARK_THEME_NAME,
DEFAULT_LIGHT_THEME_NAME,
defaultDarkTheme,
defaultLightTheme,
} from "../src/theme";

const themes = {
[DEFAULT_DARK_THEME_NAME]: defaultDarkTheme,
[DEFAULT_LIGHT_THEME_NAME]: defaultLightTheme,
};

const ThemeDecorator = (storyFn) => (
<ThemeProvider themes={themes} defaultThemeName={DEFAULT_LIGHT_THEME_NAME}>
{storyFn()}
</ThemeProvider>
);

export default ThemeDecorator;
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Example extends Component {
- Install all deps by running:
`yarn`
- If you're developing only on pi-ui, serving the live documentation should be enough:
`yarn docz:dev`
`yarn storybook`

- If you want to see your changes reflected in a project consuming pi-ui, you can use yarn link:
- Go to the pi-ui directory on your machine and run:
Expand Down
29 changes: 0 additions & 29 deletions doczrc.js

This file was deleted.

29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
"build": "rollup -c",
"start": "rollup -c -w",
"prepare": "yarn run build",
"docz:dev": "docz dev",
"docz:build": "docz build",
"docz:deploy": "gh-pages -d .docz/dist",
"lint:css": "stylelint 'src/**/*.css'",
"lint:css:fix": "npm run lint:css -- --fix",
"lint:js": "eslint --ext .js,.jsx ./src",
"lint:js:fix": "npm run lint:js -- --fix"
"lint:js:fix": "npm run lint:js -- --fix",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"peerDependencies": {
"prop-types": "^15.5.4",
Expand All @@ -42,17 +41,23 @@
"@babel/preset-env": "^7.16.0",
"@babel/preset-react": "^7.16.0",
"@mdx-js/react": "^1.6.22",
"@react-theming/storybook-addon": "^1.1.5",
"@rollup/plugin-url": "^6.1.0",
"@storybook/addon-actions": "^6.4.19",
"@storybook/addon-essentials": "^6.4.19",
"@storybook/addon-interactions": "^6.4.19",
"@storybook/addon-links": "^6.4.19",
"@storybook/addons": "^6.4.19",
"@storybook/builder-webpack5": "^6.4.19",
"@storybook/manager-webpack5": "^6.4.19",
"@storybook/react": "^6.4.19",
"@storybook/testing-library": "^0.0.9",
"@svgr/rollup": "^5.5.0",
"@testing-library/react": "^12.1.2",
"babel-eslint": "^10.1.0",
"babel-jest": "^27.3.1",
"babel-loader": "^8.2.3",
"cross-env": "^7.0.3",
"docz": "^1.2.0",
"docz-core": "^1.2.0",
"docz-plugin-css": "https://github.com/matheusd/docz-plugin-css",
"docz-theme-default": "^1.2.0",
"eslint": "^7.5.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-react-app": "^6.0.0",
Expand Down Expand Up @@ -81,7 +86,8 @@
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^2.4.1",
"stylelint": "^14.0.1",
"stylelint-config-recommended": "^6.0.0"
"stylelint-config-recommended": "^6.0.0",
"webpack": "^5.70.0"
},
"files": [
"dist"
Expand All @@ -94,10 +100,5 @@
"react-select-event": "^5.3.0",
"react-spring": "^9.3.0",
"react-tapper": "^0.1.23"
},
"resolutions": {
"minimist": "^1.2.5",
"ws": "7.4.6",
"get-pkg-repo": "4.1.1"
}
}
2 changes: 1 addition & 1 deletion src/components/Badge/Badge.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import PropTypes from "prop-types";
import styles from "./styles.css";
import styles from "./styles.module.css";
import { classNames } from "../../utils";

const Badge = ({ children, icon, show, onClose, ...props }) => {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/BoxTextInput/BoxTextInput.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import PropTypes from "prop-types";
import styles from "./styles.css";
import styles from "./styles.module.css";
import { classNames } from "../../utils";
import Icon from "../Icon/Icon.jsx";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Button/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PropTypes from "prop-types";
import React from "react";
import { classNames } from "../../utils";
import Spinner from "../Spinner/Spinner.jsx";
import styles from "./styles.css";
import styles from "./styles.module.css";

const Button = ({
children,
Expand Down
2 changes: 1 addition & 1 deletion src/components/ButtonIcon/ButtonIcon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react";
import Icon from "../Icon/Icon.jsx";
import { classNames } from "../../utils";
import Spinner from "../Spinner/Spinner.jsx";
import styles from "./styles.css";
import styles from "./styles.module.css";
import {
useTheme,
getThemeProperty,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Card/Card.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PropTypes from "prop-types";
import React from "react";
import { classNames } from "../../utils";
import styles from "./styles.css";
import styles from "./styles.module.css";

const Card = ({
children,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/Checkbox/Checkbox.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PropTypes } from "prop-types";
import React from "react";
import { classNames } from "../../utils";
import styles from "./styles.css";
import styles from "./styles.module.css";
import Description from "../Description/Description.jsx";

const Checkbox = ({
Expand Down
2 changes: 1 addition & 1 deletion src/components/CopyableText/CopyableText.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PropTypes from "prop-types";
import React, { useState } from "react";
import { copyToClipboard as copy } from "./helpers";
import { classNames, idPropTypeCheckForTruncatedComponents } from "../../utils";
import styles from "./styles.css";
import styles from "./styles.module.css";
import Tooltip from "../Tooltip/Tooltip.jsx";
import Icon from "../Icon/Icon.jsx";
import TextHighlighted from "../TextHighlighted/TextHighlighted.jsx";
Expand Down
2 changes: 1 addition & 1 deletion src/components/DarkLightToggle/DarkLightToggle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import PropTypes from "prop-types";
import { useSpring, animated } from "react-spring";
import { useTheme, getThemeProperty } from "../../theme";
import styles from "./styles.css";
import styles from "./styles.module.css";

const DarkLightToggle = ({ onToggle, toggled }) => {
const { theme } = useTheme();
Expand Down
2 changes: 1 addition & 1 deletion src/components/Datepicker/Datepicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, {
import PropTypes from "prop-types";
import Tappable from "react-tapper";
import { classNames } from "../../utils";
import styles from "./styles.css";
import styles from "./styles.module.css";
import DatePickerPad from "./DatepickerPad.jsx";
import { useTheme } from "../../theme";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Datepicker/DatepickerPad.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import PropTypes from "prop-types";
import styles from "./styles.css";
import styles from "./styles.module.css";
import { classNames } from "../../utils";
import { mapToArray, convertObjectToUnixTimestamp } from "./helpers";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Description/Description.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PropTypes } from "prop-types";
import React from "react";
import styles from "./styles.css";
import styles from "./styles.module.css";
import { classNames } from "../../utils";

const Description = ({ body, style, className }) =>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dropdown/Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from "prop-types";
import { animated, useTransition } from "react-spring";
import useClickOutside from "../../hooks/useClickOutside";
import { classNames } from "../../utils";
import styles from "./styles.css";
import styles from "./styles.module.css";

const Arrow = ({ open, onClick, className }) => (
<div
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dropdown/DropdownItem.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from "prop-types";
import React from "react";
import styles from "./styles.css";
import styles from "./styles.module.css";
import { classNames } from "../../utils";

const DropdownItem = ({
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/Container.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import PropTypes from "prop-types";
import styles from "./styles.css";
import styles from "./styles.module.css";
import { classNames } from "../../utils";

const Container = ({
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import PropTypes from "prop-types";
import styles from "./styles.css";
import styles from "./styles.module.css";
import { classNames } from "../../utils";

const Header = ({ children, style, className, ...props }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/Main.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import PropTypes from "prop-types";
import styles from "./styles.css";
import styles from "./styles.module.css";
import { classNames } from "../../utils";

const Main = ({ children, style, className, fill, ...props }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/PageDetails.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import PropTypes from "prop-types";
import styles from "./styles.css";
import styles from "./styles.module.css";
import { classNames } from "../../utils";

const PageDetails = ({ children, style, className, ...props }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import PropTypes from "prop-types";
import styles from "./styles.css";
import styles from "./styles.module.css";
import { classNames } from "../../utils";

const Sidebar = ({ children, style, className, ...props }) => {
Expand Down
Loading