0.0.65 • Published 3 years ago

guilherme-test-lib v0.0.65

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
3 years ago

UI Library

The base components for the design system of FIBR Bank

Install

npm install @material-ui/core @atbankio/ui-library

Getting Started

Welcome to this community-supported project! :wave:. This library is the React implementation of the FIBR's Design Language. This library has a peer dependency on @material-ui/core since it uses Material UI components as core.

Usage

Setup

For a no hassle setup and compatibility with Create React App, transpiled ES6 and CommonJS module versions have been included within the NPM package. If using this setup, please re-write the import statement in the documentation site examples. Use the following named import syntax to access the transpiled components from /src/index.ts:

import { ThemeProvider, Button } from '@atbankio/ui-library';

// Add `ThemeProvider` to the list of providers for your app
<ThemeProvider>
  <Button>Hello world</Button>
</ThemeProvider>;

Next.js Setup

The steps below are based on:

In order to have a proper SSR setup for the styles you need to follow the steps below:

Install styled-components

yarn add styled-components

Add SSR config to _document.tsx

import { ServerStyleSheets as MaterialSSRStyles } from '@material-ui/core/styles';
import { ServerStyleSheet as StyledSSRStyles } from 'styled-components';

// ...

static async getInitialProps(ctx: DocumentContext) {
  const materialSheets = new MaterialSSRStyles();
  const styledComponentsSheet = new StyledSSRStyles();

  const originalRenderPage = ctx.renderPage;

  try {
    ctx.renderPage = () =>
      originalRenderPage({
        enhanceApp: (App) => (props) =>
          styledComponentsSheet.collectStyles(materialSheets.collect(<App {...props} />)),
      });

    const initialProps = await Document.getInitialProps(ctx);

    return {
      ...initialProps,
      styles: (
        <>
          {initialProps.styles}
          {materialSheets.getStyleElement()}
          {styledComponentsSheet.getStyleElement()}
        </>
      ),
    };
  } finally {
    styledComponentsSheet.seal();
  }
}

Add remove the generated SSR styles from the client side:

React.useEffect(() => {
  const jssStyles = document.querySelector("#jss-server-side");

  if (jssStyles) {
    jssStyles?.parentElement?.removeChild(jssStyles);
  }
}, []);

Setting up the project

git clone git@github.com:atbankio/channels-ui-library.git
cd channels-ui-library
yarn && yarn storybook
open http://localhost:3001

Structure

Tech stack

Project structure

Component structure

How to

How to style

We use styled-components for the styling, together with Material UI base theme. We follow these patterns:

  • CSS based styled components
  • Named exports
  • Use transient props to prevent props going to the DOM
  • From the components import all as S (styled) and use like <S.Button />

How to test

We use testing-library to test the components, there is no exact pattern, but we try to follow the testing-library principles:

If it relates to rendering components, then it should deal with DOM nodes rather than component instances, and it should not encourage dealing with component instances.
  1. It should be generally useful for testing the application components in the way the user would use it. We are making some trade-offs here because we're using a computer and often a simulated browser environment, but in general, utilities should encourage tests that use the components the way they're intended to be used.
  2. Utility implementations and APIs should be simple and flexible.
  3. At the end of the day, what we want is for this library to be pretty light-weight, simple, and understandable.

How to document

@TODO

How to release

@TODO

Release strategy

@TODO

Manually deploy

@TODO

Test your release

@TODO

Accessibility

We use Storybook's accessibiliy plugin that uses aXe as testing engine to detect accessibility issues, please be aware of it when developing.


© Amsterdam Trade Bank

0.0.65

3 years ago

0.0.60

3 years ago

0.0.20

3 years ago

0.0.21

3 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.24

3 years ago

0.0.25

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago