Giter VIP home page Giter VIP logo

storybox's Introduction

๐Ÿ“š Storybox

Storybook-Tailwind distribution for Styleguide projects

If you're just too lazy to read the README ๐Ÿ˜๐Ÿ‘‰ bun x frontend-storybox@latest

Currently provides:

๐ŸŽ‰ New Styleguide

First you need to kick off the generator:

$ mkdir new-styleguide && cd new-styleguide
$ bun x frontend-storybox@latest

If you want a good ESLint/Prettier/Cypress/Jest config, you can use the Antistatique Frontend Development Configuration as so:

โš ๏ธ Make sure everything has been added/commited before doing this

$ bun x antistatique-frontend@latest # Uncheck storybook and check stylelint, obviously
$ git checkout tsconfig.json

๐Ÿ”ง Installation

You need to have the following tools installed globally on your environment:

To install the project:

bun install -y

๐Ÿ Run the Project

Start the following commands in parallel (with nicer output):

$ bun run tailwind:start
$ bun run storybook:start

OR (with uglier output)

$ bun run start

And here are all the available commands:

  • bun run clean: Purge build packages cache
  • bun run tailwind:build: Build Production Tailwind project
  • bun run tailwind:start: Start Tailwind development mode
  • bun run storybook:start: Start Storybook
  • bun run storybook:build: Build Storybook static deliverable
  • bun run modules:start: Build modules and watch for changes
  • bun run modules:build: Build modules
  • bun run start: Start all development processes
  • bun run build: Build all deliverables
  • bun run build:assets: Build all deliverables
  • bun run build:styleguide: Build styleguide for deployment
  • bun run generate: Generate new component (select Blank for ease)
  • bun run icons:build : Build the icons sprite
  • bun run images:build : Build the placeholders images using ImageMagick

๐Ÿ“ฆ Deliver Styleguide

To deliver your styleguide, simply hit the following command:

$ bun run build

In ./public, it will output you a CSS folder that includes a styles.css with your custom CSS and the *purged Tailwind utilities.

It will also take all the modules available in ./src/modules/ and create independent bundles (without React and ReactDOM) that can be used as widgets. Check the ./src/modules/test-module.tsx example.

*โš ๏ธ Always use complete utility name (even in variables), otherwise the purge will skip your โ€œcomposedโ€ classNames.

๐Ÿš€ Deploy Styleguide

You can easily (and freely) deploy your styleguide on Netlify.

Choose the following options:

  • Build command: bun run build:styleguide
  • Publish directory: storybook-static/

storybox's People

Contributors

seb-graf avatar yago avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

storybox's Issues

Module builds fail with upgraded version of `ts-loader`

After successfully migrating to 1.0.2 following the guide instructions, the build command fails with these errors:

ERROR in ./src/modules/slider-vanilla.tsx
Module build failed (from ./node_modules/ts-loader/index.js):
TypeError: loaderContext.getOptions is not a function
    at getLoaderOptions (/Users/nelson/work/theodora-base-theme/styleguide/node_modules/ts-loader/dist/index.js:91:41)
    at Object.loader (/Users/nelson/work/theodora-base-theme/styleguide/node_modules/ts-loader/dist/index.js:14:21)

ERROR in ./src/modules/header-vanilla.tsx
Module build failed (from ./node_modules/ts-loader/index.js):
TypeError: loaderContext.getOptions is not a function
    at getLoaderOptions (/Users/nelson/work/theodora-base-theme/styleguide/node_modules/ts-loader/dist/index.js:91:41)
    at Object.loader (/Users/nelson/work/theodora-base-theme/styleguide/node_modules/ts-loader/dist/index.js:14:21)

Might be related to TypeStrong/ts-loader#595

Icon sprite

  • Refactor the Icon and Icons component to use an external SVG sprite file and svg-sprite module (f.ex "icons:build": "svg-sprite -s --symbol-inline --symbol-dest public --symbol-sprite icons.svg src/assets/icons/*.svg",)
  • Add default documentation page using IconGallery

Alpine.js

Find a way to make possible using Alpine.js JS logic in our React documented components as clean as possible. This way, we will be able to use it more often instead of clanky vanilla js.

Vite build system

Drop Webpack in favor of Vite/Rollup:

  • Use Vite builder for Storybook
  • Refactor src/modules/* build system to use Vite

`styles.css` is not found on storybook build

When building the styleguide, storybook doesn't find the styles.css. Might have been introduced by 1.0.3

Steps to reproduce:

  1. Install a brand new styleguide with npx frontend-storybox@latest
  2. Build the styleguide with yarn build:styleguide
  3. Serve the styleguide with npx http-server storybook-static/
  4. Notice the styles are not active on the styleguide and the http-server outputs this error:
[2021-10-13T08:25:50.192Z]  "GET /styles.css" Error (404): "Not found"

Storybook 7

  • Updates Storybook dependencies
  • Refactoring to use CSF3 (+ MDX)

๐Ÿ’ก If it's easier, start from a blank base to re-setup the Storybook project.

Placeholder images

Add placeholder generation script and documentation. Something like:

 "images:build": "npx zx bin/generate-image.mjs",

and for bin/generate-image.mjs

#!/usr/bin/env zx

/* Require:
 * - ImageMagick (https://imagemagick.org/)
 * - rename (for macOS https://formulae.brew.sh/formula/rename)
 *
 * More on image sizes/formats for the web on https://antistatique.github.io/placeholders/
 */

const widths = [140, 480, 640, 800, 1080, 2000, 3000];
const ratios = ['original'];
const formats = [
  ['jpg', 65],
]

await $`rm -rf ./public/placeholders`;
await $`mkdir -p ./public/placeholders`;
await $`mkdir -p ./public/placeholders/tmp`;

for (const ratio of ratios) {
  await $`mkdir -p ./public/placeholders/tmp/${ratio}`;

  for (const width of widths) {
    const path = `./public/placeholders/tmp/${ratio}/${width}`;
    await $`mkdir -p ${path}`;

    for (const format of formats) {
      const [ext, quality] = format;

      await $`mogrify -format ${ext} -quality ${quality} -resize ${width} -gravity Center -pointsize ${width * 0.05} -fill '#ffffff80' -annotate 0 'โ€‚${width}px - ${ext.toUpperCase()}โ€‚' -path ${path} src/assets/placeholders/*.jpg`;
      await $`rename -s .${ext} '_${width}.${ext}' ${path}/*`;

      await $`mv ${path}/*.${ext} ./public/placeholders/`;
    }
  }

}

await $`rm -rf ./public/placeholders/tmp`;

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.