Giter Club home page Giter Club logo

banana-template's Introduction

Banana ๐ŸŒ

React + TS + Vite.js + Primereact + tailwind template.

What does it include?

this template uses the following technologies:

It also includes some additional utilities and libraries such as:

What are the features?

It contains some custom utility code such as:

Primereact theming with Tailwind

Primereact in unstyled mode can be styled with Tailwind via the Pass Through API at will. You can edit/create themes in the themes folder and import them in providers/UIProvider.tsx. If you want to create your own separated theme, copy and paste the themes/main.ts file, rename it and the object inside then import it in providers/UIProvider as such:

// @/themes/awesome.ts
import { PrimeReactPTOptions } from "primereact/api";

const awesomeTheme: PrimeReactPTOptions = {
    // Put any override style here...
};

export default awesomeTheme;

// @/themes/index.ts
import mainTheme from "./main";
import awesomeTheme from "./awesome";

export default { 
    main: mainTheme,
    awesome: awesomeTheme, // We add our import here
};

// @/providers/UIProvider.tsx
export const UIProvider = (props: UIProviderProps) => {
    
    // ...

    const AppTheme = usePassThrough(
        Tailwind,
        themes.awesome, // We use our new theme here
        {
            mergeProps: true,
            mergeSections: true,
            classNameMergeFunction: twMerge,
        },
    );

    return (
        <PrimeReactProvider 
            value={{ 
                unstyled: true, 
                pt: AppTheme,
            }}
        >
            <Toast ref={_toast}/>
            <ConfirmDialog />
            <UIContext.Provider value={initialValue}>
                {props.children}
            </UIContext.Provider>
        </PrimeReactProvider>
    )
}

More info about Primereact theming with Tailwind here.

Pre-configured React Query client

A React query client has been pre-configured so that you can code right away. However, you can always change the values to suit you.

By default, the following values are set:

Setting Value
refetchOnWindowFocus No
retry 2
staleTime 10 min.
gcTime 15 min.

By passing a meta object in your queries hooks with an error or success message, you can display a Primereact toast automaticaly.

const useMyQuery = () => {
    return useQuery({
        queryKey: ["my-awesome-query"],
        queryFn: fetchMyAwesomeData,
        meta: {
            success: {
                detail: "Your awesome data has been fetched with success!",
            },
            error: {
                detail: "It seems that your awesome data has been lost...",
            }
        }
    })
}

Global Primereact toasts handling

As mentioned above, it is possible to handle toasts via queries settlement. But you can also display some from anywhere in your code with the toast util as such:

import { toast } from "@/utils/toast";

toast.show({ detail: "Is that a toast???" });

It follows the same API as the Primereact toasts with extra functions.

Alias @ folder

In order to avoid writing boring and not very readable ../../../ when importing your local modules, @/ can be used as an alias to the src/ folder.

// Switch from this
import { myAwesomeFunction } from "../../../../utils/awesome";

// ...to that!
import { myAwesomeFunction } from "@/utils/awesome";

Dynamic SVGs components

With this template, you no longer need to create manually components for your favorites SVGs icons or images. Just import them in your code as such:

import MyAwesomeSVGIcon from "@/path/to/svg/awesomeIcon.svg?react";

const SomeComponent = () => {
    return <>
        <MyAwesomeSvgIcon />
    </>;
}

For more information about svgr configuration, see their docs.

How to use it?

By Github template

Use it as a Github template.

By Cloning it

Clone this repository with degit:

degit teaflex/banana-template my-project

Go to your project folder and install the dependencies with your favorite package manager:

cd my-project
pnpm i

Then you should be good to go!

Why "Banana"?

Idk it sounds funny.

banana-template's People

Contributors

teaflex avatar nicoolandgood avatar

Watchers

 avatar

banana-template's Issues

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.