1.8.21 • Published 2 years ago

@crcdevops/open-source-design-system v1.8.21

Weekly downloads
1,253
License
MIT
Repository
github
Last release
2 years ago

Changes to come

If you intend to fork this open repo, I advise to wait. There are some major changes coming in the near near future which would make it awkward for you if you intend to use/contribute to this repo.

The following changes are:

  • Name change to repo and npm package
  • Code of conduct
  • Contributing guidelines

CRC Design System

This a guide to help everyone (developers and designers) understand the core design principles of CRC. As a company that highly values relationships, we mirror this focus in our UX. Our design decisions prioritises user satisfaction, making sure any aesthetic/functional additions only improve on that aspect.

Prerequisites

This design system uses React.

Using the Design System

Installation

To install this repo and use its components, install with yarn.

yarn add @crcdevops/open-source-design-system

Importing Components

Once installation is done, the package.json file will update with the design-system in the dependency. Import the chosen components into your react app and voilà.

import { Label } from "@crcdevops/open-source-design-system";

You can view the different components and their name via storybook.

Editing the Design System

The design system is alive and ever evolving. If you wish to contribute, clone and open a new branch to begin making changes. Remember user satisfaction is of utmost priority.

Cloning the repo

Like with all repos git clone and then enter your password as this is a private repo. Then install all necessary dependencies.

git@github.com:Client-Relationship-Consultancy/open-source-design-system.git
yarn install

Linking locally to packages using the Design-system

This is a bit of a pain right now and we will create a better way of doing it soon.

  • yarn build
  • yarn link
  • then in the package using the design system, run yarn link @crcdevops/open-source-design-system

Migrating to Typescript

  1. Change component file from .js -> .ts and type the Component file!
  2. Change the Component and Interface as names exports:
export const Component = ...
export interface IComponent { ...
  1. Update the Component/index.js file to
export {Component, IComponent} from "./Component"
  1. Update the src/index.js to export the new named Component and Interface
  2. Update package patch version! (e.g. 1.0.X)

Gotcha - Jest Snapshots failing

Versioning

Patch versions should be taken care of automatically by CircleCI. But if you want to bump a minor or major version then you'll have to do it manually in the package.json

  • You should bump the minor version if your change is breaking

Storybook

Storybook is a very useful development environment for creating and managing components. Run storybook by typing the following command in the command line:

yarn storybook

All existing and new components go in the src/components directory. The repo is structured based on an atomic design principle. The smallest components, such as buttons, labels and input, shoud be placed in the atoms directory. More complex components would go either in molecules or organisms. Note that these components are meant to be reusable, so please think about how they can be customised for all used cases. If there are meaningful restrictions, please state wherever is appropiate.

In order for storybook to render your components, please import them into the stories/index.js file. Below is an example story:

import { MyComponent } from "../src/components/atoms/MyComponent";

storiesOf("MyComponent Story", module)
    .add("MyComponent", () => {
        return <MyComponent>Hello World!</MyComponent>;
    })
    .add("MyComponent Alt", () => {
        return <MyComponent foo="bar">Hello World!</MyComponent>;
    });

Writing Tests

All tests are handled by Jest and Enzyme. Everything is already configured which you can find in the jestSetup.js file in the root directory. Further Jest settings can be seen in the package.json file. Please do not touch the __mocks__ directory, as jest needs it to be able to read the css files.

When writing enzyme tests, you may sometimes run into difficulties when shallow rendering. This is due to styled components adding an outer wrapper. If you mount render instead, it will work.

All components should have a test file written for it. The test files need to end in *.test.js; Jest will automatically pick this up. Please place the tests files in the same directory as the component it is testing. This will make it obvious as to which component does not have a test file.

Below is an example test file:

import React from "react";
import { mount } from "enzyme";
import "jest-styled-components";
import MyComponent from "./MyComponent";

describe("MyComponent Tests", () => {
    const component = mount(<MyComponent foo="bar">Hello World!</MyComponent>);

    it("render MyComponent", () => {
        expect(component.prop(foo)).toEqual("bar");
    });
    it("match snapshot?", () => {
        expect(component).toMatchSnapshot();
    });
});

Gotchas

  • If you import from index within the design-system you may get circular dependency issues. Avoid doing this from files within the design-system and instead use the alias paths to the file you would like
  • When you yarn link, the Jest snapshots may fail. Clearing the jest cache should fix it: yarn jest --clearCache

13/12/19 - Storybook Version Errors

  • please note that we have had some versioning issues with storybook recently - if you face errors related to storybook please try the following versions: "@storybook/addon-notes": "5.2.4", "@storybook/addon-options": "5.2.4", "@storybook/addons": "5.2.4", "@storybook/react": "5.2.5",
1.8.21

2 years ago

1.8.20

2 years ago

1.8.15

2 years ago

1.8.16

2 years ago

1.8.17

2 years ago

1.8.18

2 years ago

1.8.19

2 years ago

1.8.13

2 years ago

1.8.14

2 years ago

1.8.11

3 years ago

1.8.12

2 years ago

1.8.9

3 years ago

1.8.10

3 years ago

1.8.8

3 years ago

1.8.7

3 years ago

1.8.6

3 years ago

1.8.5

3 years ago

1.8.2

3 years ago

1.8.4

3 years ago

1.8.3

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.55

3 years ago

1.7.54

3 years ago

1.7.53

3 years ago

1.7.52

3 years ago

1.7.51

3 years ago

1.7.50

3 years ago

1.7.49

3 years ago

1.7.48

3 years ago

1.7.47

3 years ago

1.7.46

3 years ago

1.7.45

3 years ago

1.7.44

3 years ago

1.7.42

3 years ago

1.7.43

3 years ago

1.7.41

3 years ago

1.7.40

3 years ago

1.7.39

3 years ago

1.7.36

3 years ago

1.7.37

3 years ago

1.7.38

3 years ago

1.7.35

3 years ago

1.7.34

3 years ago

1.7.33

3 years ago

1.7.32

3 years ago

1.7.31

3 years ago

1.7.30

3 years ago

1.7.29

3 years ago

1.7.28

3 years ago

1.7.27

3 years ago

1.7.25

3 years ago

1.7.26

3 years ago

1.7.24

3 years ago

1.7.23

3 years ago

1.7.22

3 years ago

1.7.20

3 years ago

1.7.21

3 years ago

1.7.17

3 years ago

1.7.16

3 years ago

1.7.15

3 years ago

1.7.14

3 years ago

1.7.13

3 years ago

1.7.12

3 years ago

1.7.11

3 years ago

1.7.10

3 years ago

1.7.9

3 years ago

1.7.8

3 years ago

1.7.7

3 years ago

1.7.6

3 years ago

1.7.5

3 years ago

1.7.4

3 years ago

1.7.3

3 years ago

1.7.2

3 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.6.15

3 years ago

1.6.16

3 years ago

1.6.14

3 years ago

1.6.13

3 years ago

1.6.12

3 years ago

1.6.11

3 years ago

1.6.10

3 years ago

1.6.9

3 years ago

1.6.8

4 years ago

1.6.7

4 years ago

1.6.6

4 years ago

1.6.5

4 years ago

1.6.4

4 years ago

1.6.3

4 years ago

1.6.2

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.12

4 years ago

1.5.11

4 years ago

1.5.10

4 years ago

1.5.9

4 years ago

1.5.8

4 years ago

1.5.7

4 years ago

1.5.6

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.9

4 years ago

1.4.8

4 years ago

1.4.7

4 years ago

1.4.6

4 years ago

1.4.5

4 years ago

1.4.4

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago