Skip to content

Commit f308fd7

Browse files
chore(TreeView): updated size props (#10970)
* 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>
1 parent 4c12ad5 commit f308fd7

3 files changed

Lines changed: 31 additions & 14 deletions

File tree

packages/react/src/components/TreeView/TreeView.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import classNames from 'classnames';
1111
import { settings } from 'carbon-components';
1212
import { keys, match, matches } from '../../internal/keyboard';
1313
import uniqueId from '../../tools/uniqueId';
14+
import * as FeatureFlags from '@carbon/feature-flags';
1415

1516
const { prefix } = settings;
1617

@@ -23,7 +24,7 @@ export default function TreeView({
2324
multiselect,
2425
onSelect,
2526
selected: preselected = [],
26-
size = 'default',
27+
size = FeatureFlags.enabled('enable-v11-release') ? 'sm' : 'default',
2728
...rest
2829
}) {
2930
const { current: treeId } = useRef(rest.id || uniqueId());
@@ -219,5 +220,7 @@ TreeView.propTypes = {
219220
/**
220221
* Specify the size of the tree from a list of available sizes.
221222
*/
222-
size: PropTypes.oneOf(['default', 'compact']),
223+
size: FeatureFlags.enabled('enable-v11-release')
224+
? PropTypes.oneOf(['xs', 'sm'])
225+
: PropTypes.oneOf(['default', 'compact']),
223226
};

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,26 @@ function renderTree({ nodes, expanded, withIcons = false }) {
192192
export default {
193193
title: 'Experimental/unstable_TreeView',
194194
component: TreeView,
195+
argTypes: {
196+
size: {
197+
options: ['xs', 'sm'],
198+
control: { type: 'select' },
199+
},
200+
},
201+
args: {
202+
size: 'sm',
203+
},
195204
};
196205

197-
export const Default = () => (
206+
export const Default = (args) => (
198207
<>
199-
<InlineNotification
200-
kind="info"
201-
title="Experimental component"
202-
subtitle="An accessibility review of this component is in progress"
203-
/>
204-
<TreeView {...props()}>{renderTree({ nodes })}</TreeView>
208+
<InlineNotification kind="info">
209+
Experimental component: An accessibility review of this component is in
210+
progress
211+
</InlineNotification>
212+
<TreeView {...props()} {...args}>
213+
{renderTree({ nodes })}
214+
</TreeView>
205215
</>
206216
);
207217

@@ -212,20 +222,22 @@ Default.parameters = {
212222
},
213223
};
214224

215-
export const WithIcons = () => (
225+
export const WithIcons = (args) => (
216226
<>
217227
<InlineNotification
218228
kind="info"
219229
title="Experimental component"
220230
subtitle="An accessibility review of this component is in progress"
221231
/>
222-
<TreeView {...props()}>{renderTree({ nodes, withIcons: true })}</TreeView>
232+
<TreeView {...props()} {...args}>
233+
{renderTree({ nodes, withIcons: true })}
234+
</TreeView>
223235
</>
224236
);
225237

226238
WithIcons.storyName = 'with icons';
227239

228-
export const WithControlledExpansion = () => {
240+
export const WithControlledExpansion = (args) => {
229241
const [expanded, setExpanded] = useState(undefined);
230242
return (
231243
<>
@@ -242,7 +254,9 @@ export const WithControlledExpansion = () => {
242254
collapse all
243255
</button>
244256
</div>
245-
<TreeView {...props()}>{renderTree({ nodes, expanded })}</TreeView>
257+
<TreeView {...props()} {...args}>
258+
{renderTree({ nodes, expanded })}
259+
</TreeView>
246260
</>
247261
);
248262
};

packages/styles/scss/components/treeview/_treeview.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
}
172172
}
173173

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

0 commit comments

Comments
 (0)