GithubHelp home page GithubHelp logo

fitfab / fitfab-ui Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 2.95 MB

NPM React Component Library

TypeScript 58.27% JavaScript 41.12% Shell 0.62%
react rollup typescript styled-components es6 storrybook

fitfab-ui's Introduction

Fitfab-UI Component (Rollup, TypeScript, Babel, React styled-components)

With this release, I target ES6 JavaScript. ES6 is much closer to TypeScript and produces less code, which means faster loading times.

  • This Library is meant to be used in modern browsers -- It doesn't support IE11.
  • Other decisions: read more here

peerDependencies:

  • react@^16.8.4
  • react-dom@^16.8.4
  • styled-components@^4.1.3

install

yarn add fitfab-ui

usage

import { prettyDate } from 'fitfab-ui'
const pretty = prettyDate('8/2/2019')
// pretty should be: 'August 2 2019'

See the Storybook setup

Using local copy of fitfab-ui

NPM LINK

  • from the root of 'fitfab-ui' run: npm link
  • from the root of your app run: npm link fitfab-ui

Then start using as normal:

import { Button } from 'fitfab-ui'


Script CMD explained.

NPM CMD: read about npm scripts

"prepublishOnly": "npm test && npm run lint"

  • This run BEFORE the package is prepared and packed, ONLY on npm publish.

  • A good place to verify that linting rules and tests are passing.

Rollup TypeScript & Babel setup

Jest & Enzyme setup

NOTE: make sure that jsx is set to react { "jsx": "react" } within the tsconfig.json file.

Jest & React testing library setup

  • create the file rtl.setup.ts
// See https://github.com/kentcdodds/react-testing-library#global-config
import '@testing-library/react/cleanup-after-each'
import 'jest-dom/extend-expect'
  • Then add it to jest.config.js -- on this project I have a /config folder where the rtl.setup.ts lives.
    /***
     * Setup React-testing-library
     */
    setupFilesAfterEnv: ['<rootDir>/config/rtl.setup.ts'],

Three-Shaking Gotcha

if you were to use export default , the bundle would not be three shaken.

// src/utils.js
export default {
    alert: msg => {
        console.log(msg)
    },
    sum: (x, y) => x + y,
}

// src/main.js
import utils from './utils'

const total = utils.sum(7, 4)
console.log(`This is the total: ${total}`)

The code will include alert eventhough it was NOT use in the main.js file.

Migrate from TSLint to ESLint

reference:

Husky & lint-staged update 2021

  • npx husky-init && npm install

    Note: Husky will create a prepare script command within package.json

  • npx mrm@2 lint-staged

    This command will install and configure husky and lint-staged depending on the code quality tools from your project's package.json dependencies

creating a new husky hooks

  • npx husky add .husky/pre-push 'npm test'

    Note: add the pre-push hook to only run the tests when pushing

  • npx husky add .husky/commit-msg 'message'

    Note: This is to enforce Conventional Commits specification

Commitlint setup

Read the Local Setup Guide for Commitlint

adding fitgma tokens

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.