1.17.1 • Published 4 years ago

@cognite/cogs.js v1.17.1

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
4 years ago

Cogs.js

Cogs.js is the UI Building Blocks for Cognite Applications.

Mission Statement

Cogs.js aims to solve, or assist to solve, the following problems:

  • Lack of design consistency across applications within Cognite.
  • Improving developer experience when creating designs from Figma
  • Lack of single source for common, reusable tokens and atoms (Icons, Colors, type, etc)

Cogs.js also aims to replace antd.

Cogs.js exports several base tokens, such as Colors, Typography and Icons. It also exports several atom components, such as buttons. Finally, it exports some smaller molecules, such as a loading screen.

Installation!

Start off by installing the package through yarn.

$ yarn add @cognite/cogs.js
$ npm install @cognite/cogs.js

Use

You can see what's available within the storybook.

Contribution

Cogs.js should be a community driven effort. See the Design System board for more of what needs doing!

Releases and Commit messages

Releases are automated by semantic-release. Each commit can trigger a release. We use the conventionalcommit pattern to decide whether a commit is a PATCH, MINOR or MAJOR release.

  • Commit message prefix fix: indicates PATCH release,
  • Commit message prefix feat: indicates MINOR release,
  • Commit message prefix {ANY_PREFIX}!: so for example feat!: or even refactor!: indicate MAJOR release.

Making a new component checklist

Use the Button component as an example, for a starting place

  • Place a new folder into either Atoms, Components or Tokens
  • In that folder, have an index.ts that exports everything, Button.tsx and Button.stories.tsx.
  • Add Button.spec.tsx next to Button.tsx.
  • All styles related to that component go into the matching directory in the styles directory

Guidelines:

  • In all cases, you should build your component in the most agnostic way possible - using pure CSS. Then build your React component to use these styles. Sometimes this isn't feasible, and thats okay.
  • Remember to export your component in src/index.ts, or you won't see it in NPM!

Your stories should look like this:

  • HTML only version (when at all possible, provide a HTML only version for non-React users.)
  • React component (required, showing the basic use)
  • Example stories (whatever you think is good)
  • Playground (if it seems useful)

Adding util functions

If you have common, reused functions, you can also place them here! Provide the function, any tests, and a README describing the function in a single folder under Utils.

Jest matchers

@cognite/cogs.js exposes custom jest matchers to aid in writing unit tests. To integrate this in your tests, do the following:

Import the expect extensions somewhere in the setup process. This is commonly done in src/setupTests.ts. However, please consult your jest.config.js to see which files are provided to setupFilesAfterEnv.

import '@cognite/cogs.js/extend-expect';

Then in your tests, the new extensions can be used natively. For example:

import React from 'react';
import { render, screen } from '@testing-library/react';

import DeleteButton from './DeleteButton'; // your custom component

describe('DeleteButton', () => {
  it('is disabled by default', () => {
    render(<DeleteButton />);
    const button = screen.getByRole('button', { name: 'Delete item' });
    expect(button).toBeInTheDocument();
    expect(button).toBeDisabled();
    expect(button).toContainCogsIcon('Delete');
  });
});

Figma Icons

We make use of Figma's API to get icons. To update icons in cogs.js, we currently manually run a script to fetch them from figma, and then make a PR containing any additions or changes generated by the output of the script.

Before running the script, it is required to have an access token, which can be fetched according to these instructions, and then stored under the local environment variable (ie. in .bash_profile) named FIGMA_TOKEN.

Now you may run:

$ yarn figma:icons

This will take all the icon symbols from the 'CogniteIcons' figma file as SVGs and place them into an output folder. After that, it will parse all the SVG icons, replacing colors and turning them into components It will then prettify all files. You can delete the output folder after running the script :)

1.14.1

4 years ago

1.10.5

4 years ago

1.2.0

4 years ago

1.14.0

4 years ago

1.10.4

4 years ago

1.10.3

4 years ago

1.10.2

4 years ago

1.14.3

4 years ago

1.10.7

4 years ago

1.14.2

4 years ago

1.10.6

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.2.1

4 years ago

1.15.0

4 years ago

1.11.1

4 years ago

1.15.1

4 years ago

1.9.1

4 years ago

1.9.0

4 years ago

1.5.0

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.10.1

4 years ago

1.10.0

4 years ago

1.12.1

4 years ago

1.12.0

4 years ago

1.16.0

4 years ago

1.8.1

4 years ago

1.8.0

4 years ago

1.4.0

4 years ago

1.11.0

4 years ago

1.13.0

4 years ago

1.17.1

4 years ago

1.17.0

4 years ago

1.7.0

4 years ago

1.3.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.11

4 years ago

1.0.12

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

0.4.10

4 years ago

0.4.9

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago

0.4.8

4 years ago

0.4.7

4 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.2.42

4 years ago

0.2.41

4 years ago

0.2.40

4 years ago

0.2.39

4 years ago

0.2.38

4 years ago

0.2.37

4 years ago

0.2.36

4 years ago

0.2.35

4 years ago

0.2.34

4 years ago

0.2.33

5 years ago

0.2.32

5 years ago

0.2.31

5 years ago

0.2.29

5 years ago

0.2.28

5 years ago

0.2.27

5 years ago

0.2.26

5 years ago

0.2.25

5 years ago

0.2.24

5 years ago

0.2.23

5 years ago

0.2.22

5 years ago

0.2.21

5 years ago

0.2.20

5 years ago

0.2.19

5 years ago

0.2.18

5 years ago

0.2.17

5 years ago

0.2.16

5 years ago

0.2.15

5 years ago

0.2.14

5 years ago

0.2.14-rc.0

5 years ago

0.2.13-rc.3

5 years ago

0.2.13-rc.2

5 years ago

0.2.13-rc.1

5 years ago

0.2.13

5 years ago

0.2.13-rc.0

5 years ago

0.2.12-rc.0

5 years ago

0.2.12

5 years ago

0.2.11

5 years ago

0.2.10

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.1.12

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.21

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago