0.0.74 • Published 2 years ago

react-dev-starter-pack v0.0.74

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

react-starter-kit

This package is a union of different helpers. Functions, hooks, components-builders and so on. To use it you should add specific packages to your project:

  • redux, redux-toolkit, redux-saga
  • react-hook-form, yup

Navigation

Builders

Components-builders

Builders

router

Usage

Argument of function is an object, which specifies route object. Output is an object too, but with some features. You will receive root: '/' field, and root for every object inside, and the value will be name of field. Every child string field will have prefix which is combpination of parent's(obj) fields names.

You can override root. You can disable adding prefixes by adding ! to start of string.

import { builders } from "react-dev-starter-pack";

export const routes = builders.router({
  sandbox: "/sandbox",
  auth: {
    login: "/login",
    password: "/password",
  },
  cabinet: {
    root: '/lk',
    transactions: '/transactions',
    profile: '!/custom-route/profile'  
  },
});

Output

{
    root: '/',
    auth: {
       root: '/auth',
       login: "/auth/login",
       password: "/auth/password",
    },
    sandbox: "/sandbox",
    cabinet: {
       root: '/lk',
       transactions: '/lk/transactions',
       profile: '/custom-route/profile'  
    },
}

Yup

Under the hood yupBuilder has built version of yup, but you shoud to install @types/yup as devDeps.

Usage
export const YUP = builders.yup({
  text: {
    max: () => "Max",
    min: () => "Min",
    req: "Req",
    email: "Email",
  },
  customSchemas: {},
});

Output - Object

PropertyDefinition
instanceequals to import * as yup from 'yup'
schemascollection of common schemas + your custom
resolver@hookform resolver
createequals to yup.object().shape
createequals to yup.object().shape
texttext snippets

localStorage

This builder is kind of Proxy between developer and localStorage. It has only one parameter - generic type of your localStorage model. It will automatically do JSON.stringify/parse. Also it has full typescript support.

Usage
import {builders} from "react-dev-starter-pack";

export const lcController = builders.localStorage<{
    id: string,
    user: {
        name: string,
        age: number
    }
}>()
PropertyDefinition
gettyped get
settyped set
clearlocalStorage.clear()

api

Makes your function async and awaiting of result. Has try-catch under the hood. Returns Promise<AxiosResponse> Usage

apiBuilder((phone: string) =>
  authAxios.get(`/user?phone_number=${phone}`)
);

component

Error boundary wrapper with custom fallback component.

Usage

export const createFC = builders.component(() => (
  <div>Something went wrong...</div>
));
export default createFc((props:any) => {
    return <div>{{}}</div> // your application will not fall
})

Component builders

I have not finished it yet, so you should to specify styles for overriding like: label.label input.input

Input

InputBuilder. Output is object with different inputs.

export const Input = UIBuilders.InputTextBuilder({
  classNames: {
    elements: {
      input: styles.input,
      label: styles.label,
      error: styles.error,
      wrapper: styles.wrapper,
    },
    state: {
      error: styles.error_state,
    },
  },
  icons: {
    lock: Lock,
    edit: Edit,
    eyeClosed: EyeClosed,
  },
});

Switch

Usage

export const Switch = UIBuilders.SwitchBuilder({
  classNames: {
    input: styles.input,
    circle: styles.circle,
    circleContainer: styles.circleContainer,
    container: styles.container,
  },
});

Use css vars for restyling rect:

--circle-width: 50px;
--padding: 5px;
--border-radius: 40px;

CheckInput

Radio & Checkbox

Usage variant 1

export const CheckInput = UIBuilders.CheckInputBuilder({
  classNames: {
    input: styles.input,
  },
  icons: {
    checkbox: {
      checked: Icons.ui.CheckBoxChecked,
      unchecked: Icons.ui.CheckBoxUnchecked,
    },
    radio: {
      checked: Icons.ui.RadioChecked,
      unchecked: Icons.ui.RadioUnchecked,
    },
  },
});

Usage variant 2

export const PillSwitch = UIBuilders.CheckInputBuilder<"custom", payloadType>({
  classNames: {
    input: styles.input,
  },
  customElement: {
    component: ({ text }) => {
      return <div className={styles.pill}>{text}</div>;
    },
  },
}).group;
.input:checked + .pill {
    background: linear-gradient(180deg, #052DB9 0%, #4B78F2 100%);
    box-shadow: 0px 5px 9px rgba(40, 112, 219, 0.36);
    color: white;
}

.pill {
    width: 131px;
    padding: 10px;
    font-size: 18px;
    transition: .4s;
    text-align: center;
    color: black;
    background: linear-gradient(180deg, #FFFFFF 100%, #FFFFFF 100%);
    border: 1px solid #8FA4B0;
    box-sizing: border-box;
    border-radius: 24px;
}

Hooks

0.0.40

2 years ago

0.0.41

2 years ago

0.0.42

2 years ago

0.0.43

2 years ago

0.0.44

2 years ago

0.0.45

2 years ago

0.0.46

2 years ago

0.0.47

2 years ago

0.0.37

2 years ago

0.0.38

2 years ago

0.0.39

2 years ago

0.0.73

2 years ago

0.0.74

2 years ago

0.0.32

2 years ago

0.0.33

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.70

2 years ago

0.0.71

2 years ago

0.0.72

2 years ago

0.0.62

2 years ago

0.0.63

2 years ago

0.0.64

2 years ago

0.0.65

2 years ago

0.0.66

2 years ago

0.0.67

2 years ago

0.0.68

2 years ago

0.0.69

2 years ago

0.0.60

2 years ago

0.0.61

2 years ago

0.0.59

2 years ago

0.0.51

2 years ago

0.0.52

2 years ago

0.0.53

2 years ago

0.0.54

2 years ago

0.0.55

2 years ago

0.0.56

2 years ago

0.0.57

2 years ago

0.0.58

2 years ago

0.0.50

2 years ago

0.0.48

2 years ago

0.0.49

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago