-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add Table footer component to `eds-core-react` - Implemented the Table footer component with optional sticky property for a fixed footer. - Updated `Table.docs.mdx` to include documentation for the Table footer. - Added Table footer to the storybook to showcase various use cases. - Updated test suites to cover edge cases and ensure proper functionality of the Table footer. * feat(eds-data-grid): add Table Footer component feat(eds-data-grid): add Table Footer component - Added the possibility to show a footer in the data grid. - Enabled the option to make the footer fixed. - Added `footerClass` and `footerStyle` as component props for custom styling. - Updated docs and stories to include the new footer functionality. - Updated test suites to cover edge cases and ensure proper functionality of the Table Footer. chore: extract Resizer and TableCell components -`Resizer` is now a separate module to enhance reusability and scalability. - Renamed `Cell` to `TableCell` and moved it to a separate module for better reusability and scalability.
- Loading branch information
1 parent
a5dca55
commit 5f8015c
Showing
25 changed files
with
1,276 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/eds-core-react/src/components/Table/Foot/Foot.tokens.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { tokens } from '@equinor/eds-tokens' | ||
import type { ComponentToken } from '@equinor/eds-tokens' | ||
|
||
const { | ||
colors: { | ||
ui: { | ||
background__medium: { rgba: borderColor }, | ||
}, | ||
interactive: { | ||
table__header__fill_resting: { rgba: backgroundColor }, | ||
}, | ||
}, | ||
} = tokens | ||
|
||
export const token: ComponentToken = { | ||
background: backgroundColor, | ||
border: { | ||
type: 'bordergroup', | ||
bottom: { | ||
type: 'border', | ||
width: '2px', | ||
color: borderColor, | ||
style: 'solid', | ||
}, | ||
}, | ||
} |
27 changes: 27 additions & 0 deletions
27
packages/eds-core-react/src/components/Table/Foot/Foot.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { HTMLAttributes, forwardRef } from 'react' | ||
import styled from 'styled-components' | ||
import { token } from './Foot.tokens' | ||
import { bordersTemplate } from '@equinor/eds-utils' | ||
import { InnerContext } from '../Inner.context' | ||
|
||
const StyledTableFoot = styled.tfoot` | ||
${bordersTemplate(token.border)} | ||
background: ${token.background}; | ||
` | ||
|
||
export type FootProps = { | ||
/** Footer will stick to bottom when scrolling */ | ||
sticky?: boolean | ||
} & HTMLAttributes<HTMLTableSectionElement> | ||
|
||
export const Foot = forwardRef<HTMLTableSectionElement, FootProps>( | ||
function Foot({ children, sticky, ...props }, ref) { | ||
return ( | ||
<InnerContext.Provider value={{ variant: 'foot', sticky }}> | ||
<StyledTableFoot {...props} ref={ref}> | ||
{children} | ||
</StyledTableFoot> | ||
</InnerContext.Provider> | ||
) | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './Foot' |
69 changes: 69 additions & 0 deletions
69
packages/eds-core-react/src/components/Table/FooterCell/FooterCell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { ThHTMLAttributes, forwardRef } from 'react' | ||
import styled, { css, ThemeProvider } from 'styled-components' | ||
import { | ||
typographyTemplate, | ||
spacingsTemplate, | ||
bordersTemplate, | ||
useToken, | ||
} from '@equinor/eds-utils' | ||
import { | ||
token as tableFoot, | ||
TableHeadToken as TableFootToken, | ||
} from './../HeaderCell/HeaderCell.tokens' // Use Header cell tokens as default | ||
import { useEds } from '../../EdsProvider' | ||
|
||
type BaseProps = { | ||
theme: TableFootToken | ||
$sticky: boolean | ||
} | ||
|
||
const StyledTableCell = styled.th((props: BaseProps) => { | ||
const { theme, $sticky } = props | ||
const { background, height, typography, spacings } = theme | ||
|
||
return css` | ||
min-height: ${height}; | ||
height: ${height}; | ||
background: ${background}; | ||
box-sizing: border-box; | ||
${spacingsTemplate(spacings)} | ||
${typographyTemplate(typography)} | ||
${bordersTemplate(theme.border)} | ||
${$sticky | ||
? css` | ||
position: sticky; | ||
bottom: 0; | ||
z-index: 2; | ||
` | ||
: ''} | ||
` | ||
}) | ||
|
||
const CellInner = styled.div` | ||
display: flex; | ||
align-items: center; | ||
` | ||
|
||
type CellProps = { | ||
sticky?: boolean | ||
} & ThHTMLAttributes<HTMLTableCellElement> | ||
|
||
export const TableFooterCell = forwardRef<HTMLTableCellElement, CellProps>( | ||
function TableFooterCell({ children, sticky, ...rest }, ref) { | ||
const { density } = useEds() | ||
const token = useToken({ density }, tableFoot) | ||
const props = { | ||
ref, | ||
$sticky: sticky, | ||
...rest, | ||
} | ||
|
||
return ( | ||
<ThemeProvider theme={token}> | ||
<StyledTableCell {...props}> | ||
<CellInner>{children}</CellInner> | ||
</StyledTableCell> | ||
</ThemeProvider> | ||
) | ||
}, | ||
) |
1 change: 1 addition & 0 deletions
1
packages/eds-core-react/src/components/Table/FooterCell/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './FooterCell' |
6 changes: 3 additions & 3 deletions
6
packages/eds-core-react/src/components/Table/Inner.context.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { createContext } from 'react' | ||
|
||
type State = { | ||
variant: 'body' | 'head' | ||
variant: 'body' | 'head' | 'foot' | ||
sticky?: boolean | ||
} | ||
|
||
const initalState: State = { | ||
const initialState: State = { | ||
variant: 'body', | ||
} | ||
|
||
export const InnerContext = createContext<State>(initalState) | ||
export const InnerContext = createContext<State>(initialState) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.