1.5.2 • Published 1 year ago

@syns-platform/perspective-design-components-react v1.5.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Perspective Design System

Commitizen friendly

Welcome to the Perspective Design System component libary v1

📚 Documentation

Note that perspecive-design-system is a private npm package so you will need an npm account and invitation to the Synspective organization or a .npmrc file at the root of the project with a valid token.

For more information on this see Docbase

🛠 Install

npm i @syns-platform/perspective-design-components-react

Or if you perfer yarn

yarn add @syns-platform/perspective-design-components-react

Finally you will also need these peer dependencies installed in your project

npm install @carbon/icons-react @styled-system/css react react-dom styled-components styled-system rc-slider react-flatpickr yarn add @carbon/icons-react @styled-system/css react react-dom styled-components styled-system rc-slider react-flatpickr

and the types if using typescript

npm install -D @types/styled-components @types/styled-system__css

You will then also want to add a gloabal type for inline styling.

Add a @types folder in the src folder.

Then add the following in index.d.ts

import type { SystemStyleObject } from '@styled-system/css';
declare global {
    type StyleType = SystemStyleObject;

    type StyleObjectType = {
        [index: string]: StyleType;
    };
}

🎨 Adding a theme

You will also need a theme. You can use your own based off a styled-system specification but it's much easier to use our theme.

npm install --save @types/styled-components @types/styled-system__css

💻 Usage

💅 Set up the Theme

Wrap the app in a styled-components theme provider and supply your theme. Here we are using the dark theme from our theme library but you can create your own one too if needed.

import { ThemeProvider } from 'styled-components';
import { darkTheme } from '@syns-platform/perspective-theme';

<ThemeProvider theme={darkTheme}>
   <App />
</ThemeProvider>

🛠 Import components

Then you should be able to use any component by importing it

import { Button } from '@syns-platform/perspective-design-components-react';

<Button
    variant="primary"
    onClick={() => console.log('click')}
>
    Click Me!
</Button>

Icons

We use carbon icons so install the package and it's types if you are using typescript

npm install @carbon/icons-react npm install --save @types/carbon__icons-react

Usage with react-hook-form

On the platform team we use this the react-hook-form for handling forms. Most components should work by default but there are a few that requre use of the Controller component.

Here is an example using the <Combobox /> component

import { useForm, Controller } from 'react-hook-form';
import { Combobox } from '@syns-platform/perspective-design-components-react';

const App: React.FC = () => {
    const {
        formState: { errors },
        control,
    } = useForm();

return (
    <Controller
        name="comboboxController"
        control={control}
        rules={{ required: true }}
        render={({ field }) => (
            <Combobox
                {...field}
                id="combobox"
                items={itemList}
                placeholder="Search by name"
                titleText="Select Item"
                invalid={!!errors.comboboxController}
                invalidText="You need to select an item"
            />
        )}
    />
)}

Overriding styles

Ovridding specific styles can be done in 2 ways.

Theme Override

import { ThemeProvider } from 'styled-components';
import { darkTheme } from '@syns-platform/perspective-theme';

// Define what props.theme will look like
const myTheme = {
  ...darkTheme,
  colors: {
    ...darkTheme.colors,
    ui: {
      ...darkTheme.colors.ui,
      background: 'pink',
      '01': 'orange',
      '02': 'green',
    },
  }
};

<ThemeProvider theme={myTheme}>
   <App />
</ThemeProvider>

sx prop

Many components have a sx prop that allow you to write some inline css that has access to the theme. For more information see the next section.

Custom components

The <Box /> component can be used to create any addional custom component you might need.

The advantage of using the <Box /> over a regular <div /> is that it has build in access to the theme using the sx prop.

import { Box } from '@syns-platform/perspective-design-components-react';

const App: React.FC = () => {

return (
    <Box
        sx={{
            width: '100px',
            backgroundColor: 'ui.01'
            padding: 'spacing05'
        }}
    />
)}

You can also set it to be any type of html element using the as prop.

import { Box } from '@syns-platform/perspective-design-components-react';

const App: React.FC = () => {

return (
    <Box
        as='img'
        src="example.jpg"
        alt="Not useful alt content"
        width="500"
        height="600"
        sx={{
            border: '1px solid red'
        }}
    />
)}

💻 For Developers

We use lerna to manage the monorepo

Dependencies installation and bootstrap

lerna bootstrap

We use storybook for development.

lerna run dev --parallel

So you can write your compoent and a see/debug it in a storybook story. For more information see the contributon guide.

Build

Builds the packages for production to the build folder.

lerna run build

Testing

lerna run test

Launches the test runner in the interactive watch mode. See the section about running tests for more information.

Deployment

  1. Pull latest changes from dev
  2. Run lerna version
  3. Select version bump. In most cases it will be minor or patch
  4. Run lerna publish from-git --no-git-tag-version --no-push --yes
  5. Push Publish commit to origin develop
1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.0

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.1-alpha.0

1 year ago

1.2.0-alpha.0

1 year ago

1.1.6-alpha.0

1 year ago

1.1.5-alpha.0

1 year ago

1.1.4-alpha.0

1 year ago

1.1.3-alpha.0

1 year ago

1.1.2-alpha.0

1 year ago

1.1.1-alpha.0

1 year ago

0.11.0

1 year ago

1.1.0-alpha.0

1 year ago

1.0.2-alpha.0

1 year ago

1.0.1-alpha.0

1 year ago

0.10.3

1 year ago

1.0.0-alpha.0

1 year ago

0.10.2

1 year ago

0.10.1

1 year ago

0.10.0

1 year ago

0.9.7

1 year ago

0.9.6

1 year ago

0.9.5

1 year ago

0.9.4

1 year ago

0.9.3

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.9.0

2 years ago

0.8.7

2 years ago

0.8.6

2 years ago

0.8.5

2 years ago

0.8.4

2 years ago

0.8.3

2 years ago

0.8.2

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.1

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.2.0-beta.9

2 years ago

0.2.0-beta.8

2 years ago

0.2.0-beta.7

2 years ago

0.2.0-beta.6

2 years ago

0.2.0-beta.5

2 years ago

0.2.0-beta.4

2 years ago

0.2.0-beta.3

2 years ago

0.2.0-beta.2

2 years ago

0.2.0-beta.1

2 years ago

0.1.42

2 years ago

0.1.41

2 years ago

0.1.40

2 years ago

0.1.39

2 years ago

0.1.38

2 years ago

0.1.37

2 years ago

0.1.36

2 years ago

0.1.35

2 years ago

0.1.34

2 years ago

0.1.33

2 years ago

0.1.32

2 years ago

0.1.31

2 years ago

0.1.30

2 years ago

0.1.29

2 years ago

0.1.27

2 years ago

0.1.26

2 years ago

0.1.26-beta.0

2 years ago

0.1.25

2 years ago

0.1.24

2 years ago

0.1.23

2 years ago

0.1.22

2 years ago

0.1.21

2 years ago

0.1.20

2 years ago

0.1.19

2 years ago

0.1.18

2 years ago

0.1.17

2 years ago

0.1.16

2 years ago

0.1.15

2 years ago

0.1.14

2 years ago

0.1.13

2 years ago

0.1.12

2 years ago

0.1.11

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago