GithubHelp home page GithubHelp logo

azigler / tsdx-react-storybook-starter Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 3.24 MB

TSDX with an opinionated setup for React and Storybook

Home Page: https://azigler.github.io/tsdx-react-storybook-starter/storybook

License: MIT License

Shell 0.67% JavaScript 31.95% HTML 3.73% TypeScript 51.28% CSS 2.69% Less 2.51% Sass 2.33% SCSS 2.51% Stylus 2.34%
component-library react storybook tsdx typescript

tsdx-react-storybook-starter's Introduction

tsdx-react-storybook-starter

TSDX with an opinionated setup for React and Storybook

License Contributing Guide Code of Conduct Security Policy

Statements Branches Functions Lines

Storybook

Table of Contents

Background

This is an opinionated setup for creating a component library. If you’re looking to build a user-facing React app, you should use a tool like create-react-app, razzle, nextjs, gatsby, or react-static instead. This GitHub template repository is a TSDX project generated with React and Storybook. Configurations have been made to simplify building, testing, and publishing TypeScript component libraries to npm. This project uses the following:

Install

This repository should be used as a GitHub template. Instead of cloning or forking, you should create your own repository via the Use this template button or the GitHub CLI with the following command:

gh repo create YOUR_PROJECT_NAME --clone --template azigler/tsdx-react-storybook-starter

Once you have your repository initialized and cloned locally, install the necessary packages with the following command in the project directory:

yarn install

Usage

Scripts

You can append additional flags to the scripts when you call them. These scripts have only been tested in Yarn.

  • badges: Adds badges to README.md for Jest tests
  • build: Runs tsdx build to build CommonJS, ESModules, Universal, and SystemJS module formats to the /dist directory
  • clean: Cleans up caches, /dist, and /storybook-static here and in /example
  • deploy: Runs the test and build scripts then builds and copies Storybook, /example, and Jest test coverage to the /deploy directory
  • dev: Runs tsdx watch
  • husky: Initializes Husky using a pre-commit hook with yarn husky:prepare
  • husky:prepare: Alias for lint, build, test, size, and storybook:build scripts
  • lint: Runs tsdx lint recursively in the /src directory with the --fix flag
  • size: Runs ai/size-limit using size-limit configurations in package.json
  • start: Alias for dev script
  • storybook: Starts a Storybook server at http://localhost:6006
  • storybook:build: Builds Storybook to the /storybook-static directory
  • test: Runs Jest tests recursively found in the /src directory to save results, coverage, and snapshots and then runs the badges script
  • test:ci: Alias for test script when executed via ci GitHub Action
  • test:watch: Alias for test script that watches for changes

TSDX

The recommended workflow is to use the following command:

yarn dev

This builds your project to the /dist directory and watches to rebuild automatically when any changes are made in the /src directory.

In another terminal, run either Storybook or the Parcel example and start making your changes with hot reloading.

To build your project for publishing, use the following command:

yarn prepare

CommonJS, ESModules, Universal, and SystemJS module formats are built by default. The appropriate paths are configured in package.json and /dist/index.js accordingly.

To learn more about the different scripts available, check out the Scripts section.

Storybook

To start a Storybook development server with hot reloading at http://localhost:6006, use the following command:

yarn storybook

This loads all stories recursively inside the /src directory.

Stories should reference the components as if using the library, similar to the example playground. This means importing from the root project directory, which aliases to the /dist directory.

To build Storybook as a static site to the /storybook-static directory, use the following command:

yarn storybook:build

To preview the Storybook for the main branch of tsdx-react-storybook-starter, click the following badge:

Storybook

Example

To start a Parcel development server at http://localhost:1234 with hot reloading, use the following command in the /example directory:

yarn dev

The example will import whatever is in the /dist directory, so if you are seeing out-of-date components then make sure TSDX is running in another terminal via yarn dev like recommended above.

To build the example to the /example/dist directory for production, use the following command in the /example directory:

yarn build

To preview the example in the main branch of tsdx-react-storybook-starter, click here.

Scripts

Tips

Maintainers

@azigler

Contributing

Feedback and contributions are encouraged! After reading the Code of Conduct, use the Bug Report and Feature Request issue templates to discuss any bugs or contributions to tsdx-react-storybook-starter. For more information, please read the Contributing Guide.

License

MIT © Andrew Zigler

tsdx-react-storybook-starter's People

Contributors

azigler avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.