Giter VIP home page Giter VIP logo

lc-component-library's Introduction

The Lambda Curry Component Library

Installing the Component Library

yarn add @lambdacurry/component-library

Notes about installation and usage

  • If using TypeScript, you'll want to install the @types listed in our peer-dependencies.

  • To get the necessary base styles you'll want to import the index.css file.

    JavaScript:

    import '@lambdacurry/component-library/dist/styles/index.css';

    CSS:

    @import '~@lambdacurry/component-library/dist/styles/index.css';
  • Some SSR (Gatsby) sites do not load the component styles for some reason, so you'll want to use the CSS all.css file (instead of the index.css file). JavaScript:

    import '@lambdacurry/component-library/dist/all.css';

    CSS:

    @import '~@lambdacurry/component-library/dist/all.css';

Theming

The component library uses CSS custom properties to handle theming. To make this work with Tailwind's opacity utilities, the values of your theme variables must be in RGB format. Our configuration handles wrapping the values in the rgba() function, so you only need to provide the comma-separate RGB values. For example to override the black color variable, you would do it like this:

.my-theme-root {
  --lc-color-black: 40, 45, 48; /* This is equivalent to the hex value #282D30 */
}

Here is the full list of CSS custom properties that we currently provide for theming (along with their default values):

:root {
  --lc-color-black: 0, 0, 0;
  --lc-color-white: 255, 255, 255;

  --lc-color-gray-lightest: 245, 246, 250;
  --lc-color-gray-lighter: 226, 226, 226;
  --lc-color-gray-light: 189, 189, 189;
  --lc-color-gray: 160, 165, 186;
  --lc-color-gray-dark: 112, 112, 112;
  --lc-color-gray-darker: 64, 64, 64;

  --lc-color-primary: 49, 130, 206;
  --lc-color-primary-dark: 44, 82, 130;

  --lc-color-accent: 237, 100, 166;
  --lc-color-accent-dark: 184, 50, 128;

  --lc-color-success: 72, 187, 120;
  --lc-color-success-dark: 47, 133, 90;

  --lc-color-warning: 237, 137, 54;
  --lc-color-warning-dark: 221, 107, 32;

  --lc-color-danger: 229, 62, 62;
  --lc-color-danger-dark: 197, 48, 48;

  --lc-color-active: 91, 208, 103;
}

Documentation

To view the documentation for the component library go to https://component-library.lambdacurry.dev/. (The documentation automatically deploys when new updates are merged to the master branch.)

How to deploy a beta version

For internal Lambda Curry organization people, there is a document on this here.

ESbuild

We're utilizing esbuild for the builds: https://esbuild.github.io/

A few things to note:

  • Currently the postcss.config.js is using a new format (utilized by storybook), so we are replicating the config within esbuild.msj. Updates for PostCSS should be done in both places for now.
  • We copied the source code for the esbuild PostCSS and SVGR plugins. We are using them within our project (esbuild.postcss.js and esbuild.fileImport.js). In order to get SVGs (and other image assets) working, we convert them all to javascript files with SVGR, but the imports in the compiled JavaScript files were still expecting .svg, so esbuild.fileImport.js is a custom plugin that rewrites those imports to their expected .js file.

TypeScript

The tsconfig.json is set up to interpret dom and esnext types, as well as react for jsx. Adjust according to your needs.

Storybook

Learn the nx commands to run storybook and e2e cypress testing for it.

NOTE: Stories should reference the components as if using the library, similar to the example playground. This means importing from the root project directory. This has been aliased in the tsconfig and the storybook webpack config as a helper.

Configuration

Code quality is set up for you with prettier, husky, and lint-staged. Adjust the respective fields in package.json accordingly. (we are currently not utilizing these, except for prettier)

Building

To do a one-off build, use yarn build.

Testing

To run tests, use yarn test. (Tests are a good idea, we should add them sometime.)

Jest

Jest tests are set up to run with yarn test.

React Testing Library

We do not set up react-testing-library for you yet, we welcome contributions and documentation on this.

This project was generated using Nx.

๐Ÿ”Ž Smart, Extensible Build Framework

Adding capabilities to your workspace

Nx supports many plugins which add capabilities for developing different types of applications and different tools.

These capabilities include generating applications, libraries, etc as well as the devtools to test, and build projects as well.

Below are our core plugins:

  • React
    • npm install --save-dev @nrwl/react
  • Web (no framework frontends)
    • npm install --save-dev @nrwl/web
  • Angular
    • npm install --save-dev @nrwl/angular
  • Nest
    • npm install --save-dev @nrwl/nest
  • Express
    • npm install --save-dev @nrwl/express
  • Node
    • npm install --save-dev @nrwl/node

There are also many community plugins you could add.

Generate an application

Run nx g @nrwl/react:app my-app to generate an application.

You can use any of the plugins above to generate applications as well.

When using Nx, you can create multiple applications and libraries in the same workspace.

Generate a library

Run nx g @nrwl/react:lib my-lib to generate a library.

You can also use any of the plugins above to generate libraries as well.

Libraries are shareable across libraries and applications. They can be imported from @testworkspace/mylib.

Development server

Run nx serve my-app for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Code scaffolding

Run nx g @nrwl/react:component my-component --project=my-app to generate a new component.

Build

Run nx build my-app to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.

Running unit tests

Run nx test my-app to execute the unit tests via Jest.

Run nx affected:test to execute the unit tests affected by a change.

Running end-to-end tests

Run ng e2e my-app to execute the end-to-end tests via Cypress.

Run nx affected:e2e to execute the end-to-end tests affected by a change.

Understand your workspace

Run nx dep-graph to see a diagram of the dependencies of your projects.

Further help

Visit the Nx Documentation to learn more.

โ˜ Nx Cloud

Distributed Computation Caching & Distributed Task Execution

Nx Cloud pairs with Nx in order to enable you to build and test code more rapidly, by up to 10 times. Even teams that are new to Nx can connect to Nx Cloud and start saving time instantly.

Teams using Nx gain the advantage of building full-stack applications with their preferred framework alongside Nxโ€™s advanced code generation and project dependency graph, plus a unified experience for both frontend and backend developers.

Visit Nx Cloud to learn more.

lc-component-library's People

Contributors

carlo-piantini avatar chrishuman0923 avatar dwene avatar jaredhill4 avatar jaruesink avatar togoog1 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

adsupnow

lc-component-library's Issues

Storybook build is broken

After migrating to PostCSS the Storybook build is broken. It appears it is having a problem finding the assets, so we probably need to take a look at what is going on with postcss-url plugin. Here is the output I'm currently seeing:

70% building 2266/2266 modules 0 activeERR! => Failed to build the preview
ERR! Module not found: Error: Can't resolve './dist/assets/fonts/gilroy-thin.woff' in '/Users/jaredhill/Code/lc-component-library/src/styles'
ERR! ModuleNotFoundError: Module not found: Error: Can't resolve './dist/assets/fonts/gilroy-thin.woff' in '/Users/jaredhill/Code/lc-component-library/src/styles'
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/webpack/lib/Compilation.js:925:10
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/webpack/lib/NormalModuleFactory.js:401:22
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/webpack/lib/NormalModuleFactory.js:130:21
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/webpack/lib/NormalModuleFactory.js:224:22
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/neo-async/async.js:2830:7
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/neo-async/async.js:6877:13
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/webpack/lib/NormalModuleFactory.js:214:25
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/enhanced-resolve/lib/Resolver.js:213:14
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/enhanced-resolve/lib/Resolver.js:285:5
ERR!     at eval (eval at create (/Users/jaredhill/Code/lc-component-library/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/enhanced-resolve/lib/Resolver.js:285:5
ERR!     at eval (eval at create (/Users/jaredhill/Code/lc-component-library/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/enhanced-resolve/lib/Resolver.js:285:5
ERR!     at eval (eval at create (/Users/jaredhill/Code/lc-component-library/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43
ERR!  ModuleNotFoundError: Module not found: Error: Can't resolve './dist/assets/fonts/gilroy-thin.woff' in '/Users/jaredhill/Code/lc-component-library/src/styles'
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/webpack/lib/Compilation.js:925:10
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/webpack/lib/NormalModuleFactory.js:401:22
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/webpack/lib/NormalModuleFactory.js:130:21
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/webpack/lib/NormalModuleFactory.js:224:22
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/neo-async/async.js:2830:7
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/neo-async/async.js:6877:13
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/webpack/lib/NormalModuleFactory.js:214:25
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/enhanced-resolve/lib/Resolver.js:213:14
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/enhanced-resolve/lib/Resolver.js:285:5
ERR!     at eval (eval at create (/Users/jaredhill/Code/lc-component-library/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/enhanced-resolve/lib/Resolver.js:285:5
ERR!     at eval (eval at create (/Users/jaredhill/Code/lc-component-library/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/enhanced-resolve/lib/Resolver.js:285:5
ERR!     at eval (eval at create (/Users/jaredhill/Code/lc-component-library/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
ERR!     at /Users/jaredhill/Code/lc-component-library/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43
ERR! resolve './dist/assets/fonts/gilroy-thin.woff' in '/Users/jaredhill/Code/lc-component-library/src/styles'
ERR!   using description file: /Users/jaredhill/Code/lc-component-library/package.json (relative path: ./src/styles)
ERR!     Field 'browser' doesn't contain a valid alias configuration
ERR!     using description file: /Users/jaredhill/Code/lc-component-library/package.json (relative path: ./src/styles/dist/assets/fonts/gilroy-thin.woff)
ERR!       no extension
ERR!         Field 'browser' doesn't contain a valid alias configuration
ERR!         /Users/jaredhill/Code/lc-component-library/src/styles/dist/assets/fonts/gilroy-thin.woff doesn't exist
ERR!       .mjs
ERR!         Field 'browser' doesn't contain a valid alias configuration
ERR!         /Users/jaredhill/Code/lc-component-library/src/styles/dist/assets/fonts/gilroy-thin.woff.mjs doesn't exist
ERR!       .js
ERR!         Field 'browser' doesn't contain a valid alias configuration
ERR!         /Users/jaredhill/Code/lc-component-library/src/styles/dist/assets/fonts/gilroy-thin.woff.js doesn't exist
ERR!       .jsx
ERR!         Field 'browser' doesn't contain a valid alias configuration
ERR!         /Users/jaredhill/Code/lc-component-library/src/styles/dist/assets/fonts/gilroy-thin.woff.jsx doesn't exist
ERR!       .ts
ERR!         Field 'browser' doesn't contain a valid alias configuration
ERR!         /Users/jaredhill/Code/lc-component-library/src/styles/dist/assets/fonts/gilroy-thin.woff.ts doesn't exist
ERR!       .tsx
ERR!         Field 'browser' doesn't contain a valid alias configuration
ERR!         /Users/jaredhill/Code/lc-component-library/src/styles/dist/assets/fonts/gilroy-thin.woff.tsx doesn't exist
ERR!       .json
ERR!         Field 'browser' doesn't contain a valid alias configuration
ERR!         /Users/jaredhill/Code/lc-component-library/src/styles/dist/assets/fonts/gilroy-thin.woff.json doesn't exist
ERR!       .cjs
ERR!         Field 'browser' doesn't contain a valid alias configuration
ERR!         /Users/jaredhill/Code/lc-component-library/src/styles/dist/assets/fonts/gilroy-thin.woff.cjs doesn't exist
ERR!       .ts
ERR!         Field 'browser' doesn't contain a valid alias configuration
ERR!         /Users/jaredhill/Code/lc-component-library/src/styles/dist/assets/fonts/gilroy-thin.woff.ts doesn't exist
ERR!       .tsx
ERR!         Field 'browser' doesn't contain a valid alias configuration
ERR!         /Users/jaredhill/Code/lc-component-library/src/styles/dist/assets/fonts/gilroy-thin.woff.tsx doesn't exist
ERR!       as directory
ERR!         /Users/jaredhill/Code/lc-component-library/src/styles/dist/assets/fonts/gilroy-thin.woff doesn't exist
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Fix React 18 TypeScript errors

This tweet provides context for this issue:

https://twitter.com/reactjs/status/1512453230504124420

To force compatibility with React 18, we have temporarily added // @ts-ignore comments to lines that could not be fixed via simple dependency upgrades or w/o spending too much time sifting through the TS errors.

We need to go back through and resolve the TS errors and remove the // @ts-ignore comments.

Adding Placeholder to Date Input breaks the input

Let's say we want to have a date input with a placeholder like so. Currently this breaks the date formatting and causes an error in the change detection.

       <InputDate
              name="start"
              label="Select Begin Date"
              inputProps={{ placeholder: 'mm/dd/yyyy' }}
              formikProps={dateRangeFormikProps}
       />

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.