diff --git a/jsapp/js/components/common/SimpleTable.module.scss b/jsapp/js/components/common/SimpleTable.module.scss new file mode 100644 index 0000000000..2c804a8de3 --- /dev/null +++ b/jsapp/js/components/common/SimpleTable.module.scss @@ -0,0 +1,25 @@ +// We need bigger specificity in each selector to ensure we do overwrite default +// styles + +table.SimpleTableRoot { + background-color: var(--mantine-color-gray-9); + border-collapse: separate; + border-radius: var(--mantine-radius-md); +} + +thead.SimpleTableThead { + background-color: var(--mantine-color-gray-8); +} + +th.SimpleTableTh { + font-size: var(--mantine-font-size-sm); + color: var(--mantine-color-gray-2); + font-weight: 400; +} + +td.SimpleTableTd { + font-size: var(--mantine-font-size-md); + border-top-width: 1px; + border-top-color: var(--mantine-color-gray-7); + border-top-style: solid; +} diff --git a/jsapp/js/components/common/SimpleTable.tsx b/jsapp/js/components/common/SimpleTable.tsx index 28c0cfb998..4680131556 100644 --- a/jsapp/js/components/common/SimpleTable.tsx +++ b/jsapp/js/components/common/SimpleTable.tsx @@ -1,6 +1,7 @@ -import {Table, type TableData} from '@mantine/core'; +import {Table, type MantineStyleProps, type TableData} from '@mantine/core'; +import styles from './SimpleTable.module.scss'; -interface SimpleTableProps { +interface SimpleTableProps extends MantineStyleProps { head: TableData['head']; body: TableData['body']; /** @@ -13,20 +14,30 @@ interface SimpleTableProps { /** * A wrapper component for `Table` from `@mantine/core`. It requires column - * headings, column data, and has optional minimum width. + * headings, column data, and has optional minimum width. You can pass all + * standard Mantine style props down to the inner `Table`. */ -export default function SimpleTable(props: SimpleTableProps) { +export default function SimpleTable( + {head, body, minWidth, ...styleProps}: SimpleTableProps +) { const table = ( ); - if (props.minWidth) { + if (minWidth) { return ( - + {table} ); diff --git a/jsapp/js/components/modalForms/bulkEditSubmissionsForm.es6 b/jsapp/js/components/modalForms/bulkEditSubmissionsForm.es6 index 320c43564b..644ef28c15 100644 --- a/jsapp/js/components/modalForms/bulkEditSubmissionsForm.es6 +++ b/jsapp/js/components/modalForms/bulkEditSubmissionsForm.es6 @@ -16,7 +16,7 @@ import {actions} from 'js/actions'; import TextBox from 'js/components/common/textBox'; import Button from 'js/components/common/button'; import SimpleTable from 'js/components/common/SimpleTable'; -import {Text, Box} from '@mantine/core'; +import {Text} from '@mantine/core'; import envStore from 'js/envStore'; // we need a text to display when we need to say "this question has no answer" @@ -550,18 +550,17 @@ class BulkEditRowForm extends React.Component { - - {t('Action')}, - ]} - body={this.getRows()} - minWidth={600} - /> - + {t('Action')}, + ]} + body={this.getRows()} + minWidth={600} + /> ); } diff --git a/jsapp/js/theme/kobo/Table.ts b/jsapp/js/theme/kobo/Table.ts index 6099a5af66..8cc2685f8c 100644 --- a/jsapp/js/theme/kobo/Table.ts +++ b/jsapp/js/theme/kobo/Table.ts @@ -8,29 +8,6 @@ export const TableThemeKobo = Table.extend({ withRowBorders: false, captionSide: 'top', }, - styles: (theme) => { - return { - table: { - backgroundColor: theme.colors.gray[9], - borderCollapse: 'separate', - borderRadius: theme.radius.md, - }, - thead: { - backgroundColor: theme.colors.gray[8], - }, - th: { - fontSize: theme.fontSizes.sm, - color: theme.colors.gray[2], - fontWeight: '400', - }, - td: { - fontSize: theme.fontSizes.md, - borderTopWidth: '1px', - borderTopColor: theme.colors.gray[7], - borderTopStyle: 'solid', - }, - }; - }, vars: (theme) => { return { table: {