Git Product home page Git Product logo

origin-storybook's Introduction

Origin Protocol Component Library

An Origin Protocol shared component library, using React, Storybook.js, and rollup.js.

The latest Storybook version from the main branch is live here.

Install and use components

These components are meant to be used by originprotocol.com, ousd.com, oeth.com, and story.xyz React frontend apps.

To use in a consuming React app

  1. Install the npm package.
yarn add @originprotocol/origin-storybook

In a React component, import components:

import { Card, Header, Footer } from '@originprotocol/origin-storybook'
...
<Header webProperty='originprotocol' />

<Card
 body="7,777 Lucky Duckies have left the pond and are getting into mischief!"
 img={<value alt="keanu banner" height="200" src="https://placekeanu.com/381/192" width="400"/>}
 linkHref="https://google.com"
 linkText="Visit luckyducky.xyz/market"
 thumbnail={<value alt="keanu face" layout="fill" src="https://placekeanu.com/128/128"/>}
 title="Lucky Ducky NFTs"
 webProperty="originprotocol"
/>

<Footer />
...

Running and developing Storybook locally

To run storybook locally to develop or look at component docs, install and run Storybook:

yarn
yarn storybook

This will stand up a Storybook server at localhost:6006.


Making new components

  1. In src/components, add a folder with your component name and an index.tsx file.
export const YourComponent = () => {
  ...
}
  1. Add a YourComponent.stories.tsx file in your folder.
import { ComponentStory, ComponentMeta } from '@storybook/react';

import { YourComponent } from '.';

// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
export default {
  title: 'Origin/YourComponent',
  component: Footer,
  // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
} as ComponentMeta<typeof Footer>;

// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
const Template: ComponentStory<typeof YourComponent> = (args) => (
  <YourComponent />
)

export const YourComponentStoryTitle = Template.bind({});

Your folder should look like:

.
└── src/
    └── components/
        └── YourComponent/
            ├── index.tsx
            └── YourComponent.stories.tsx
  1. In src/index.ts, import your component:
import './index.css'

export * from './components/Button'
export * from './components/Card'
export * from './components/Dropdown'
export * from './components/Footer'
export * from './components/Header'
export * from './components/Typography'
export * from './components/YourComponent' // add your component here

Development notes

  • We use Tailwindcss v3 for styling
  • We use HeadlessUI for more complex UI interactions like dropdowns.
  • The build step will compile image and CSS styling, so consuming apps don't need to have Tailwind or HeadlessUI installed.

Publishing updates

Building changes

Once the preview of the components with changes look good, you'll want to build the components using Rollup.

yarn build

Publishing changes

After commiting changes:

yarn build
npm version [major|minor|patch] -m "New version message"
npm publish

Make sure to also add the tags to Github as well!

git push origin main --tags

origin-storybook's People

Contributors

nickick avatar rolandpo avatar hrikb avatar micahalcorn avatar toniocodo avatar

Watchers

Daniel Von Fange avatar  avatar Tom Linton avatar Chris avatar Domen Grabec avatar Scott Mitchell avatar James Cloos avatar Franck avatar Josh Fraser avatar Kelly Hwang avatar Rafael Ugolini avatar Matthew Liu avatar Shah avatar  avatar

Forkers

jayjaysecurity

origin-storybook's Issues

Fix Storybook build

The current build is broken when trying to run yarn storybook, getting this error:

ERROR in ./node_modules/tailwind-merge/dist/lib/class-utils.mjs 44:5
Module parse failed: Unexpected token (44:5)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     var validator = _ref.validator;
|     return validator(classRest);
>   })?.classGroupId;
| }
| var arbitraryPropertyRegex = /^\[(.+)\]$/;
 @ ./node_modules/tailwind-merge/dist/lib/config-utils.mjs 1:0-53 9:7-23
 @ ./node_modules/tailwind-merge/dist/lib/create-tailwind-merge.mjs
 @ ./node_modules/tailwind-merge/dist/lib/tw-merge.mjs
 @ ./node_modules/tailwind-merge/dist/tailwind-merge.mjs
 @ ./src/components/Button/index.tsx
 @ ./src/components/Button/Button.stories.tsx
 @ ./src sync ^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(js|jsx|ts|tsx))$
 @ ./generated-stories-entry.js
 @ multi ./node_modules/@storybook/core-client/dist/esm/globals/polyfills.js ./node_modules/@storybook/core-client/dist/esm/globals/globals.js (webpack)-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined ./storybook-init-framework-entry.js ./node_modules/@storybook/react/dist/esm/client/docs/config-generated-config-entry.js ./node_modules/@storybook/react/dist/esm/client/preview/config-generated-config-entry.js ./node_modules/@storybook/addon-links/preview.js-generated-config-entry.js ./node_modules/@storybook/addon-docs/preview.js-generated-config-entry.js ./node_modules/@storybook/addon-actions/preview.js-generated-config-entry.js ./node_modules/@storybook/addon-backgrounds/preview.js-generated-config-entry.js ./node_modules/@storybook/addon-measure/preview.js-generated-config-entry.js ./node_modules/@storybook/addon-outline/preview.js-generated-config-entry.js ./node_modules/@storybook/addon-interactions/preview.js-generated-config-entry.js ./.storybook/preview.js-generated-config-entry.js ./generated-stories-entry.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.