The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/packages/grafana-ui/src/components/Table/Table.story.tsx

74 lines
1.9 KiB

// import React from 'react';
7 years ago
import { storiesOf } from '@storybook/react';
import { Table } from './Table';
import { migratedTestTable, migratedTestStyles, simpleTable } from './examples';
import { ScopedVars, TableData } from '../../types/index';
import { withFullSizeStory } from '../../utils/storybook/withFullSizeStory';
import { number, boolean } from '@storybook/addon-knobs';
7 years ago
const replaceVariables = (value: string, scopedVars?: ScopedVars) => {
if (scopedVars) {
// For testing variables replacement in link
for (const key in scopedVars) {
const val = scopedVars[key];
value = value.replace('$' + key, val.value);
}
}
7 years ago
return value;
};
storiesOf('UI/Table', module)
7 years ago
.add('basic', () => {
const showHeader = boolean('Show Header', true);
const fixedRowCount = number('Fixed Rows', 1);
const fixedColumnCount = number('Fixed Columns', 1);
return withFullSizeStory(Table, {
7 years ago
styles: [],
data: simpleTable,
replaceVariables,
fixedRowCount,
fixedColumnCount,
showHeader,
7 years ago
});
})
.add('Test Configuration', () => {
return withFullSizeStory(Table, {
7 years ago
styles: migratedTestStyles,
data: migratedTestTable,
replaceVariables,
showHeader: true,
});
})
.add('Lots of cells', () => {
const data = {
columns: [],
rows: [],
type: 'table',
columnMap: {},
} as TableData;
for (let i = 0; i < 20; i++) {
data.columns.push({
text: 'Column ' + i,
});
}
for (let r = 0; r < 500; r++) {
const row = [];
for (let i = 0; i < 20; i++) {
row.push(r + i);
}
data.rows.push(row);
}
console.log('DATA:', data);
return withFullSizeStory(Table, {
styles: simpleTable,
data,
replaceVariables,
showHeader: true,
fixedColumnCount: 1,
fixedRowCount: 1,
7 years ago
});
});