Skip to content

Commit

Permalink
chore(TreeView): updated size props (#10970)
Browse files Browse the repository at this point in the history
* chore(TreeView): updated size props

* Update packages/react/src/components/TreeView/next/Treeview.stories.js

Co-authored-by: Taylor Jones <tay1orjones@users.noreply.github.com>

Co-authored-by: Taylor Jones <tay1orjones@users.noreply.github.com>
  • Loading branch information
sstrubberg and tay1orjones authored Mar 14, 2022
1 parent 4c12ad5 commit f308fd7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
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>
</>
);
};
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 f308fd7

Please sign in to comment.