guilherme-test-lib
v0.0.65
Published
### The base components for the design system of FIBR Bank
Downloads
24
Readme
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 [email protected]: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:
- https://testing-library.com/docs/guiding-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