Skip to content

Commit

Permalink
chore(react): add table sticky header
Browse files Browse the repository at this point in the history
  • Loading branch information
cafrias committed Nov 26, 2024
1 parent 335444e commit a314c2d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
13 changes: 11 additions & 2 deletions packages/core/src/components/table/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
--header-text: var(--header-text-ghost);
--sort-button-text: var(--sort-button-background);

border: none;
border-color: transparent;

tbody {
border: 1px solid var(--border-out-color);
Expand All @@ -134,7 +134,7 @@
--sort-button-text: var(--sort-button-background);

& tbody {
border-top: 1px solid var(--cell-border-color);
border-top: 1px groove var(--cell-border-color);
}
}

Expand Down Expand Up @@ -208,6 +208,15 @@
@include ghost;
}

.nds-table--sticky {
& thead {
@include device.media-up('sm') {
position: sticky;
top: -1px;
}
}
}

.nds-table-sort-button {
display: none;
padding: 0;
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/components/Table/BaseTable/BaseTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const BaseTable = ({
variant = 'solid',
color = 'navy',
className,
stickyHeader = false,
...others
}: BaseTableProps) => {
const resolvedClassName = classNames(
Expand All @@ -23,6 +24,7 @@ export const BaseTable = ({
[`nds-table--${variant}`]: !!variant,
[`nds-table--${color}`]: !!color,
'nds-table--striped': !isNotStriped,
'nds-table--sticky': stickyHeader,
},
className,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Table/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default meta;

type Story = StoryObj<typeof Table>;

const ROWS = 10;
const ROWS = 50;

const data: TableData = {
headers: [
Expand Down

0 comments on commit a314c2d

Please sign in to comment.