Giter Site home page Giter Site logo

showrin / nextjs-tailwind-storybook-with-ci-cd Goto Github PK

View Code? Open in Web Editor NEW
65.0 4.0 14.0 568 KB

This repository is built to provide a ready-to-go template for the projects that are using NextJS, Tailwind, Storybook, eslint, jest, prettier in them.

Home Page: https://nextjs-tailwind-storybook-with-ci-cd-eight.vercel.app

License: MIT License

JavaScript 64.43% CSS 2.09% HTML 1.10% MDX 32.39%
cicd nextjs reactjs storybook tailwindcss template eslint jest prettier prettier-eslint react-testing-library

nextjs-tailwind-storybook-with-ci-cd's Introduction

nextjs-tailwind-storybook-with-ci-cd

This repository is built to provide a ready-to-go template for the projects that are using the following tech stacks:

  1. NextJS
  2. Tailwind
  3. Storybook
  4. Jest
  5. React Testing Library
  6. Eslint
  7. Prettier

This template will provide the full setup under the hood and will save a big portion of your time. You have to just create your new repo using this template.

Table of Contents

How to Create Repository Using This Template?

  1. Click on this link to generate a new repo using this template.
  2. Give a name to your repo.
  3. Provide a meaningfull description.
  4. You can keep the Include all branches options unchecked.
  5. Click on Create repository from template button and boom ๐Ÿ’ฅ. Your repository is ready.
  6. Now if you clone the repo in your PC and run yarn, all the dependency will be installed.
  7. Then running yarn dev will start the app at http://localhost:3000.
  8. running yarn storybook will start the storybook of your app at http://localhost:6006.

Package Versions

Following versions were installed when this template was built.

Package Name Version
NodeJS 16.10.0
NextJS 13.3.0
react 18.2.0
react-dom 18.2.0
tailwindcss 3.3.1
postcss 8.4.21
jest 29.5.0
jest-environment-jsdom 29.5.0
@testing-library/jest-dom 5.16.5
@testing-library/react 14.0.0
eslint 8.38.0
eslint-config-next 13.3.0
eslint-config-prettier 8.8.0
prettier 2.8.7
storybook 7.0.5

Available Commands

There are some commands preadded to this template. These commands will help to execute basic tasks.

  1. Following command will start the dev server at port 3000 and we can visit the site at http://localhost:3000.

    yarn dev
    
  2. Following command will create a production build of the site.

    yarn build
    
  3. Following command will start a server at port 3000 with the production build (created using yarn build) and we can visit the site at http://localhost:3000.

    yarn start
    
  4. Following command will check any linting issue according to the eslint rules set in the .eslintrc.json file.

    yarn lint
    
  5. Following command will execute all the unit tests (file with *.test.jsx, *.test.tsx, *.test.js or *.test.ts extention) and check whether all the tests pass or not.

    yarn test
    
  6. Following command will execute unit tests (file with *.test.jsx, *.test.tsx, *.test.js or *.test.ts extention) and check whether all the tests pass or not in the real-time.

    yarn test:watch
    
  7. Following command will start the storybook server at port 6006 and we can visit the story at http://localhost:6006.

    yarn storybook
    
  8. Following command will create a static web application capable of being served by any web server. For more info please visit Publish Storybook.

    yarn build-storybook
    

Folder Structure

Before working on a project, we should know about its folder structure. This helps a lot to understand where to find which components or portion of codes. In this template, the folder structure was tried to be kept as simple as possible.

  1. .github/workflows: This folder is used to keep all the files related to github actions. We've already setup a basic CI/CD in the template and named the file tests.yml. We can create more yml files for different actions.

  2. .storybook: All the storybook related config files like theme, seo, preview, manager etc live inside this folder.

  3. components: In our web app, we'll have to build many reusable components like button, input, modal etc. This is the place where we can keep all our reusable components. While creating a component we have tto ensure the following rules have been followed in order to maintain the consistency.

    1. Each component must have a folder and index.js file inside the folder. For example: if we are creating a button component, the structure should be:

      components
      | - Buttton
          | - Button.jsx
          | - index.js
      

      Then we can access the component from outside using ./componets/Button.

    2. If a component has some sub-components, then we can keep them in a folder named subComponents inside that component.

      components
      | - Buttton
          | - subComponents
              | - ButtonOverlay
                  | - ButtonOverlay.jsx
                  | - index.js
          | - Button.jsx
          | - index.js
      
    3. Each component must have a story file (for storybook). Story file names should be in <Component Name>.stories.jsx this format.

      components
      | - Buttton
          | - subComponents
              | - ButtonOverlay
                  | - ButtonOverlay.jsx
                  | - index.js
          | - Button.jsx
          | - Button.stories.jsx
          | - index.js
      
    4. Each component and sub-components must have a test file (for unit testing). Test file names should be in <Component Name>.test.jsx this format.

      components
      | - Buttton
          | - subComponents
              | - ButtonOverlay
                  | - ButtonOverlay.jsx
                  | - ButtonOverlay.test.jsx
                  | - index.js
          | - Button.jsx
          | - Button.stories.jsx
          | - Button.test.jsx
          | - index.js
      

    That's a general set of rules for the components folder. But of course, you can set your own rules and structure. In that case, you might have to change storybook, jest, and other configs.

  4. pages: This folder keeps all the page and api related files of our app. It's a basic feature provided by NextJS. To learn more about them, you can read the following docs from NextJS.

    1. NextJS Pages
    2. NextJS API Routes
  5. public: This folder is also provided by NextJS. It keeps all the static assets like images, icons, audios, pdfs etc. To learn more about this folder, visit Static File Serving in NextJs.

  6. styles: All the global css or scss files will be kept in this folder. You can keep the local files too with an appropiate folder structure in it.

Change NextJS Config

If you need to change settings of nextjs, then next.config.js and jsconfig.json is the place where you'll have to work. Currently, we've done a bare minimum setup in both files.

But in the jsconfig.json file, we've setup a path alias for the root directory. You can access the root directory using @/ this alias. To learn more about it, read Absolute Imports and Module path aliases in NextJS. Also, you can learn more about next.config.js file from next.config.js Doc.

Change Tailwind Config

If you need to change settings of tailwind, then postcss.config.js and tailwind.config.js is the place where you'll have to work. You can modify or extend the tailwind theme in tailwind.config.js file. For more info, you can read Tailwind Configuration doc.

Change Unit Test Config

Basically, we can modify jest unit testing setup using jest.config.js and jest.setup.js file. To learn more about it, you can go through Jest and React Testing Library in NextJS.

Change Eslint Config

We can use .eslintrc.json file in order to add or remove any eslint rule. For more details, you can read ESLint Configuration Files Doc.

Change Eslint Config

.prettierrc.json file is there to change prettier config of the app. We've added some configs in this file. To remove or add any config, you can go through Prettier Configuration File Doc.

Change Storybook Config

All the config files of storybook are kept in the .storybook folder.

All the project related configs for storybook are in main.js file. If you need to change anything in the storybook preview section, then preview.js file is the appropiate one. Learn more from Configure Storybook Doc.

To modify the theme, we may have to work in appTheme.js and manager.js files. To learn more about theming, visit Storybook Theming Doc.

If we want to do any SEO related changes, then we may have to modify manager-head.html or main.js files. To read more about it, visit Search engine optimization (SEO) Doc.

If we want to access any assets in the public folder, then we don't have to mention public in the src url. You can emit that. For example, we have an image xyz.png in public folder. Then we can access this image from any story using ./xyz.png. Learn more about it from Serving static files via Storybook Configuration Doc.

If we want to write detailed descriptions about our components, props and stories we can use JSDoc comments. To learn more please, visit the following docs from Storybook.

  1. Writing descriptions in Storybook
  2. Writing descriptions of Props in Storybook

CI/CD in This App

A github action has been setup in tests.yml file inside .github folder. This action runs js linting and unit test every time a new commit has been pushed to origin. You can write more github actions here as per your need.

Storybook doesn't Support Some NextJS Features

Currently, storybook doesn't support some features (TurboPack, Server Component, SWC etc) of NextJS v13. But if you are not using these features, then there shouldn't be any problem with storybook. [Source]

License

Being an open source repository, this repo has a MIT License in it. But when you are using this template, you should have to use your own license here ๐Ÿšจ๐Ÿšจ๐Ÿšจ. You can easily generate this. You can read Licensing a repository Doc.

Deployment Guideline

How to Deploy NextJS App on Vercel

  1. Visit Vercel's Dashboard.
  2. Under Import Git Repository section, click Continue with Github button.
  3. Install Vercel in your GitHub account when prompted.
  4. Select your NextJs app repository and click Import.
  5. Add environment variables (if present) from your NextJs app's .env file under Environment Variables tab in Configure Project section.
  6. Click Deploy.
  7. On successful deployment, you will be directed to a new url with a preview image of your deployed NextJs app.
  8. Click on the preview image.
  9. You will be directed to a url that looks like [DOMAIN-NAME].vercel.app.

nextjs-tailwind-storybook-with-ci-cd's People

Contributors

anirudh3167 avatar rafat17 avatar showrin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nextjs-tailwind-storybook-with-ci-cd's Issues

Write Documentation regarding Storybook deployment in vercel

Description

We can deploy our storybook build on various platforms; Vercel is one of them. Our goal is to guide users with proper steps on how to deploy the storybook build on Vercel.

Add Deployment Guideline at the end of the TOC and README (if it's not added already). Under this section add the How to Deploy Storybook Build on Vercel section and write the instructions here.

Things to check before submission

  • The steps provided are clear and concise enough
  • No missing steps
  • The app can be deployed successfully following the given steps
  • The new section has been added to the TOC
  • A note has been added regarding the deletion of additional files if a user is not using the Vercel for deployment (If we've to add any additional files)

Please, copy and paste these checkpoints into the PR and mark each of them after completion.

Write Documentation regarding deployment in netlify

Description

We can deploy our nextjs app on various platforms; Netlify is one of them. Our goal is to guide users with proper steps on how to deploy the nextjs app on Netlify.

Add Deployment Guideline at the end of the TOC and README (if it's not added already). Under this section add How to Deploy on Netlify section and write the instructions here.

Things to check before submission

  • The steps provided are clear and concise enough
  • No missing steps
  • The app can be deployed successfully following the given steps
  • The new section has been added to the TOC
  • A note has been added regarding the deletion of additional files if a user is not using the Netlify for deployment (If we've to add any additional files)

Please, copy and paste these checkpoints into the PR and mark each of them after completion.

Write Documentation regarding deployment in vercel

Description

We can deploy our nextjs app on various platforms; Vercel is one of them. Our goal is to guide users with proper steps on how to deploy the nextjs app on Vercel.

Add Deployment Guideline at the end of the TOC and README (if it's not added already). Under this section add the How to Deploy on Vercel section and write the instructions here.

Things to check before submission

  • The steps provided are clear and concise enough
  • No missing steps
  • The app can be deployed successfully following the given steps
  • The new section has been added to the TOC
  • A note has been added regarding the deletion of additional files if a user is not using the Vercel for deployment (If we've to add any additional files)

Please, copy and paste these checkpoints into the PR and mark each of them after completion.

Write Documentation regarding Storybook deployment in netlify

Description

We can deploy our storybook build on various platforms; Netlify is one of them. Our goal is to guide users with proper steps on how to deploy the storybook build on Netlify.

Add Deployment Guideline at the end of the TOC and README (if it's not added already). Under this section add the How to Deploy Storybook Build on Netlify section and write the instructions here.

Things to check before submission

  • The steps provided are clear and concise enough
  • No missing steps
  • The app can be deployed successfully following the given steps
  • The new section has been added to the TOC
  • A note has been added regarding the deletion of additional files if a user is not using the Netlify for deployment (If we've to add any additional files)

Please, copy and paste these checkpoints into the PR and mark each of them after completion.

Write Documentation regarding Storybook deployment in github-pages

Description

We can deploy our storybook build on various platforms; Github Page is one of them. Our goal is to guide users with proper steps on how to deploy the storybook build on GitHub Page.

Add Deployment Guideline at the end of the TOC and README (if it's not added already). Under this section add the How to Deploy Storybook Build on GitHub Page section and write the instructions here.

Things to check before submission

  • The steps provided are clear and concise enough
  • No missing steps
  • The app can be deployed successfully following the given steps
  • The new section has been added to the TOC
  • A note has been added regarding the deletion of additional files if a user is not using the GitHub Page for deployment (If we've to add any additional files)

Please, copy and paste these checkpoints into the PR and mark each of them after completion.

Write Documentation regarding deployment in github page

Description

We can deploy our nextjs app on various platforms; Github Page is one of them. Our goal is to guide users with proper steps on how to deploy the nextjs app on the GitHub page.

Add Deployment Guideline at the end of the TOC and README (if it's not added already). Under this section add How to Deploy on Github Page section and write the instructions here.

Things to check before submission

  • The steps provided are clear and concise enough
  • No missing steps
  • The app can be deployed successfully following the given steps
  • The new section has been added to the TOC
  • A note has been added regarding the deletion of additional files if a user is not using the Github Page for deployment (If we've to add any additional files)

Please, copy and paste these checkpoints into the PR and mark each of them after completion.

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.