Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(Theme): update Theme docs with new guidance/usage #2998

Merged
merged 15 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions src/pages/components/number-input/accessibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,48 @@ standard number input component, Carbon already incorporates accessibility.
</AnchorLinks>

## What Carbon provides
Carbon bakes keyboard operation into its components, improving the experience of blind users and others who operate via the keyboard. Carbon incorporates many other accessibility considerations, some of which are described below.

Carbon bakes keyboard operation into its components, improving the experience of
blind users and others who operate via the keyboard. Carbon incorporates many
other accessibility considerations, some of which are described below.

### Keyboard interaction

The Carbon number input replicates the behavior of the stock HTML component. The number input takes a single tab stop. The + and - buttons, operable by pointer, are not in the tab order. When the input has focus, the arrow keys give keyboard users the same ability to incrementally adjust the values. As well, users can directly type numeric values in the input. Only numerals are allowed to be entered.
The Carbon number input replicates the behavior of the stock HTML component. The
number input takes a single tab stop. The + and - buttons, operable by pointer,
are not in the tab order. When the input has focus, the arrow keys give keyboard
users the same ability to incrementally adjust the values. As well, users can
directly type numeric values in the input. Only numerals are allowed to be
entered.

<Row>
<Column colLg={8}>

![example of number input keyboard interaction](images/number-input-accessibility-1.png)

<Caption>
The number input is reachable by Tab and changed with the arrow keys or by directly entering a number.
The number input is reachable by Tab and changed with the arrow keys or by
directly entering a number.
</Caption>

</Column>
</Row>

### Error handling
Carbon provides errors and warning messages to assistive technology. This is an improvement on the stock HTML number input, which simply prevents the typing of alphabetic characters without explanation. Carbon also adds an error or warning icon and puts error messages in red as a further visual cue.

Carbon provides errors and warning messages to assistive technology. This is an
improvement on the stock HTML number input, which simply prevents the typing of
alphabetic characters without explanation. Carbon also adds an error or warning
icon and puts error messages in red as a further visual cue.

<Row>
<Column colLg={8}>

![The letter e is in the input, a red exclamation mark appears beside it, the border of the input is in red and a red text message appears underneath 'Number is not valid'](images/number-input-accessibility-2.png)

<Caption>
Messages are surfaced to assistive technologies, and color alone is not used to visually signal errors.
Messages are surfaced to assistive technologies, and color alone is not used
to visually signal errors.
</Caption>

</Column>
Expand All @@ -71,16 +85,21 @@ Carbon provides errors and warning messages to assistive technology. This is an
Design annotations are needed for the following instance.

### Cue users for value and step
Carbon offers the ability for the author to set minimum and maximum values for the input. When setting limits on number entry, designers should warn the user in advance, instead of users discovering limits through an error message. This is particularly the case if designers alter the step value, which determines the increment change when activating the +/- buttons or arrow keys. If a user directly enters a value that does not match the step increment, it will be disallowed for no apparent reason, so advanced warnings are crucial.

Carbon offers the ability for the author to set minimum and maximum values for
the input. When setting limits on number entry, designers should warn the user
in advance, instead of users discovering limits through an error message. This
is particularly the case if designers alter the step value, which determines the
increment change when activating the +/- buttons or arrow keys. If a user
directly enters a value that does not match the step increment, it will be
disallowed for no apparent reason, so advanced warnings are crucial.

<Row>
<Column colLg={8}>

![a numeric input with helper text to enter values between 30 and 70, in increments of 5](images/number-input-accessibility-3.png)

<Caption>
Notify users of allowable input ranges through helper text.
</Caption>
<Caption>Notify users of allowable input ranges through helper text.</Caption>

</Column>
</Row>
Expand All @@ -89,5 +108,7 @@ Carbon offers the ability for the author to set minimum and maximum values for t

Keep this in mind if you’re modifying Carbon or creating a custom component.

- Carbon uses `aria-describedby` to associate the helper text and error messages with the input.
- The red error SVG icons have `aria-hidden="true"` set, since the helper text provides the same information.
- Carbon uses `aria-describedby` to associate the helper text and error messages
with the input.
- The red error SVG icons have `aria-hidden="true"` set, since the helper text
provides the same information.
6 changes: 3 additions & 3 deletions src/pages/designing/kits/figma.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ There are four Carbon v10 theme libraries, two light (White and Gray 10) and two
dark (Gray 90 and Gray 100). Each theme lives in its own Figma library. You can
turn on as many libraries as you’d like.

If you are using Carbon v11, the `(v11 BETA) White Theme` library and `v11 Text
Styles` library are now available. The other v11 theme libraries will be
available in Figma at the end of July 2022.
If you are using Carbon v11, the `(v11 BETA) White Theme` library and
`v11 Text Styles` library are now available. The other v11 theme libraries will
be available in Figma at the end of July 2022.

Inside of a design file, navigate to the **Main menu** panel in the top left of
the toolbar (A). Open the menu and select **Libraries** from the list (B).
Expand Down
41 changes: 28 additions & 13 deletions src/pages/guidelines/themes/code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ building.

<AnchorLinks>

<AnchorLink>Get started</AnchorLink>
<AnchorLink>Usage</AnchorLink>
<AnchorLink>Get started</AnchorLink> <AnchorLink>Usage</AnchorLink>
<AnchorLink>Resources</AnchorLink>

</AnchorLinks>
Expand All @@ -49,29 +48,37 @@ yarn add @carbon/themes

## Usage

You can use `@carbon/themes` in JavaScript or Sass by including this package in
your project. By default, `@carbon/themes` provides a set of color tokens that
are pre-defined for a specific theme. Currently, we offer the following color
themes: white, gray 10, gray 90, gray 100 .
There are three ways to utilize Carbon Themes. First, and maybe the simplest way
is to bring in our
[`<Theme>`](https://react.carbondesignsystem.com/?path=/story/components-theme--default)
component and pass your desired theme as a prop. Second, if you need more
dakahn marked this conversation as resolved.
Show resolved Hide resolved
granular control of where themes are applied or access to specific theming
tokens when and you're using `@carbon/styles` or `@carbon/react` you already
have access to sass theming with no need for an extra package. Lastly, you can
use `@carbon/themes` in JavaScript or Sass by including this package in your
project.

By default, `@carbon/themes` provides a set of color tokens that are pre-defined
for a specific theme. Currently, we offer the following color themes: white,
gray 10, gray 90, gray 100 .

You can preview all of the token values for this on the
[Carbon Design System website](https://www.carbondesignsystem.com/guidelines/color/usage)
.
[color guidelines](/guidelines/color/usage) page.

### Sass

If your project is using Sass, you can include this package and the
corresponding default theme by writing the following in your Sass file:

```scss
@import '@carbon/themes/scss/themes';
@use '@carbon/themes/scss/themes';
```

By default, the white theme will be initialized. If you would like to include
another theme, you can do so by calling our mixin. For example:

```scss
@import '@carbon/themes/scss/themes';
@use '@carbon/themes/scss/themes';

// Use the gray 10 theme
@include theme($theme--g10);
Expand All @@ -87,7 +94,7 @@ Alternatively, you can set the global theme variable then call the mixin without
passing in a theme name.

```scss
@import '@carbon/themes/scss/themes';
@use '@carbon/themes/scss/themes';

$theme: $theme--g10;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This usage is outdated, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it? I thought that's how you accessed the theming tokens, but I'd bet i'm definitely wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought that was how we still brought in themes for custom work? but I could just be doing it wrong


Expand All @@ -98,7 +105,7 @@ $theme: $theme--g10;
Inline theming can be done by using the mixin. For example:

```scss
@import '@carbon/themes/scss/themes';
@use '@carbon/themes/scss/themes';

// Use the default white theme here

Expand All @@ -115,6 +122,14 @@ Inline theming can be done by using the mixin. For example:
}
```

Themes can be configured by accessing the tokens in the import statement. For
example:

```scss
@use '@carbon/react/scss/themes';
@use '@carbon/react/scss/theme' with ($theme: themes.$g100);
```

### JavaScript

If you're looking to use these themes in JavaScript, we export a variety of
Expand Down Expand Up @@ -143,7 +158,7 @@ import {
<Column colMd={4} colLg={4} noGutterSm>
<ResourceCard
subTitle="Carbon theme package"
href="https://github.com/carbon-design-system/carbon/blob/v10/packages/themes"
href="https://github.com/carbon-design-system/carbon/tree/main/packages/themes"
>

<MdxIcon name="bee" />
Expand Down