Git Product home page Git Product logo

oboe-site's Introduction

nextjs12-chakra-ui starter kit

Table of Contents

Overview

This Next.js 12 starter kit comes with formatting, linting, example components, testing and styling. Here is the complete list of technologies and tooling used in this kit:

Installation

CLI (Recommended)

npm create @this-dot/starter -- --kit next12-chakra-ui

or

yarn create @this-dot/starter --kit next12-chakra-ui
  • Follow the prompts to select the next12-chakra-ui starter kit and name your new project.
  • cd into your project directory and run yarn install.
  • Run yarn run dev to start the development server.
  • Open your browser to http://localhost:3000 to see the included example code running.

Manual

This requires a download of the entire starter.dev repository and extraction of the next12-chakra-ui kit from the starters directory.

git clone https://github.com/thisdot/starter.dev.git
  • Copy and rename the starters/next12-chakra-ui directory to the name of your new project.
  • cd into your project directory and run yarn install.
  • Run yarn run dev to start the development server.
  • Open your browser to http://localhost:3000 to see the included example code running.

Commands

  • yarn run dev - Starts the development server.
  • yarn run test - Runs the unit tests.
  • yarn run storybook - Starts the Storybook UI.
  • yarn run lint - Runs ESLint on the project.
  • yarn run format:fix - Formats code for the entire project

State management

For this starter kit we are not using a global state manager but instead storing state inside the routes for Next.js. For example, please look at the /src/pages/counter-example.tsx and src/pages/fetch-example.tsx files.

Testing

Unit testing

The unit tests for the home page can be found in the __tests__ directory.

.
├── Counter.test.tsx
├── Greeting.test.tsx
└── index.test.tsx

Storybook's Accessibility testing

This starter kit comes with the @storybook/addon-a11y which is used to check for common accessibility errors in your components. When you run yarn run storybook, each story will show detailed explanations with suggested fixes if errors are found.

Chakra UI's Customizable theme

Inside the src/pages/_app.tsx directory, you will find the basic setup for customizing your theme, colors, and font styles using Chakra UI.

const colors = {
  brand: {
    50: "#1a365d",
    100: "#153e75",
    500: "#2464ec",
  },
};

const fontWeights = {
  normal: 400,
  medium: 600,
  bold: 800,
};

const breakpoints = {
  sm: "320px",
  md: "768px",
  lg: "960px",
  xl: "1200px",
};

export const theme = extendTheme({ colors, fontWeights, breakpoints });

Example Components

API routes example

Inside the src/pages/api directory, you will find a hello.ts file which includes an example on how to create your own API's with Next.js 12.

import type { NextApiRequest, NextApiResponse } from "next";

type Data = {
  name: string,
};

export default function handler(
  req: NextApiRequest,
  res: NextApiResponse<Data>
) {
  res.status(200).json({ name: "This Dot Labs" });
}

Counter Example

Inside the src/components/Counter directory, you will find the Counter.tsx and Counter.stories.tsx files. In this example, you will see how to work with Chakra UI components in Next.js 12. You will also see examples on how to write stories for your components using Storybook.

Fetch example

Inside the src/pages directory, you will find the fetch-example.tsx which demonstrates how to fetch data using Next.js 12. Inside the src/components/Greeting directory, the Greeting.stories.tsx provides examples on how to write stories for your components using Storybook.

Kit Organization / Architecture

At the root level, you will find all of the testing, linting, Prettier formatting, Storybook and TypeScript configurations along with the src and public directories.

Inside the src directory, you will find the following structure:

.
├── components
│   ├── Counter
│   │   ├── Counter.stories.tsx
│   │   ├── Counter.tsx
│   │   └── index.ts
│   ├── Greeting
│   │   ├── Greeting.stories.tsx
│   │   ├── Greeting.tsx
│   │   └── index.ts
│   └── index.ts
└── pages
    ├── api
    │   └── hello.ts
    ├── _app.tsx
    ├── counter-example.tsx
    ├── fetch-example.tsx
    └── index.tsx

How to deploy your project

You can use services like Netlify or Vercel to deploy your application. Both of these services will come with a built-in CI/CD pipeline and live previews.

oboe-site's People

Contributors

jdwilkin4 avatar

Watchers

 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.