mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Table: updates story from knobs to control (#34193)
* Tables: updates story from knobs to control * removes the Descending and sortByDisplayName controls since they have no effect on component Co-authored-by: Hugo Häggmark <hugo.haggmark@gmail.com>
This commit is contained in:
parent
3e48fe9475
commit
21f0509f8b
@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import { merge } from 'lodash';
|
import { merge } from 'lodash';
|
||||||
import { Table } from '@grafana/ui';
|
import { Table } from '@grafana/ui';
|
||||||
import { withCenteredStory } from '../../utils/storybook/withCenteredStory';
|
import { withCenteredStory } from '../../utils/storybook/withCenteredStory';
|
||||||
import { number } from '@storybook/addon-knobs';
|
import { Meta, Story } from '@storybook/react';
|
||||||
import { useTheme2 } from '../../themes';
|
import { useTheme2 } from '../../themes';
|
||||||
import mdx from './Table.mdx';
|
import mdx from './Table.mdx';
|
||||||
import {
|
import {
|
||||||
@ -21,11 +21,22 @@ export default {
|
|||||||
component: Table,
|
component: Table,
|
||||||
decorators: [withCenteredStory],
|
decorators: [withCenteredStory],
|
||||||
parameters: {
|
parameters: {
|
||||||
|
controls: {
|
||||||
|
exclude: ['onColumnResize', 'onSortByChange', 'onCellFilterAdded', 'ariaLabel', 'data', 'initialSortBy'],
|
||||||
|
},
|
||||||
docs: {
|
docs: {
|
||||||
page: mdx,
|
page: mdx,
|
||||||
},
|
},
|
||||||
|
knobs: {
|
||||||
|
disable: true,
|
||||||
},
|
},
|
||||||
};
|
},
|
||||||
|
args: {
|
||||||
|
width: 700,
|
||||||
|
height: 500,
|
||||||
|
columnMinWidth: 150,
|
||||||
|
},
|
||||||
|
} as Meta;
|
||||||
|
|
||||||
function buildData(theme: GrafanaTheme2, config: Record<string, FieldConfig>): DataFrame {
|
function buildData(theme: GrafanaTheme2, config: Record<string, FieldConfig>): DataFrame {
|
||||||
const data = new MutableDataFrame({
|
const data = new MutableDataFrame({
|
||||||
@ -99,21 +110,19 @@ const defaultThresholds: ThresholdsConfig = {
|
|||||||
mode: ThresholdsMode.Absolute,
|
mode: ThresholdsMode.Absolute,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Simple = () => {
|
export const Basic: Story = (args) => {
|
||||||
const theme = useTheme2();
|
const theme = useTheme2();
|
||||||
const width = number('width', 700, {}, 'Props');
|
|
||||||
const data = buildData(theme, {});
|
const data = buildData(theme, {});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="panel-container" style={{ width: 'auto' }}>
|
<div className="panel-container" style={{ width: 'auto' }}>
|
||||||
<Table data={data} height={500} width={width} />
|
<Table data={data} height={args.height} width={args.width} {...args} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const BarGaugeCell = () => {
|
export const BarGaugeCell: Story = (args) => {
|
||||||
const theme = useTheme2();
|
const theme = useTheme2();
|
||||||
const width = number('width', 700, {}, 'Props');
|
|
||||||
const data = buildData(theme, {
|
const data = buildData(theme, {
|
||||||
Progress: {
|
Progress: {
|
||||||
custom: {
|
custom: {
|
||||||
@ -126,14 +135,13 @@ export const BarGaugeCell = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="panel-container" style={{ width: 'auto' }}>
|
<div className="panel-container" style={{ width: 'auto' }}>
|
||||||
<Table data={data} height={500} width={width} />
|
<Table data={data} height={args.height} width={args.width} {...args} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ColoredCells = () => {
|
export const ColoredCells: Story = (args) => {
|
||||||
const theme = useTheme2();
|
const theme = useTheme2();
|
||||||
const width = number('width', 750, {}, 'Props');
|
|
||||||
const data = buildData(theme, {
|
const data = buildData(theme, {
|
||||||
Progress: {
|
Progress: {
|
||||||
custom: {
|
custom: {
|
||||||
@ -146,7 +154,7 @@ export const ColoredCells = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="panel-container" style={{ width: 'auto' }}>
|
<div className="panel-container" style={{ width: 'auto' }}>
|
||||||
<Table data={data} height={500} width={width} />
|
<Table data={data} height={args.height} width={args.width} {...args} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user