Skip to content

Commit

Permalink
Merge branch 'main' into release/v11.4.0-rc.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblack authored May 24, 2022
2 parents f37537e + 5175c28 commit 6e276d6
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 7 deletions.
64 changes: 64 additions & 0 deletions packages/react/src/components/IconButton/IconButton.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { ArgsTable, Canvas, Story } from '@storybook/addon-docs';

# IconButton

[Source
code](https://github.com/carbon-design-system/carbon/tree/main/packages/react/src/components/IconButton)
 | 
[Usage guidelines](https://www.carbondesignsystem.com/components/button/usage)

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

## Table of Contents

- [Overview](#overview)
- [Component API](#component-api)
- [Feedback](#feedback)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Overview

The `IconButton` component is useful when you have a button where the
content is an icon. In this situation, it's important that the button itself is
labeled in a way that can be understandable by mouse, keyboard, and screen
readers. As a result, this component makes it easy to create accessible icon buttons

```jsx
import { IconButton } from '@carbon/react';
import { Add } from '@carbon/react/icons';

function ExampleComponent() {
return (
<IconButton label="Add">
<Add />
</IconButton>
);
}
```

## Alignment

The `align` prop allows you to specify where your content should be placed
relative to the `IconButton`. For example, if you provide `align="top"` to the
`IconButton` component then the tooltip will render above your component.
Similarly, if you provide `align="bottom"` then the tooltip will render below
your component.

## Customizing the label

You can customize the label, or tooltip, of the `IconButton` with the `label`
prop. However, it's important that this label contain no interactive content so
that the component remains accessible.

## Component API

<ArgsTable />

## Feedback

Help us improve this component by providing feedback, asking questions on Slack,
or updating this file on
[GitHub](https://github.com/carbon-design-system/carbon/edit/main/packages/react/src/components/IconButton/IconButton.mdx).

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import { Edit } from '@carbon/icons-react';
import React from 'react';
import { IconButton } from '../';
import { IconButton } from '../IconButton';
import mdx from './IconButton.mdx';

export default {
title: 'Components/IconButton',
Expand All @@ -16,6 +17,9 @@ export default {
controls: {
hideNoControlsWarning: true,
},
docs: {
page: mdx,
},
layout: 'centered',
},
argTypes: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/IconButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const IconButton = React.forwardRef(function IconButton(props, ref) {
kind={kind}
ref={ref}
size={size}
className={cx(`${prefix}--btn--icon-only`, { [className]: className })}>
className={cx(`${prefix}--btn--icon-only`, className)}>
{children}
</Button>
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function StructuredListWrapper(props) {
return (
<GridSelectedRowStateContext.Provider value={selectedRow}>
<GridSelectedRowDispatchContext.Provider value={setSelectedRow}>
<div role="grid" className={classes} {...other} aria-label={ariaLabel}>
<div role="table" className={classes} {...other} aria-label={ariaLabel}>
{children}
</div>
</GridSelectedRowDispatchContext.Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ example:

Help us improve this component by providing feedback, asking questions on Slack,
or updating this file on
[GitHub](https://github.com/carbon-design-system/carbon/edit/main/packages/react/src/components/Toggletip/next/Toggletip.mdx).
[GitHub](https://github.com/carbon-design-system/carbon/edit/main/packages/react/src/components/Toggletip/Toggletip.mdx).
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

import { Information } from '@carbon/icons-react';
import React from 'react';
import { default as Button } from '../../Button';
import { default as Link } from '../../Link';
import { default as Button } from '../Button';
import { default as Link } from '../Link';
import {
ToggletipLabel,
Toggletip,
ToggletipButton,
ToggletipContent,
ToggletipActions,
} from '../../Toggletip';
} from '../Toggletip';
import mdx from './Toggletip.mdx';

export default {
Expand Down
10 changes: 10 additions & 0 deletions packages/styles/scss/__tests__/type-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,27 @@ describe('@carbon/styles/scss/type', () => {
reset: meta.mixin-exists('reset', 'type'),
type-style: meta.mixin-exists('type-style', 'type'),
font-family: meta.mixin-exists('font-family', 'type'),
font-weight: meta.mixin-exists('font-family', 'type'),
default-type: meta.mixin-exists('default-type', 'type'),
type-classes: meta.mixin-exists('type-classes', 'type'),
),
functions: (
font-weight: meta.function-exists('font-family', 'type'),
),
));
`);

const { value: api } = get('api');
expect(api.functions).toEqual({
'font-weight': true,
});
expect(api.mixins).toEqual({
reset: true,
'type-style': true,
'font-family': true,
'default-type': true,
'type-classes': true,
'font-weight': true,
});
expect(api.variables).toMatchInlineSnapshot(`
Array [
Expand Down Expand Up @@ -73,6 +81,8 @@ describe('@carbon/styles/scss/type', () => {
"display-02",
"display-03",
"display-04",
"font-families",
"font-weights",
"tokens",
]
`);
Expand Down
3 changes: 3 additions & 0 deletions packages/styles/scss/type/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
font-family,
default-type,
type-classes,
font-weight,

// Variables
$caption-01,
Expand Down Expand Up @@ -46,6 +47,8 @@
$display-02,
$display-03,
$display-04,
$font-families,
$font-weights,
$tokens;

@use '@carbon/type';
Expand Down

0 comments on commit 6e276d6

Please sign in to comment.