Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(SimpleTable): drop BEM, use Mantine TASK-1377 #5366

Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
45b7fc4
create initial files
magicznyleszek Dec 16, 2024
dd16257
Merge branch 'kalvis/mantine-setup' into leszek/task-1377-simple-tabl…
magicznyleszek Dec 16, 2024
583bba3
prepare initial stories
magicznyleszek Dec 16, 2024
67471a4
add Table theme overrides
magicznyleszek Dec 17, 2024
a0ff728
adjust SimpleTable styles
magicznyleszek Dec 18, 2024
63d9a73
use SimpleTable in ProjectExportsList
magicznyleszek Dec 18, 2024
701d673
remove leftover project-exports selector styles
magicznyleszek Dec 18, 2024
a123d45
use SimpleTable in BulkEditSubmissionsForm
magicznyleszek Dec 18, 2024
a93c7bf
use SimpleTable in BulkEditRowForm
magicznyleszek Dec 18, 2024
54e6495
use SimpleTable in SubmissionDataTable
magicznyleszek Dec 18, 2024
898bc09
remove bem.SimpleTable from codebase
magicznyleszek Dec 18, 2024
abb8342
linter fixes
magicznyleszek Dec 18, 2024
4f8ed7a
improve SimpleTable story example
magicznyleszek Dec 18, 2024
ad2e5a7
update SimpleTable stories to use global Mantine setup
magicznyleszek Dec 18, 2024
b32253c
Merge branch 'kalvis/mantine-setup' into leszek/task-1377-simple-tabl…
magicznyleszek Dec 18, 2024
b07fd65
Merge branch 'kalvis/mantine-setup' into leszek/task-1377-simple-tabl…
magicznyleszek Dec 18, 2024
2c89090
Merge branch 'kalvis/mantine-setup' into leszek/task-1377-simple-tabl…
magicznyleszek Dec 19, 2024
c4e9f27
code review fixes
magicznyleszek Dec 23, 2024
b9bd823
Merge branch 'kalvis/mantine-setup' into leszek/task-1377-simple-tabl…
magicznyleszek Jan 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions jsapp/js/bemComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,6 @@ bem.KDrawer__primaryIcons = makeBem(bem.KDrawer, 'primary-icons', 'nav');
bem.KDrawer__secondaryIcons = makeBem(bem.KDrawer, 'secondary-icons', 'nav');
bem.KDrawer__sidebar = makeBem(bem.KDrawer, 'sidebar', 'aside');

bem.SimpleTable = makeBem(null, 'simple-table', 'table');
bem.SimpleTable__header = makeBem(bem.SimpleTable, 'header', 'thead');
bem.SimpleTable__body = makeBem(bem.SimpleTable, 'body', 'tbody');
bem.SimpleTable__footer = makeBem(bem.SimpleTable, 'footer', 'tfoot');
bem.SimpleTable__row = makeBem(bem.SimpleTable, 'row', 'tr');
// NOTE: messageRow needs a __cell with colspan set
bem.SimpleTable__messageRow = makeBem(bem.SimpleTable, 'message-row', 'tr');
bem.SimpleTable__cell = makeBem(bem.SimpleTable, 'cell', 'td');

bem.tagSelect = makeBem(null, 'tag-select');
bem.collectionFilter = makeBem(null, 'collection-filter');

Expand Down
46 changes: 46 additions & 0 deletions jsapp/js/components/common/SimpleTable.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type {Meta, StoryObj} from '@storybook/react';
import SimpleTable from './SimpleTable';

const meta: Meta<React.ComponentProps<typeof SimpleTable>> = {
title: 'common/SimpleTable',
component: SimpleTable,
argTypes: {},
args: {},
render: ({...args}) => (
<SimpleTable
{...args}
head={['Element position', 'Atomic mass', 'Symbol', 'Element name']}
body={
[
[6, 12.011, 'C', 'Carbon'],
[7, 14.007, 'N', 'Nitrogen'],
[39, 88.906, 'Y', 'Yttrium'],
[56, 137.33, 'Ba', 'Barium'],
[
'n/a',
'n/a',
'??',
(
<div key='test'>
This is just a DIV. It has a button and an input:
<br/><br/>
<button>button</button>
<br/><br/>
<input type='email'/>
<br/><br/>
It shows you can have any <code>React.ReactNode</code> here.
</div>
),
],
[58, 140.12, 'Ce', 'Cerium'],
]
}
/>
),
};

export default meta;

export const Primary: StoryObj<typeof SimpleTable> = {
args: {},
};
36 changes: 36 additions & 0 deletions jsapp/js/components/common/SimpleTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {Table, type TableData} from '@mantine/core';

interface SimpleTableProps {
head: TableData['head'];
body: TableData['body'];
/**
* Passing minimum width enables contextual horizontal scrollbar (i.e. without
* it the table will never display scrollbar - regardless of how small
* the screen is).
*/
minWidth?: number;
}

/**
* A wrapper component for `Table` from `@mantine/core`. It requires column
* headings, column data, and has optional minimum width.
*/
export default function SimpleTable(props: SimpleTableProps) {
const table = (
<Table
data={{head: props.head, body: props.body}}
horizontalSpacing='sm'
verticalSpacing='sm'
/>
);

if (props.minWidth) {
return (
<Table.ScrollContainer minWidth={props.minWidth} type='native'>
{table}
</Table.ScrollContainer>
);
}

return table;
}
Akuukis marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading