Skip to main content

Styles

Overview

Hello
World !
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 import React from 'react'; import classes from './styles.module.scss'; const config = { alwaysInEdition: true, hasFooter: true, styles: { header: { container: () => { return { classes: classes.customHeader }; }, cell: ({ columnIndex }) => { const style = {}; if (columnIndex === 0) { style.background = 'gold'; } return { style, classes: classes.customHeaderCell }; } }, body: { container: () => { return { classes: classes.customBody }; }, row: ({ rowData, rowIndex }) => { if (rowData.one === 'B') { return { classes: [classes.customBodyRow, 'important'] }; } else if (rowData.one === 'C') { return { classes: [classes.customBodyRow, 'warning'] }; } return { classes: classes.customBodyRow, style: rowIndex === 2 ? { backgroundColor: '#FFAAAA' } : undefined }; }, cell: ({ key }) => { return { style: { backgroundColor: key === 'two' ? 'rgba(255,0,0,.8)' : null } }; } }, footer: { container: () => { return { style: { background: 'none' } }; }, cell: ({ columnIndex, key }) => { console.log(columnIndex); const style = {}; if (key === 'three') { return { style: { border: `2px solid blue`, boxSizing: 'border-box', marginTop: '1px', background: '#fafafa' } }; } if (columnIndex === 0) { style.background = 'gold'; style.height = '100%'; } return { style, classes: classes.customFooterCell }; } } }, columns: [ { key: 'one', header: 'Col 1', size: 1 }, { key: 'two', header: 'Col 5', size: 1 }, { key: 'three', header: 'Col 3', size: 1, footerProps: { colspan: 2 }, footerValue: () => ( <div> <div>Hello</div> <div>World !</div> </div> ) }, { key: 'four', header: 'Col 4', size: 1 } ] }; export default config;

Config

const config = {
styles: {
header: HeaderStyle,
body: BodyStyle,
footer: FooterStyle
},
columns: [...]
}
interface StyleResponse {
classes?: object|object[];
style?: object;
}

interface HeaderStyle {
container?: (): StyleResponse;
cell?: ({ columnIndex: number, key: string }): StyleResponse;
}

interface BodyStyle {
container?: (): StyleResponse;
row?: ({ rowData: object, rowIndex: number }): StyleResponse;
cell?: ({ columnIndex: number, key: string, rowData: object, rowIndex: number }): StyleResponse;
}

interface FooterStyle {
container?: (): StyleResponse;
cell?: ({ columnIndex: number, key: string }): StyleResponse;
}