4.8.1 • Published 3 years ago

@workday/canvas-kit-react-core v4.8.1

Weekly downloads
1,649
License
Apache-2.0
Repository
-
Last release
3 years ago

Canvas Kit Core

Canvas Kit Core contains values and base styles that are shared across the kit.

Includes:

Installation

yarn add @workday/canvas-kit-react

or

yarn add @workday/canvas-kit-react-core

Colors

Workday Canvas Colors are directly exported from @workday/canvas-colors-web. Colors come in shades from 100 (lighter) - 600 (darker). These can be used directly, but semantic constants are preferred.

Colors (100-600):

  • Cinnamon
  • Peach
  • Chili Mango
  • Cantaloupe
  • Sour Lemon
  • Juicy Pear
  • Kiwi
  • Green Apple
  • Watermelon
  • Jewel
  • Toothpaste
  • Blueberry
  • Plum
  • Berry Smoothie
  • Blackberry
  • Island Punch
  • Grape Soda
  • Pomegranate
  • Fruit Punch
  • Root Beer
  • Toasted Marshmallow
  • Coconut
  • Cappuccino
  • Soap
  • Licorice
  • French Vanilla
  • Black Pepper

Usage

import {colors} from '@workday/canvas-kit-react-core';

colors.blueberry400;

Each of the colors have a gradient version as well

import {colors} from '@workday/canvas-kit-react-core';

colors.gradients.blueberry;

Semantic constants

To ensure consistency across implementations, our semantic constants should be used wherever possible. This allows us to swap out the color of a button or icon for example, without having to find every instance of it and change the color manually.

We have several semantic groupings:

  • commonColors
  • buttonColors
    • delete
    • primary
    • secondary
  • iconColors
  • statusColors
  • typeColors
import {iconColors} from '@workday/canvas-kit-react-core';

iconColors.hover;

Spacing

Workday Canvas Spacing is directly exported from @workday/canvas-spacing-web.

Spacing variables are in a "t-shirt size" format. Spacing values are in px format (spacing) or number format (spacingNumbers).

VariableSize (px)Size (number)
xxxs'4px'4
xxs'8px'8
xs'12px'12
s'16px'16
m'24px'24
l'32px'32
xl'40px'40
xxl'64px'64
xxxl'80px'80

Margin & Padding

Spacing functions provide margin and padding spacing. These are available with the space function. The space function utilizes the following props:

Margin Props

  • m margin
  • mt margin-top
  • mr margin-right
  • mb margin-bottom
  • ml margin-left
  • mx margin-left & margin-right
  • my margin-top & margin-bottom

Padding Props

  • p padding
  • pt padding-top
  • pr padding-right
  • pb padding-bottom
  • pl padding-left
  • px padding-left & padding-right
  • py padding-top & padding-bottom

Usage

import {spacing, spacingNumbers, space} from '@workday/canvas-kit-react-core';

spacing.s; // 16px
spacingNumbers.s; // 16

...

const Box = styled('div')(space)

<Box p={spacing.xl} pb={64} m={40} mx={10}>
  ...
</Box>

/*
  margin-top: 40px;
  margin-right: 10px;
  margin-bottom: 40px;
  margin-left: 10px;
  padding-top: 40px;
  padding-right: 40px;
  padding-bottom: 64px;
  padding-left: 40px;
*/

Depth

Five levels of depth are available. They are directly exported from @workday/canvas-depth-web.

LevelUsage Recommendations
Depth -1 (inset)Inset card depth
Depth 1Standard card depth
Depth 2Increased card depth on hover
Depth 3Active cards, popups
Depth 4Cards on white backgrounds, menus

Usage

import {depth} from '@workday/canvas-kit-react-core';

depth.inset;
depth['2'];

Type

Type styles are available as objects to use alone or with Emotion.

Our type module is a combination of hierarchy and variants. The hierarchy has the font size, weight, etc. for different levels of type (e.g. canvas.type.h1, canvas.type.body, etc.). The variants (e.g. canvas.type.variant.label) are applied to a hierarchy level to achieve certain styling. Variants only come their augmenting styles and a base type object is required.

Hierarchy Levels
dataViz1
dataViz2
h1
h2
h3
h4
h5
body
body2
small
Variants
label
button
caps
hint
error
inverse
mono
link

Disclaimer

A new type hierarchy is in the process of being introduced into our products. You can find more info about it in the Beta Type Hierarchy section. We plan to maintain both hierarchies for a short time, but there will be a breaking change when we replace the current one with the new one.

Usage

If you're working in emotion, you can simply spread the type objects to use their styles.

import {type} from '@workday/canvas-kit-react-core';

const MyLabel = styled('label')({
  ...type.body,
  ...type.variant.label,
});

If you are only using one object, you can do this inline with the style attribute.

import {type} from '@workday/canvas-kit-react-core';

<h1 style={type.h1}>H1 Header</h1>;

To combine objects inline, you can also use emotion's css function.

import {type} from '@workday/canvas-kit-react-core';

<label className={css(canvas.type.body, canvas.type.variant.label)}>Label Text</label>;

Beta Type Hierarchy

As stated above, a new type hierarchy is in the process of being introduced into our products. It relies on larger font sizes/weights to increase legibility and promote reducing density in UI design. Other than the visual size and weight changes across every level of hierarchy, there are a few naming changes: type.dataViz1 and type.dataViz2 have been renamed to type.brand1 and type.brand2, respectively.

Usage

The usage is the same as the current hierarchy, you just need a different import.

import {beta_type as type} from '@workday/canvas-kit-react-core';

const MyLabel = styled('label')({
  ...type.body,
  ...type.variant.label,
});

Breaking Change

When the breaking change is made, anyone using the current type guide will need to update the references for dataViz1 and dataViz2, and adjust any references they want to keep at the same size (since the text will automatically get large). For those already using beta_type, they simply need to drop beta_ from their import.

Input Provider

This is a higher order (wrapping) component for providing css-referencable data attributes for the users current input. Focus outlines are required for accesibility, but they can be unnecessary visual noise when using a mouse. This allows us to hide focus outlines (as desired) while the user is interacting with components using a mouse, touch, etc. and show them when keyboard navigation begins. This logic is heavily influenced by what-input.

We strongly encourage you to use this in your application to wrap all Canvas components. You can use it to style your own components as well.

Definitions

Input: The current input method from the user.

  • Equal to one of InputTypes
  • Triggered by the following events:
    • keydown
    • keyup
    • mousedown
    • MSPointerDown
    • pointerdown
    • touchstart

Intent: The potential next input method from the user. Mouse, pointer and mouse wheel events only demonstrate potential, but not actual, interaction and are treated separately. Note: if input type updates from the events above, the intent type will also be updated to the same value.

  • Equal to one of InputTypes
  • Triggered by the following events:
    • mousemove
    • MSPointerMove
    • pointermove
    • wheel
    • mousewheel
    • DOMMouseScroll

Usage

As an external consumer, you should reference the following example.

If you are contributing a component, you must add the necessary styling (see below) and use the InputProviderDecorator in your stories. DO NOT wrap any canvas kit components in an InputProvider.

import * as React from 'react';
import {InputProvider} from '../../../../utils/storybook';

<InputProvider>{/* All your components containing any Canvas components */}</InputProvider>;

This will result in a wrapping div with two data attributes:

<div data-whatinput="mouse" data-whatinput="mouse"><!-- All your components' HTML --></div>

Now in any component within this wrapper, you can use these data attributes to customize the focus handling.

React/Emotion:

[`[data-whatinput='mouse'] &:focus,
  [data-whatinput='touch'] &:focus,
  [data-whatinput='pointer'] &:focus`]: {
  outline: 'none',
  border: 'none',
},

SCSS:

[data-whatinput='mouse'],
[data-whatinput='touch'],
[data-whatinput='pointer'] {
  .my-component:focus {
    outline: none;
    border: none;
  }
}

We provide a helper to hide the focus outlines on mouse input. Simply spread it in your styles (i.e. ...hideMouseFocus).

Note: It is best practice to show focus outlines by default and specifically hide them in the cases you would like (i.e. mouse/touch/pointer input).

Static Properties

InputTypes

Theme
Keyboard
Mouse
Pointer
Touch

Component Props

Required

None

Optional

provideIntent: boolean

Whether you would like the attribute data-whatintent rendered (see definition of intent above). Note: detecting intent will add scroll and mouse positioning listeners which could affect performance.

Storybook Decorator

We provide a storybook decorator to wrap your stories in an InputProvider automatically.

Example:

import {InputProviderDecorator} from '../../../../utils/storybook';

storiesOf('My Story', module)
  .addDecorator(InputProviderDecorator)
  .add('All', () => <YourJSX />);
@infinitebrahmanuniverse/nolb-_wor@everything-registry/sub-chunk-1021@workday/canvas-kit-labs-react-select@workday/canvas-kit-labs-react-side-panel@workday/canvas-kit-labs-react-tabs@workday/canvas-kit-labs-react-breadcrumbs@workday/canvas-kit-labs-react-button@workday/canvas-kit-labs-react-menu@workday/canvas-kit-labs-react-pagination@workday/canvas-kit-labs-react-segmented-control@workday/canvas-kit-labs-react-color-picker@workday/canvas-kit-labs-react-combobox@workday/canvas-kit-labs-react-core@workday/canvas-kit-labs-react-header@workday/canvas-kit-labs-react-drawer@workday/canvas-kit-react-form-field@workday/canvas-kit-react-header@workday/canvas-kit-react-popup@workday/canvas-kit-react-radio@workday/canvas-kit-react-segmented-control@workday/canvas-kit-react-skeleton@workday/canvas-kit-react-status-indicator@workday/canvas-kit-react-switch@workday/canvas-kit-react-table@workday/canvas-kit-react-text-area@workday/canvas-kit-react-page-header@workday/canvas-kit-react-icon@workday/canvas-kit-react-layout@workday/canvas-kit-react-loading-animation@workday/canvas-kit-react-menu@workday/canvas-kit-react-text-input@workday/canvas-kit-react-toast@workday/canvas-kit-react-tooltip@workday/canvas-kit-react-select@workday/canvas-kit-react-side-panel@workday/canvas-kit-react-action-bar@workday/canvas-kit-react-avatar@workday/canvas-kit-react-badge@workday/canvas-kit-react-banner@workday/canvas-kit-react-button@workday/canvas-kit-react-card@workday/canvas-kit-react-checkbox@workday/canvas-kit-react-color-picker@workday/canvas-kit-react-common@workday/canvas-kit-react-cookie-banner
4.8.3

3 years ago

4.8.2

3 years ago

4.8.1

3 years ago

4.8.0

3 years ago

4.7.1-next.18

3 years ago

4.7.1-next.14

3 years ago

4.7.1-next.15

3 years ago

4.7.1-next.16

3 years ago

4.7.1-next.0

3 years ago

4.7.1-next.1

3 years ago

4.7.1-next.2

3 years ago

4.7.1-next.3

3 years ago

4.7.1-next.4

3 years ago

4.7.1-next.5

3 years ago

4.7.1-next.6

3 years ago

4.7.1-next.7

3 years ago

4.7.1-next.8

3 years ago

4.7.1-next.9

3 years ago

4.7.1-next.10

3 years ago

4.7.1-next.11

3 years ago

4.7.1-next.12

3 years ago

4.7.0

3 years ago

4.6.1-next.3

3 years ago

4.6.1-next.2

3 years ago

4.6.1-next.0

3 years ago

4.6.1-next.1

3 years ago

4.6.0

3 years ago

4.5.2-next.3

3 years ago

4.5.2-next.2

3 years ago

4.5.2-next.1

3 years ago

4.5.2-next.0

3 years ago

4.5.1

3 years ago

4.5.1-next.3

3 years ago

4.5.1-next.2

3 years ago

4.5.1-next.1

3 years ago

4.5.1-next.4

3 years ago

4.5.1-next.0

3 years ago

4.5.0

3 years ago

4.4.3-next.15

3 years ago

4.4.3-next.17

3 years ago

4.4.3-next.16

3 years ago

4.4.3-next.18

3 years ago

4.4.3-next.14

3 years ago

4.4.3-next.13

3 years ago

4.4.3-next.12

3 years ago

4.4.3-next.11

3 years ago

5.0.0-beta.0

3 years ago

4.4.3-next.10

3 years ago

4.4.3-next.9

3 years ago

4.4.3-next.8

3 years ago

4.4.3-next.7

3 years ago

4.4.3-next.6

3 years ago

4.4.3-next.5

3 years ago

4.4.3-next.4

3 years ago

4.4.3-next.3

3 years ago

4.4.3-next.0

3 years ago

4.4.3-next.1

3 years ago

4.4.2

3 years ago

4.4.2-next.4

3 years ago

4.4.2-next.3

3 years ago

4.4.2-next.2

3 years ago

4.4.1-next.4

3 years ago

4.4.1

3 years ago

4.4.1-next.3

3 years ago

4.4.1-next.2

3 years ago

4.4.1-next.1

3 years ago

4.4.1-next.0

3 years ago

4.4.0

3 years ago

4.3.2-next.6

3 years ago

4.3.2-next.4

3 years ago

4.3.2-next.3

3 years ago

4.3.2-next.5

3 years ago

4.3.2-next.2

3 years ago

4.3.2-next.1

3 years ago

4.3.2-next.0

3 years ago

4.3.1

4 years ago

4.3.1-next.4

4 years ago

4.3.1-next.2

4 years ago

4.3.1-next.3

4 years ago

4.3.1-next.1

4 years ago

4.3.1-next.0

4 years ago

4.3.0

4 years ago

4.1.3-next.28

4 years ago

4.1.3-next.27

4 years ago

4.1.3-next.26

4 years ago

4.1.3-next.25

4 years ago

4.1.3-next.24

4 years ago

4.1.3-next.23

4 years ago

4.1.3-next.22

4 years ago

4.1.3-next.20

4 years ago

4.1.3-next.21

4 years ago

4.1.3-next.17

4 years ago

4.1.3-next.18

4 years ago

4.1.3-next.16

4 years ago

4.2.0

4 years ago

4.1.3-next.15

4 years ago

4.1.3-next.13

4 years ago

4.1.3-next.12

4 years ago

4.1.3-next.10

4 years ago

4.1.3-next.11

4 years ago

4.1.3-next.9

4 years ago

4.1.3-next.8

4 years ago

4.1.3-next.6

4 years ago

4.1.3-next.7

4 years ago

4.1.3-next.4

4 years ago

4.1.3-next.2

4 years ago

4.1.3-next.3

4 years ago

4.1.3-next.0

4 years ago

4.1.3-next.1

4 years ago

4.0.3

4 years ago

4.1.2

4 years ago

4.1.2-next.0

4 years ago

4.0.2

4 years ago

4.1.1

4 years ago

4.1.1-next.5

4 years ago

4.1.1-next.4

4 years ago

4.1.1-next.0

4 years ago

4.1.1-next.3

4 years ago

4.1.1-next.2

4 years ago

4.1.0

4 years ago

4.0.1-next.19

4 years ago

4.0.1-next.18

4 years ago

4.0.1-next.17

4 years ago

4.0.1-next.16

4 years ago

4.0.1-next.15

4 years ago

4.0.1-next.14

4 years ago

4.0.1

4 years ago

3.9.1

4 years ago

4.0.1-next.12

4 years ago

4.0.1-next.11

4 years ago

4.0.1-next.10

4 years ago

4.0.1-next.9

4 years ago

4.0.1-next.7

4 years ago

4.0.1-next.8

4 years ago

4.0.1-next.6

4 years ago

4.0.1-next.5

4 years ago

4.0.1-next.4

4 years ago

4.0.1-next.3

4 years ago

4.0.1-next.2

4 years ago

4.0.1-next.1

4 years ago

4.0.1-next.0

4 years ago

3.8.1-next.17

4 years ago

4.0.0

4 years ago

3.9.0

4 years ago

3.8.1-next.16

4 years ago

4.0.0-beta.5

4 years ago

3.8.1-next.15

4 years ago

3.8.1-next.14

4 years ago

3.8.1-next.13

4 years ago

3.8.1-next.12

4 years ago

3.8.1-next.11

4 years ago

3.8.1-next.10

4 years ago

3.8.1-next.7

4 years ago

3.8.1-next.8

4 years ago

3.8.1-next.9

4 years ago

3.8.1-next.6

4 years ago

3.8.1-next.5

4 years ago

3.8.1-next.3

4 years ago

3.8.1-next.4

4 years ago

3.8.1-next.2

4 years ago

3.8.1-next.0

4 years ago

3.8.1-next.1

4 years ago

3.8.0

4 years ago

3.7.1-next.7

4 years ago

3.7.1-next.8

4 years ago

3.7.1-next.6

4 years ago

3.7.1-next.3

4 years ago

3.7.1-next.4

4 years ago

3.7.1-next.5

4 years ago

4.0.0-beta.4

4 years ago

3.7.1-next.2

4 years ago

3.7.1-next.0

4 years ago

4.0.0-beta.3

4 years ago

4.0.0-beta.2

4 years ago

3.6.1-next.14

4 years ago

3.7.0

4 years ago

3.6.1-next.13

4 years ago

3.6.1-next.12

4 years ago

3.6.1-next.11

4 years ago

3.6.1-next.10

4 years ago

3.6.1-next.9

4 years ago

3.6.1-next.8

4 years ago

3.6.1-next.7

4 years ago

3.6.1-next.6

4 years ago

3.6.1-next.5

4 years ago

3.6.1-next.4

4 years ago

3.6.1-next.3

4 years ago

3.6.1-next.2

4 years ago

3.6.1-next.1

4 years ago

3.6.1-next.0

4 years ago

4.0.0-beta.1

4 years ago

3.5.1-next.10

4 years ago

3.6.0

4 years ago

3.4.1

4 years ago

3.5.1-next.9

4 years ago

3.5.1-next.8

4 years ago

4.0.0-beta.0

4 years ago

3.5.1-next.7

4 years ago

3.5.1-next.6

4 years ago

3.5.1-next.5

4 years ago

3.5.1-next.4

4 years ago

3.5.1-next.1

4 years ago

3.5.1-next.2

4 years ago

3.5.1-next.3

4 years ago

3.5.1-next.0

4 years ago

3.5.0

4 years ago

3.4.1-next.17

4 years ago

3.4.1-next.16

4 years ago

3.4.1-next.15

4 years ago

3.4.1-next.14

4 years ago

3.4.1-next.13

4 years ago

3.4.1-next.12

4 years ago

3.4.1-next.11

4 years ago

3.4.1-next.10

4 years ago

3.4.1-next.8

4 years ago

3.4.1-next.9

4 years ago

3.4.1-next.6

4 years ago

3.4.1-next.7

4 years ago

3.4.1-next.4

4 years ago

3.4.1-next.5

4 years ago

3.4.1-next.3

4 years ago

3.4.1-next.2

4 years ago

3.4.1-next.0

4 years ago

3.4.1-next.1

4 years ago

3.3.3-next.31

4 years ago

3.4.0

4 years ago

3.3.3-next.30

4 years ago

3.3.3-next.29

4 years ago

3.3.3-next.28

4 years ago

3.3.3-next.26

4 years ago

3.3.3-next.27

4 years ago

3.3.3-next.25

4 years ago

3.3.3-next.21

4 years ago

3.3.3-next.19

4 years ago

3.3.3-next.18

4 years ago

3.3.3-next.15

4 years ago

3.3.3-next.14

4 years ago

3.3.3-next.17

4 years ago

3.3.3-next.16

4 years ago

3.2.0

4 years ago

3.1.0

4 years ago

3.0.0

5 years ago

3.0.0-beta.1

5 years ago

3.0.0-beta.0

5 years ago

3.0.0-alpha.7

5 years ago

3.0.0-alpha.6

5 years ago

3.0.0-alpha.5

5 years ago

3.0.0-alpha.4

5 years ago

3.0.0-alpha.3

5 years ago

3.0.0-alpha.2

5 years ago

3.0.0-alpha.1

5 years ago