Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(Storybook): update storybook config so actions display properly #13302

Merged
merged 3 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions packages/react/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import './styles.scss';
import '../src/feature-flags';

import { configureActions } from '@storybook/addon-actions';
import { white, g10, g90, g100 } from '@carbon/themes';
import React from 'react';
import { breakpoints } from '@carbon/layout';
Expand Down Expand Up @@ -203,11 +202,6 @@ export const parameters = {
},
};

configureActions({
depth: 3,
limit: 10,
});

export const decorators = [
(Story, context) => {
const { locale, theme } = context.globals;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export const WithLayer = () => (
export const Playground = (args) => (
<div style={{ width: 300 }}>
<ComboBox
onChange={() => {}}
id="carbon-combobox"
items={items}
downshiftProps={{
Expand Down Expand Up @@ -184,7 +183,7 @@ Playground.argTypes = {
},
},
onChange: {
action: 'clicked',
action: 'changed',
},
onClick: {
action: 'clicked',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ Playground.argTypes = {
},
},
onClose: {
action: 'clicked',
action: 'onClose',
},
onKeyDown: {
action: 'clicked',
action: 'onKeyDown',
},
selectorPrimaryFocus: {
table: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ export const Playground = (args) => (
aria-hidden={batchActionProps.shouldShowBatchActions}>
<TableToolbarSearch
tabIndex={batchActionProps.shouldShowBatchActions ? -1 : 0}
onChange={onInputChange}
onChange={(evt) => {
action('TableToolbarSearch - onChange')(evt);
onInputChange(evt);
}}
/>
<TableToolbarMenu
tabIndex={batchActionProps.shouldShowBatchActions ? -1 : 0}>
Expand Down Expand Up @@ -240,7 +243,10 @@ export const Playground = (args) => (
<TableBody>
{rows.map((row, i) => (
<TableRow key={i} {...getRowProps({ row })}>
<TableSelectRow {...getSelectionProps({ row })} />
<TableSelectRow
{...getSelectionProps({ row })}
onChange={action('TableSelectRow - onChange')}
/>
{row.cells.map((cell) => (
<TableCell key={cell.id}>{cell.value}</TableCell>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ export const Playground = (args) => (
<TableToolbar>
<TableToolbarContent>
{/* pass in `onInputChange` change here to make filtering work */}
<TableToolbarSearch onChange={onInputChange} />
<TableToolbarSearch
onChange={(evt) => {
action('TableToolbarSearch - onChange')(evt);
onInputChange(evt);
}}
/>
<TableToolbarMenu>
<TableToolbarAction onClick={action('Action 1 Click')}>
Action 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,8 @@ export const Default = () => (
</TableHead>
<TableBody>
{rows.map((row, i) => (
<TableRow
key={i}
{...getRowProps({ row })}
onClick={(evt) => {
action('TableRow onClick')(evt);
}}>
<TableSelectRow
{...getSelectionProps({ row })}
onSelect={(evt) => {
action('TableSelectRow onSelect')(evt);
getSelectionProps({ row }).onSelect(evt);
}}
/>
<TableRow key={i} {...getRowProps({ row })}>
<TableSelectRow {...getSelectionProps({ row })} />
{row.cells.map((cell) => (
<TableCell key={cell.id}>{cell.value}</TableCell>
))}
Expand Down Expand Up @@ -214,10 +203,7 @@ export const Playground = (args) => (
}}>
<TableSelectRow
{...getSelectionProps({ row })}
onSelect={(evt) => {
action('TableSelectRow onSelect')(evt);
getSelectionProps({ row }).onSelect(evt);
}}
onChange={action('TableSelectRow - onChange')}
/>
{row.cells.map((cell) => (
<TableCell key={cell.id}>{cell.value}</TableCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const Default = () => (
);

export const Playground = (args) => (
<DataTable rows={rows} headers={headers} {...args}>
<DataTable isSortable rows={rows} headers={headers} {...args}>
{({ rows, headers, getHeaderProps, getRowProps, getTableProps }) => (
<TableContainer title="DataTable" description="With sorting">
<Table {...getTableProps()}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,12 @@ export const Playground = (args) => (
<TableContainer title="DataTable" description="With overflow menu">
<TableToolbar {...getToolbarProps()} aria-label="data table toolbar">
<TableToolbarContent>
<TableToolbarSearch onChange={onInputChange} />
<TableToolbarSearch
onChange={(evt) => {
action('TableToolbarSearch - onChange')(evt);
onInputChange(evt);
}}
/>
<TableToolbarMenu light>
<TableToolbarAction onClick={action('Action 1 Click')}>
Action 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import './story.scss';

import React from 'react';
import { TrashCan, Save, Download } from '@carbon/icons-react';
import { action } from '@storybook/addon-actions';
import DataTable, {
Table,
TableBatchAction,
Expand Down Expand Up @@ -299,12 +300,25 @@ export const Playground = (args) => {
</TableBatchAction>
</TableBatchActions>
<TableToolbarContent>
<TableToolbarSearch onChange={onInputChange} />
<TableToolbarSearch
onChange={(evt) => {
action('TableToolbarSearch - onChange')(evt);
onInputChange(evt);
}}
/>
<TableToolbarMenu>
<TableToolbarAction onClick={this.handleOnRowAdd}>
<TableToolbarAction
onClick={(evt) => {
action('handleOnRowAdd')(evt);
this.handleOnRowAdd();
}}>
Add row
</TableToolbarAction>
<TableToolbarAction onClick={this.handleOnHeaderAdd}>
<TableToolbarAction
onClick={(evt) => {
action('handleOnHeaderAdd')(evt);
this.handleOnHeaderAdd();
}}>
Add header
</TableToolbarAction>
</TableToolbarMenu>
Expand All @@ -325,8 +339,13 @@ export const Playground = (args) => {
<TableBody>
{rows.map((row) => (
<React.Fragment key={row.id}>
<TableExpandRow {...getRowProps({ row })}>
<TableSelectRow {...getSelectionProps({ row })} />
<TableExpandRow
{...getRowProps({ row })}
onClick={action('onClick')}>
<TableSelectRow
{...getSelectionProps({ row })}
onChange={action('TableSelectRow - onChange')}
/>
{row.cells.map((cell) => (
<TableCell key={cell.id}>{cell.value}</TableCell>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import DataTable, {
import { Pagination } from '../../../../';
import { rows, headers } from '../shared';
import mdx from '../../DataTable.mdx';
import { action } from '@storybook/addon-actions';

export default {
title: 'Components/DataTable/Expansion',
Expand Down Expand Up @@ -288,7 +289,9 @@ export const Playground = (args) => (
<TableBody>
{rows.map((row) => (
<React.Fragment key={row.id}>
<TableExpandRow {...getRowProps({ row })}>
<TableExpandRow
{...getRowProps({ row })}
onClick={action('onClick')}>
{row.cells.map((cell) => (
<TableCell key={cell.id}>{cell.value}</TableCell>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ export const headers = [
];

export const batchActionClick = (selectedRows) => () =>
action('batch action click')(selectedRows);
action('Batch action click')(selectedRows);
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@ Playground.argTypes = {
},
},
onChange: {
action: 'clicked',
action: 'onChange',
},
onClose: {
action: 'clicked',
action: 'onClose',
},
onOpen: {
action: 'clicked',
action: 'onOpen',
},
readOnly: {
control: {
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/components/Modal/Modal.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,16 @@ Playground.argTypes = {
},
},
onKeyDown: {
action: 'clicked',
action: 'onKeyDown',
},
onRequestClose: {
action: 'clicked',
action: 'onRequestClose',
},
onRequestSubmit: {
action: 'clicked',
action: 'onRequestSubmit',
},
onSecondarySubmit: {
action: 'clicked',
action: 'onSecondarySubmit',
table: {
disable: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ Playground.argTypes = {
},
},
onActionButtonClick: {
action: 'clicked',
action: 'onActionButtonClick',
},
onClose: {
action: 'clicked',
action: 'onClose',
},
onCloseButtonClick: {
action: 'clicked',
action: 'onCloseButtonClick',
},
children: {
table: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ Playground.argTypes = {
},
},
onClose: {
action: 'clicked',
action: 'onClose',
},
onCloseButtonClick: {
action: 'clicked',
action: 'onCloseButtonClick',
},
children: {
table: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ Playground.argTypes = {
},
},
onClose: {
action: 'clicked',
action: 'onClose',
},
onCloseButtonClick: {
action: 'clicked',
action: 'onCloseButtonClick',
},
children: {
table: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ Playground.argTypes = {
},
},
onChange: {
action: 'clicked',
action: 'onChange',
},
onClick: {
action: 'clicked',
action: 'onClick',
},
onKeyUp: {
action: 'clicked',
action: 'onKeyUp',
},
translateWithId: {
table: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ Playground.argTypes = {
},
},
onChange: {
action: 'clicked',
action: 'onChange',
},
onClick: {
action: 'clicked',
action: 'onClick',
},
size: {
defaultValue: 'md',
Expand Down