Skip to content

Commit

Permalink
Merge branch 'main' into timepicker-size-audit
Browse files Browse the repository at this point in the history
  • Loading branch information
sstrubberg authored Mar 15, 2022
2 parents 1dc3969 + f308fd7 commit 12e2271
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 16 deletions.
6 changes: 6 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3341,6 +3341,9 @@ Map {
"role": Object {
"type": "string",
},
"tabIndex": Object {
"type": "number",
},
},
"render": [Function],
},
Expand Down Expand Up @@ -6201,6 +6204,9 @@ Map {
"className": Object {
"type": "string",
},
"tabIndex": Object {
"type": "number",
},
},
"render": [Function],
},
Expand Down
7 changes: 5 additions & 2 deletions packages/react/src/components/TreeView/TreeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import classNames from 'classnames';
import { settings } from 'carbon-components';
import { keys, match, matches } from '../../internal/keyboard';
import uniqueId from '../../tools/uniqueId';
import * as FeatureFlags from '@carbon/feature-flags';

const { prefix } = settings;

Expand All @@ -23,7 +24,7 @@ export default function TreeView({
multiselect,
onSelect,
selected: preselected = [],
size = 'default',
size = FeatureFlags.enabled('enable-v11-release') ? 'sm' : 'default',
...rest
}) {
const { current: treeId } = useRef(rest.id || uniqueId());
Expand Down Expand Up @@ -219,5 +220,7 @@ TreeView.propTypes = {
/**
* Specify the size of the tree from a list of available sizes.
*/
size: PropTypes.oneOf(['default', 'compact']),
size: FeatureFlags.enabled('enable-v11-release')
? PropTypes.oneOf(['xs', 'sm'])
: PropTypes.oneOf(['default', 'compact']),
};
36 changes: 25 additions & 11 deletions packages/react/src/components/TreeView/next/Treeview.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,26 @@ function renderTree({ nodes, expanded, withIcons = false }) {
export default {
title: 'Experimental/unstable_TreeView',
component: TreeView,
argTypes: {
size: {
options: ['xs', 'sm'],
control: { type: 'select' },
},
},
args: {
size: 'sm',
},
};

export const Default = () => (
export const Default = (args) => (
<>
<InlineNotification
kind="info"
title="Experimental component"
subtitle="An accessibility review of this component is in progress"
/>
<TreeView {...props()}>{renderTree({ nodes })}</TreeView>
<InlineNotification kind="info">
Experimental component: An accessibility review of this component is in
progress
</InlineNotification>
<TreeView {...props()} {...args}>
{renderTree({ nodes })}
</TreeView>
</>
);

Expand All @@ -212,20 +222,22 @@ Default.parameters = {
},
};

export const WithIcons = () => (
export const WithIcons = (args) => (
<>
<InlineNotification
kind="info"
title="Experimental component"
subtitle="An accessibility review of this component is in progress"
/>
<TreeView {...props()}>{renderTree({ nodes, withIcons: true })}</TreeView>
<TreeView {...props()} {...args}>
{renderTree({ nodes, withIcons: true })}
</TreeView>
</>
);

WithIcons.storyName = 'with icons';

export const WithControlledExpansion = () => {
export const WithControlledExpansion = (args) => {
const [expanded, setExpanded] = useState(undefined);
return (
<>
Expand All @@ -242,7 +254,9 @@ export const WithControlledExpansion = () => {
collapse all
</button>
</div>
<TreeView {...props()}>{renderTree({ nodes, expanded })}</TreeView>
<TreeView {...props()} {...args}>
{renderTree({ nodes, expanded })}
</TreeView>
</>
);
};
8 changes: 7 additions & 1 deletion packages/react/src/components/UIShell/HeaderMenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const HeaderMenuItem = React.forwardRef(function HeaderMenuItem(
'aria-current': ariaCurrent,
children,
role,
tabIndex = 0,
...rest
},
ref
Expand All @@ -38,7 +39,7 @@ const HeaderMenuItem = React.forwardRef(function HeaderMenuItem(
aria-current={ariaCurrent}
className={linkClassName}
ref={ref}
tabIndex={0}>
tabIndex={tabIndex}>
<span className={`${prefix}--text-truncate--end`}>{children}</span>
</Link>
</li>
Expand Down Expand Up @@ -74,6 +75,11 @@ HeaderMenuItem.propTypes = {
* `<ul>` semantics for menus.
*/
role: PropTypes.string,

/**
* Specify the tab index of the Link
*/
tabIndex: PropTypes.number,
};

export default HeaderMenuItem;
8 changes: 7 additions & 1 deletion packages/react/src/components/UIShell/SwitcherItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const SwitcherItem = React.forwardRef(function SwitcherItem(props, ref) {
className: customClassName,
children,
isSelected,
tabIndex = 0,
...rest
} = props;

Expand All @@ -42,7 +43,7 @@ const SwitcherItem = React.forwardRef(function SwitcherItem(props, ref) {
{...rest}
ref={ref}
className={linkClassName}
tabIndex={0}
tabIndex={tabIndex}
{...accessibilityLabel}>
{children}
</Link>
Expand All @@ -66,6 +67,11 @@ SwitcherItem.propTypes = {
* Optionally provide a custom class to apply to the underlying `<li>` node
*/
className: PropTypes.string,

/**
* Specify the tab index of the Link
*/
tabIndex: PropTypes.number,
};

export default SwitcherItem;
2 changes: 1 addition & 1 deletion packages/styles/scss/components/treeview/_treeview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
}
}

.#{$prefix}--tree--compact .#{$prefix}--tree-node__label {
.#{$prefix}--tree--xs .#{$prefix}--tree-node__label {
min-height: rem(24px);
}
}

0 comments on commit 12e2271

Please sign in to comment.