Skip to content

Commit da96e87

Browse files
authored
Updating expandable rows TableView and InlineAlert chromatic stories (#4852)
* updating expandable table row and inline chromatic stories * fixing selectedKeys and disabledKeys
1 parent caab221 commit da96e87

File tree

3 files changed

+114
-24
lines changed

3 files changed

+114
-24
lines changed

packages/@react-spectrum/inlinealert/chromatic/InlineAlert.chromatic.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {Content, Header} from '@react-spectrum/view';
13+
import {Content} from '@react-spectrum/view';
14+
import {Heading} from '@react-spectrum/text';
1415
import {InlineAlert} from '../';
1516
import {Meta} from '@storybook/react';
1617
import React from 'react';
@@ -27,7 +28,7 @@ export const Default = {
2728
args: {
2829
children: (
2930
<>
30-
<Header>In-line Alert Header</Header>
31+
<Heading>In-line Alert Heading</Heading>
3132
<Content>This is a React Spectrum InlineAlert</Content>
3233
</>
3334
)
@@ -39,7 +40,7 @@ export const Informative = {
3940
variant: 'info',
4041
children: (
4142
<>
42-
<Header>In-Line Alert Informative Header</Header>
43+
<Heading>In-Line Alert Informative Heading</Heading>
4344
<Content>This is a React Spectrum InlineAlert</Content>
4445
</>
4546
)
@@ -51,7 +52,7 @@ export const Positive = {
5152
variant: 'positive',
5253
children: (
5354
<>
54-
<Header>In-Line Alert Positive Header</Header>
55+
<Heading>In-Line Alert Positive Heading</Heading>
5556
<Content>This is a React Spectrum InlineAlert</Content>
5657
</>
5758
)
@@ -63,7 +64,7 @@ export const Notice = {
6364
variant: 'notice',
6465
children: (
6566
<>
66-
<Header>In-Line Alert Notice Header</Header>
67+
<Heading>In-Line Alert Notice Heading</Heading>
6768
<Content>This is a React Spectrum InlineAlert</Content>
6869
</>
6970
)
@@ -75,7 +76,7 @@ export const Negative = {
7576
variant: 'negative',
7677
children: (
7778
<>
78-
<Header>In-Line Alert Negative Header</Header>
79+
<Heading>In-Line Alert Negative Heading</Heading>
7980
<Content>This is a React Spectrum InlineAlert</Content>
8081
</>
8182
)
@@ -89,7 +90,7 @@ export const LongContent = {
8990
render: (args) => (
9091
<div style={{width: '300px'}}>
9192
<InlineAlert {...args}>
92-
<Header>In-line Alert Header that goes on and on my friend</Header>
93+
<Heading>In-line Alert Heading that goes on and on my friend</Heading>
9394
<Content>This is a React Spectrum InlineAlert that started announcing without knowing what it was. This is the inline alert that doesn't end. Yes, it goes on and on, my friend.</Content>
9495
</InlineAlert>
9596
</div>

packages/@react-spectrum/table/chromatic/TreeGridTable.chromatic.tsx

Lines changed: 93 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ let states = [
2929
{overflowMode: 'wrap'},
3030
{selectionMode: ['multiple', 'single']},
3131
{density: ['compact', 'spacious']},
32-
{defaultExpandedKeys: [[], 'all', ['Lvl 1 Foo 1', 'Lvl 2 Foo 1']]}
32+
{UNSTABLE_expandedKeys: [['Lvl 1 Foo 1'], 'all']}
3333
];
3434

3535
let combinations = generatePowerset(states);
36+
let chunkSize = Math.ceil(combinations.length / 3);
37+
let combo1 = combinations.slice(0, chunkSize);
38+
let combo2 = combinations.slice(chunkSize, chunkSize * 2);
39+
let combo3 = combinations.slice(chunkSize * 2, chunkSize * 3);
3640

3741
function shortName(key, value) {
3842
let returnVal = '';
@@ -116,16 +120,16 @@ let nestedItems = [
116120
]}
117121
];
118122

119-
const Template = ({columns, items, ...args}) => (
123+
const Template = ({combos, columns, items, ...args}) => (
120124
<Grid columns={repeat(3, '1fr')} autoFlow="row" gap="size-300">
121-
{combinations.map(c => {
125+
{combos.map(c => {
122126
let key = Object.keys(c).map(k => shortName(k, c[k])).join(' ');
123127
if (!key) {
124128
key = 'empty';
125129
}
126130
return (
127131
<View flexGrow={1} maxWidth="size-5000" maxHeight={700}>
128-
<TableView {...args} {...c} width="100%" height="100%" key={key} aria-label={key} selectedKeys={['Foo 3', 'Foo 1']} disabledKeys={['Foo 2', 'Foo 4']} UNSTABLE_allowsExpandableRows>
132+
<TableView {...args} {...c} width="100%" height="100%" key={key} aria-label={key} selectedKeys={['Lvl 1 Foo 1', 'Lvl 3 Foo 1']} disabledKeys={['Lvl 2 Foo 1', 'Lvl 2 Foo 2']} UNSTABLE_allowsExpandableRows>
129133
<TableHeader columns={columns}>
130134
{(column: any) => (
131135
<Column key={column.key} width={column.width} showDivider={column.showDivider} align={column.align} hideHeader={column.hideHeader} childColumns={column.children}>
@@ -182,40 +186,113 @@ const EmptyTemplate = (args) =>
182186

183187
export const Default = {
184188
render: Template,
185-
name: 'default items and columns',
186-
args: {columns, items: nestedItems}
189+
name: 'default items and columns 1 of 3',
190+
args: {combos: combo1, columns, items: nestedItems}
191+
};
192+
193+
export const DefaultPt2 = {
194+
render: Template,
195+
name: 'default items and columns 2 of 3',
196+
args: {combos: combo2, columns, items: nestedItems}
197+
};
198+
199+
export const DefaultPt3 = {
200+
render: Template,
201+
name: 'default items and columns 3 of 3',
202+
args: {combos: combo3, columns, items: nestedItems}
187203
};
188204

189205
export const ColumnAlign = {
190206
render: Template,
191-
name: 'column alignment',
192-
args: {columns: alignColumns, items: nestedItems}
207+
name: 'column alignment 1 of 3',
208+
args: {combos: combo1, columns: alignColumns, items: nestedItems}
209+
};
210+
211+
export const ColumnAlignPt2 = {
212+
render: Template,
213+
name: 'column alignment 2 of 3',
214+
args: {combos: combo2, columns: alignColumns, items: nestedItems}
215+
};
216+
217+
export const ColumnAlignPt3 = {
218+
render: Template,
219+
name: 'column alignment 3 of 3',
220+
args: {combos: combo3, columns: alignColumns, items: nestedItems}
193221
};
194222

195223
export const ColumnDividers = {
196224
render: Template,
197-
name: 'columns dividers',
198-
args: {columns: dividerColumns, items: nestedItems}
225+
name: 'columns dividers 1 of 3',
226+
args: {combos: combo1, columns: dividerColumns, items: nestedItems}
227+
};
228+
229+
export const ColumnDividersPt2 = {
230+
render: Template,
231+
name: 'columns dividers 2 of 3',
232+
args: {combos: combo2, columns: dividerColumns, items: nestedItems}
233+
};
234+
235+
export const ColumnDividersPt3 = {
236+
render: Template,
237+
name: 'columns dividers 3 of 3',
238+
args: {combos: combo3, columns: dividerColumns, items: nestedItems}
199239
};
200240

201241
export const ColumnWidth = {
202242
render: Template,
203-
name: 'columns widths',
204-
args: {columns: customWidth, items: nestedItems}
243+
name: 'columns widths 1 of 3',
244+
args: {combos: combo1, columns: customWidth, items: nestedItems}
245+
};
246+
247+
export const ColumnWidthPt2 = {
248+
render: Template,
249+
name: 'columns widths 2 of 3',
250+
args: {combos: combo2, columns: customWidth, items: nestedItems}
251+
};
252+
253+
export const ColumnWidthPt3 = {
254+
render: Template,
255+
name: 'columns widths 3 of 3',
256+
args: {combos: combo3, columns: customWidth, items: nestedItems}
205257
};
206258

207259
export const HiddenColumns = {
208260
render: Template,
209-
name: 'hidden columns',
210-
args: {columns: hiddenColumns, items: nestedItems}
261+
name: 'hidden columns 1 of 3',
262+
args: {combos: combo1, columns: hiddenColumns, items: nestedItems}
263+
};
264+
265+
export const HiddenColumnsPt2 = {
266+
render: Template,
267+
name: 'hidden columns 2 of 3',
268+
args: {combos: combo2, columns: hiddenColumns, items: nestedItems}
269+
};
270+
271+
export const HiddenColumnsPt3 = {
272+
render: Template,
273+
name: 'hidden columns 3 of 3',
274+
args: {combos: combo3, columns: hiddenColumns, items: nestedItems}
211275
};
212276

213277
export const NestedColumns = {
214278
render: Template,
215-
name: 'nested columns',
216-
args: {columns: nestedColumns, items: nestedItems}
279+
name: 'nested columns 1 of 3',
280+
args: {combos: combo1, columns: nestedColumns, items: nestedItems}
281+
};
282+
283+
export const NestedColumnsPt2 = {
284+
render: Template,
285+
name: 'nested columns 2 of 3',
286+
args: {combos: combo2, columns: nestedColumns, items: nestedItems}
217287
};
218288

289+
export const NestedColumnsPt3 = {
290+
render: Template,
291+
name: 'nested columns 3 of 3',
292+
args: {combos: combo3, columns: nestedColumns, items: nestedItems}
293+
};
294+
295+
219296
export const MaxHeight = () => (
220297
<TableView maxHeight="size-1200" UNSTABLE_allowsExpandableRows>
221298
<TableHeader columns={columns}>

packages/@react-spectrum/table/chromatic/TreeGridTableRTL.chromatic.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,22 @@ export default meta;
2626

2727
export {
2828
Default,
29+
DefaultPt2,
30+
DefaultPt3,
2931
ColumnAlign,
32+
ColumnAlignPt2,
33+
ColumnAlignPt3,
3034
ColumnDividers,
35+
ColumnDividersPt2,
36+
ColumnDividersPt3,
3137
ColumnWidth,
38+
ColumnWidthPt2,
39+
ColumnWidthPt3,
3240
HiddenColumns,
41+
HiddenColumnsPt2,
42+
HiddenColumnsPt3,
3343
NestedColumns,
44+
NestedColumnsPt2,
45+
NestedColumnsPt3,
3446
Empty
35-
} from './TableView.chromatic';
47+
} from './TreeGridTable.chromatic';

0 commit comments

Comments
 (0)