Giter Club home page Giter Club logo

generator-leetcode-storybook's Introduction

main_logo

Generator Leetcode Storybook

npm Main workflow codecov

A Yeoman Generator that scaffolds LeetCode problems templates into your Storybook.

Example Storybook

https://psychobolt.github.io/leetcode-storybook

Requirements

Yeoman and a React storybook (6.4+) project with Webpack 5 builder preconfigued

Alternatively, you may fork psychobolt/leetcode-storybook-starter which includes the necessary requirements and configurations.

Install

npm install -g generator-leetcode-storybook vsc-leetcode-cli

Configuration

  1. Login using Leetcode CLI
leetcode user [-g]  # Log in with github account. See official docs for user login options.

Note: Leetcode CLI only supports github or linkedin logins for US accounts.

  1. Include story paths for problem and solution for Storybook. For example,
// .storybook/main.js
module.exports = {
  /* ... */
  stories: [
    '../**/*.(problem|solution).mdx',
    /* ... */
  ],
  /* ... */
};
  1. Include asset/source rule for Markdown (.md) files using a custom webpack config. For example,
// .storybook/main.js
module.exports = {
  /* ... */
  webpackFinal: config => ({
    ...config,
    module: {
      ...config.module,
      rules: [
        ...config.module.rules.map(rule => {
          if (test.test('.md')) {
            return { ...rule, resourceQuery: { not: [/raw/] } };
          }
          return rule;
        }),
        {
          resourceQuery: /raw/,
          type: 'asset/source',
        },
      ],
    },
    /* ... */
  }),
  /* ... */
};
  1. (Optional) Configure Storybook Badges. For example,
// .storybook/preview.js
import badgesConfig from './leetcode-badges.js';

export const parameters = {
  /* ... */
  badgesConfig, // include badgesConfig
};

Include the badges addon,

// .storybook/main.js
module.exports = {
  /* ... */
  addons: [
    '@geometricpanda/storybook-addon-badges',
    /* ... */
  ],
  /* ... */
};

Usage

Run the Generator with Yeoman in your Storybook project and answer the generator's prompts

yo leetcode-storybook

It is recommended to run the generator at the project root in order to detect your .storybook/ configurations.

Development Guide

Please see DEVELOPMENT.md

generator-leetcode-storybook's People

Contributors

psychobolt avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

generator-leetcode-storybook's Issues

[Problem Generator] Change default parent directory name

By default, the generator will auto-create a parent directory for the problem (using the problem's file name). However, this name may not be unique if it already exists.

Always prompt the user to specify the problem's parent directory name. This prompt should be optional if the generator detects the default parent directory name is already unique and is skippable.

[Problem Generator] Support scaffolding alternative languages for problem code

We should support scaffolding problem file for other languages (besides javascript), even though the lack of tool support for those languages in Storybook. Note: Scaffolding code for other languages is supported in leetcode-cli.

  • Prompt input for languages
  • Allow users to input languages in a comma separated string
  • Default value is javascript and generator should always scaffold a javascript file, regardless of user input
  • Also allow passing languages as a option

Remaining tasks:

  • Document tool limitations

[Problem Generator] Do not merge languages option with saved config

If user enters languages: e.g. javascript and the config already has ['javascript', 'python'], the config should replace the languages config. Instead, the config still preserves the non specified languages e.g. python . We should save last user's input for subsequent reruns.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm @babel/plugin-proposal-class-properties Unavailable
npm @babel/plugin-proposal-nullish-coalescing-operator Unavailable
npm @babel/plugin-proposal-object-rest-spread Unavailable
npm @babel/plugin-proposal-optional-chaining Unavailable
npm @babel/plugin-proposal-private-methods Unavailable
npm @babel/plugin-proposal-private-property-in-object Unavailable
npm @storybook/testing-library Unavailable

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency babel-plugin-polyfill-corejs3 to v0.10.6
  • Update dependency rimraf to v5.0.10
  • Update dependency babel-loader to v9.2.1
  • Update dependency eslint-plugin-import to v2.30.0
  • Update dependency espree to v10.1.0
  • Update dependency markdown-to-jsx to v7.5.0
  • Update dependency webpack to v5.94.0
  • Update react monorepo to v18.3.1 (react, react-dom)
  • Update yarn monorepo (@yarnpkg/sdks, yarn)
  • Update chromaui/action action to v11
  • Update dependency c8 to v10
  • Update dependency eslint to v9
  • Update dependency eslint-plugin-jest to v28
  • Update dependency execa to v9
  • Update dependency flow-typed to v4
  • Update dependency glob to v11
  • Update dependency rimraf to v6
  • Update dependency symlink-dir to v6
  • Update dependency yeoman-test to v9
  • Update github/codeql-action action to v3
  • Update yarn monorepo to v4 (major) (@yarnpkg/core, yarn)
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/codeql-analysis.yml
  • actions/checkout v4
  • github/codeql-action v2
  • github/codeql-action v2
  • github/codeql-action v2
.github/workflows/test.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/setup-node v4
  • actions/upload-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • codecov/codecov-action v4
  • actions/checkout v4
  • chromaui/action v10
npm
.yarn/sdks/eslint/package.json
.yarn/sdks/flow-bin/package.json
package.json
  • espree 10.0.1
  • execa 8.0.1
  • glob 9.3.5
  • isbinaryfile 5.0.2
  • json5 2.2.3
  • require-from-string 2.0.2
  • slash 5.1.0
  • yeoman-generator 5.10.0
  • @babel/core 7.24.5
  • @babel/eslint-parser 7.24.5
  • @babel/plugin-proposal-class-properties 7.18.6
  • @babel/plugin-proposal-decorators 7.24.1
  • @babel/plugin-proposal-export-default-from 7.24.1
  • @babel/plugin-proposal-nullish-coalescing-operator 7.18.6
  • @babel/plugin-proposal-object-rest-spread 7.20.7
  • @babel/plugin-proposal-optional-chaining 7.21.0
  • @babel/plugin-proposal-private-methods 7.18.6
  • @babel/plugin-proposal-private-property-in-object 7.21.11
  • @babel/plugin-syntax-dynamic-import 7.8.3
  • @babel/plugin-syntax-flow 7.24.1
  • @babel/plugin-transform-arrow-functions 7.24.1
  • @babel/plugin-transform-block-scoping 7.24.5
  • @babel/plugin-transform-classes 7.24.5
  • @babel/plugin-transform-destructuring 7.24.5
  • @babel/plugin-transform-for-of 7.24.1
  • @babel/plugin-transform-parameters 7.24.5
  • @babel/plugin-transform-react-jsx 7.23.4
  • @babel/plugin-transform-shorthand-properties 7.24.1
  • @babel/plugin-transform-spread 7.24.1
  • @babel/preset-env 7.24.5
  • @geometricpanda/storybook-addon-badges 1.1.1
  • @mdx-js/react 1.6.22
  • @storybook/addon-actions 6.5.16
  • @storybook/addon-docs 6.5.16
  • @storybook/addon-essentials 6.5.16
  • @storybook/addon-interactions 6.5.16
  • @storybook/addon-links 6.5.16
  • @storybook/addons 6.5.16
  • @storybook/api 6.5.16
  • @storybook/builder-webpack5 6.5.16
  • @storybook/components 6.5.16
  • @storybook/manager-webpack5 6.5.16
  • @storybook/react 6.5.16
  • @storybook/testing-library 0.2.2
  • @storybook/theming 6.5.16
  • @yarnpkg/core 3.7.0
  • @yarnpkg/sdks 3.1.2
  • app-root-path 3.1.0
  • babel-loader 9.1.3
  • babel-plugin-macros 3.1.0
  • babel-plugin-named-exports-order 0.0.2
  • babel-plugin-polyfill-corejs3 0.10.4
  • c8 9.1.0
  • core-js 3.37.0
  • eslint 8.13.0
  • eslint-config-airbnb-base 15.0.0
  • eslint-plugin-flowtype 8.0.3
  • eslint-plugin-import 2.29.1
  • eslint-plugin-jest 27.9.0
  • execa 8.0.1
  • flow-bin 0.175.1
  • flow-typed 3.9.0
  • isbinaryfile 5.0.2
  • jest 29.7.0
  • jest-cli 29.7.0
  • jest-light-runner 0.6.0
  • jest-specific-snapshot 8.0.0
  • lodash 4.17.21
  • markdown-to-jsx 7.4.7
  • react 18.2.0
  • react-dom 18.2.0
  • react-syntax-highlighter 15.5.0
  • rimraf 5.0.5
  • symlink-dir 5.2.1
  • vsc-leetcode-cli 2.8.1
  • webpack 5.90.2
  • yeoman-environment 3.19.3
  • yeoman-test 6.3.0
  • yo 4.3.1
  • vsc-leetcode-cli *
  • yarn 3.8.2
shared/flow-deps/package.json
  • yarn 3.8.2

  • Check this box to trigger a request for Renovate to run again on this repository

[Problem Generator] Display problem information

It would be nice to display information about a problem before a story is generated from it. For example, output after entering a problem id to console:

? Enter the problem ID 1
Easy (48.52%) | Likes: 31535 | Dislikes: 1002
Tags: array | hash-table 
Companies: adobe | airbnb | amazon | apple | bloomberg | dropbox | facebook | linkedin | microsoft | uber | yahoo | yelp
? Enter a path you want to create this problem in, e.g. (DataStructure/Array) 

Language prompt should come last in this case.

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.