diff --git a/src/components/Card/SCard.vue b/src/components/Card/SCard.vue index 266d758f..ba72dfbc 100644 --- a/src/components/Card/SCard.vue +++ b/src/components/Card/SCard.vue @@ -12,7 +12,7 @@ + + diff --git a/src/components/Table/STableColumn.vue b/src/components/Table/STableColumn.vue new file mode 100644 index 00000000..05d89e94 --- /dev/null +++ b/src/components/Table/STableColumn.vue @@ -0,0 +1,195 @@ + + + + + diff --git a/src/components/Table/consts.ts b/src/components/Table/consts.ts new file mode 100644 index 00000000..ec3b1914 --- /dev/null +++ b/src/components/Table/consts.ts @@ -0,0 +1,27 @@ +import { Size } from '../../types/size' +import { TooltipPlacement } from '../Tooltip' + +export enum ColumnType { + SELECTION = 'selection', + INDEX = 'index', + EXPAND = 'expand' +} + +export enum ColumnFixedPosition { + LEFT = 'left', + RIGHT = 'right' +} + +export enum SortDirection { + ASC = 'ascending', + DESC = 'descending' +} + +export enum ColumnAlignment { + LEFT = 'left', + CENTER = 'center', + RIGHT = 'right' +} + +export const TableSize = Size +export const ColumnFilterPlacement = TooltipPlacement diff --git a/src/components/Table/index.ts b/src/components/Table/index.ts new file mode 100644 index 00000000..2a46f9ea --- /dev/null +++ b/src/components/Table/index.ts @@ -0,0 +1,13 @@ +import STable from './STable.vue' +import STableColumn from './STableColumn.vue' +import { ColumnAlignment, ColumnFixedPosition, ColumnType, SortDirection, TableSize } from './consts' + +export { + STable, + STableColumn, + ColumnAlignment, + ColumnFixedPosition, + ColumnType, + SortDirection, + TableSize +} diff --git a/src/components/index.ts b/src/components/index.ts index 59e17f66..16e8ad4e 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -20,6 +20,7 @@ import { SMain } from './Layout/Main' import { SMenu, SMenuItem, SMenuItemGroup, SSubmenu } from './Menu' import { SRow } from './Layout/Row' import { SScrollSectionItem, SScrollSections } from './ScrollSections' +import { STable, STableColumn } from './Table' import { STooltip } from './Tooltip' export { @@ -52,5 +53,7 @@ export { SScrollSectionItem, SScrollSections, SSubmenu, + STable, + STableColumn, STooltip } diff --git a/src/index.ts b/src/index.ts index 61d5a248..12c29690 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,6 +30,8 @@ import { SScrollSectionItem, SScrollSections, SSubmenu, + STable, + STableColumn, STooltip } from './components' import { Components } from './types/components' @@ -65,6 +67,8 @@ const elements = [ { component: SScrollSectionItem, name: Components.SScrollSectionItem }, { component: SScrollSections, name: Components.SScrollSections }, { component: SSubmenu, name: Components.SSubmenu }, + { component: STable, name: Components.STable }, + { component: STableColumn, name: Components.STableColumn }, { component: STooltip, name: Components.STooltip } ] @@ -111,6 +115,8 @@ export { SScrollSectionItem, SScrollSections, SSubmenu, + STable, + STableColumn, STooltip } export default SoramitsuElements diff --git a/src/stories/Table/STable.stories.ts b/src/stories/Table/STable.stories.ts new file mode 100644 index 00000000..daccf7de --- /dev/null +++ b/src/stories/Table/STable.stories.ts @@ -0,0 +1,161 @@ +import { text, withKnobs, select, boolean } from '@storybook/addon-knobs' + +import { STable, STableColumn } from '../../components' +import { TableSize } from '../../components/Table' + +export default { + component: STable, + title: 'Design System/Table', + decorators: [withKnobs], + excludeStories: /.*Data$/ +} + +export const tableData = [ + { + date: '2017-05-03', + amount: '1.56', + address: 'No. 189, Grove St, Los Angeles' + }, + { + date: '2016-05-02', + amount: '-99', + address: 'No. 190, Grove St, Los Angeles' + }, + { + date: '2018-05-04', + amount: '0', + address: 'No. 191, Grove St, Los Angeles' + }, + { + date: '2015-05-01', + amount: '55555', + address: 'No. 192, Grove St, Los Angeles' + } +] + +export const configurable = () => ({ + components: { STable, STableColumn }, + template: ` + + + + + Hello + `, + data: () => ({ + tableData: tableData + }), + props: { + height: { + default: text('Height', 'auto') + }, + stripe: { + default: boolean('Stripe', false) + }, + border: { + default: boolean('Border', false) + }, + showHeader: { + default: boolean('Show header', true) + }, + size: { + default: select('Size', Object.values(TableSize), TableSize.BIG) + }, + highlightCurrentRow: { + default: boolean('Highlight current row', false) + } + } +}) + +export const withBorder = () => ({ + components: { STable, STableColumn }, + template: ` + + + + + Hello + `, + data: () => ({ + tableData: tableData + }) +}) + +export const striped = () => ({ + components: { STable, STableColumn }, + template: ` + + + + + Hello + `, + data: () => ({ + tableData: tableData + }) +}) + +export const withAllExpandedRows = () => ({ + components: { STable, STableColumn }, + template: ` + + + + + Hello + `, + data: () => ({ + tableData: tableData + }) +}) + +export const withTotalRow = () => ({ + components: { STable, STableColumn }, + template: ` + + + + + Hello + `, + data: () => ({ + tableData: tableData + }) +}) + +export const withDefaultSort = () => ({ + components: { STable, STableColumn }, + template: ` + + + + + Hello + `, + data: () => ({ + tableData: tableData + }) +}) diff --git a/src/stories/Table/STableColumn.stories.ts b/src/stories/Table/STableColumn.stories.ts new file mode 100644 index 00000000..1ec6025b --- /dev/null +++ b/src/stories/Table/STableColumn.stories.ts @@ -0,0 +1,103 @@ +import { text, withKnobs, select, boolean } from '@storybook/addon-knobs' + +import { STable, STableColumn } from '../../components' +import { ColumnAlignment } from '../../components/Table' + +import { tableData } from './STable.stories' + +export default { + component: STableColumn, + title: 'Design System/Table/Table Column', + decorators: [withKnobs], + excludeStories: /.*Data$/ +} + +export const configurable = () => ({ + components: { STable, STableColumn }, + template: ` + + + + + Hello + `, + data: () => ({ + tableData: tableData + }), + props: { + label: { + default: text('Label', 'Date') + }, + showOverflowTooltip: { + default: boolean('Show overflow tooltip', true) + }, + align: { + default: select('Align', Object.values(ColumnAlignment), ColumnAlignment.LEFT) + }, + headerAlign: { + default: select('Header align', Object.values(ColumnAlignment), ColumnAlignment.LEFT) + } + } +}) + +export const withFilters = () => ({ + components: { STable, STableColumn }, + template: ` + + + + + Hello + `, + data: () => ({ + tableData: tableData, + tableFilters: [ + { text: '< 2016-01-01', value: 1 }, + { text: 'between 2016-01-01 and 2016-05-01', value: 2 }, + { text: 'between 2016-05-01 and 2018-05-05', value: 3 }, + { text: '> 2019-01-01', value: 4 } + ], + filterDate: (value: number, row: any) => { + const date = new Date(row.date).getTime() + switch (value) { + case 1: + return date < new Date('2016-01-01').getTime() + case 2: + return date > new Date('2016-01-01').getTime() && date < new Date('2016-05-01').getTime() + case 3: + return date > new Date('2016-05-01').getTime() && date < new Date('2018-05-05').getTime() + case 4: + return date > new Date('2019-01-01').getTime() + } + return true + } + }), + props: { + filterMultiple: { + default: boolean('Filter multiple', false) + } + } +}) diff --git a/src/styles/variables.scss b/src/styles/variables.scss index 581d8ea1..d1cc7572 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -7,6 +7,7 @@ $color-main-base: #FFF9FA; // Neutral colors $color-neutral-primary: #53565A; $color-neutral-secondary: #75787B; +$color-neutral-tertiary: #909296; $color-neutral-inactive: #C8C9C7; $color-neutral-border: #D9D9D6; $color-neutral-hover: #F0F0F0; diff --git a/src/types/components.ts b/src/types/components.ts index 701af730..ed91efee 100644 --- a/src/types/components.ts +++ b/src/types/components.ts @@ -28,5 +28,7 @@ export enum Components { SScrollSectionItem = 'SScrollSectionItem', SScrollSections = 'SScrollSections', SSubmenu = 'SSubmenu', + STable = 'STable', + STableColumn = 'STableColumn', STooltip = 'STooltip' }