generated from gravity-ui/package-example
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Table): base border/font design
- Loading branch information
Showing
49 changed files
with
367 additions
and
154 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import {block} from '../../utils'; | ||
|
||
export const b = block('styled-table'); |
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,25 @@ | ||
@use '@gravity-ui/uikit/styles/mixins'; | ||
@use '../variables'; | ||
|
||
$block: '.#{variables.$ns}styled-table'; | ||
|
||
#{$block} { | ||
&__header { | ||
background: var(--g-color-base-background); | ||
} | ||
|
||
&__cell { | ||
@include mixins.text-body-1(); | ||
} | ||
|
||
&__header-cell { | ||
@include mixins.text-subheader-1(); | ||
} | ||
|
||
&__cell, | ||
&__header-cell, | ||
&__footer-cell { | ||
padding: 11px var(--g-spacing-2) 10px; | ||
border-block-end: 1px solid var(--g-color-line-generic); | ||
} | ||
} |
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,55 @@ | ||
import React from 'react'; | ||
|
||
import {BaseTable} from '../BaseTable'; | ||
import type {BaseTableProps} from '../BaseTable'; | ||
|
||
import {b} from './Table.classname'; | ||
|
||
import './Table.scss'; | ||
|
||
export interface TableProps<TData, TScrollElement extends Element | Window = HTMLDivElement> | ||
extends BaseTableProps<TData, TScrollElement> {} | ||
|
||
export const Table = React.forwardRef( | ||
<TData, TScrollElement extends Element | Window = HTMLDivElement>( | ||
{ | ||
className, | ||
cellClassName: cellClassNameProp, | ||
footerCellClassName, | ||
headerCellClassName: headerCellClassNameProp, | ||
headerClassName, | ||
...props | ||
}: TableProps<TData, TScrollElement>, | ||
ref: React.Ref<HTMLTableElement>, | ||
) => { | ||
const cellClassName: TableProps<TData>['cellClassName'] = React.useMemo(() => { | ||
if (typeof cellClassNameProp === 'function') { | ||
return (...params) => b('cell', cellClassNameProp(...params)); | ||
} | ||
return b('cell', cellClassNameProp); | ||
}, [cellClassNameProp]); | ||
|
||
const headerCellClassName: TableProps<TData>['headerCellClassName'] = React.useMemo(() => { | ||
if (typeof headerCellClassNameProp === 'function') { | ||
return (...params) => b('header-cell', headerCellClassNameProp(...params)); | ||
} | ||
return b('header-cell', headerCellClassNameProp); | ||
}, [headerCellClassNameProp]); | ||
|
||
return ( | ||
<BaseTable | ||
ref={ref} | ||
className={b(null, className)} | ||
cellClassName={cellClassName} | ||
footerCellClassName={b('footer-cell', footerCellClassName)} | ||
headerCellClassName={headerCellClassName} | ||
headerClassName={b('header', headerClassName)} | ||
{...props} | ||
/> | ||
); | ||
}, | ||
) as (<TData, TScrollElement extends Element | Window = HTMLDivElement>( | ||
props: TableProps<TData, TScrollElement> & {ref?: React.Ref<HTMLTableElement>}, | ||
) => React.ReactElement) & {displayName: string}; | ||
|
||
Table.displayName = 'Table'; |
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 './Table'; |
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
This file was deleted.
Oops, something went wrong.
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 React from 'react'; | ||
|
||
import type {Meta, StoryFn} from '@storybook/react'; | ||
|
||
import {Table} from '../Table'; | ||
|
||
import {DefaultDemo} from './components/Table/DefaultDemo'; | ||
import {StickyHeaderDemo} from './components/Table/StickyHeaderDemo'; | ||
import {VirtualizationDemo} from './components/Table/VirtualizationDemo'; | ||
import {WindowVirtualizationDemo} from './components/Table/WindowVirtualizationDemo'; | ||
|
||
export default { | ||
title: 'Table', | ||
component: Table, | ||
} as Meta<typeof Table>; | ||
|
||
const DefaultTemplate: StoryFn = () => <DefaultDemo />; | ||
export const Default: StoryFn = DefaultTemplate.bind({}); | ||
|
||
const VirtualizationTemplate: StoryFn = () => <VirtualizationDemo />; | ||
export const Virtualization: StoryFn = VirtualizationTemplate.bind({}); | ||
|
||
const WindowVirtualizationTemplate: StoryFn = () => <WindowVirtualizationDemo />; | ||
export const WindowVirtualization: StoryFn = WindowVirtualizationTemplate.bind({}); | ||
|
||
const StickyHeaderTamplate: StoryFn = () => <StickyHeaderDemo />; | ||
export const StickyHeader: StoryFn = StickyHeaderTamplate.bind({}); |
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
2 changes: 1 addition & 1 deletion
2
..._stories__/ColumnPinningDemo.classname.ts → .../BaseTable/ColumnPinningDemo.classname.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import {cn} from '../../utils'; | ||
import {cn} from '../../../../utils'; | ||
|
||
export const cnColumnPinningDemo = cn('column-pinning-demo'); |
File renamed without changes.
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
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
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
15 changes: 15 additions & 0 deletions
15
src/components/__stories__/components/BaseTable/DefaultDemo.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,15 @@ | ||
import React from 'react'; | ||
|
||
import {useTable} from '../../../../hooks'; | ||
import {BaseTable} from '../../../BaseTable'; | ||
import {columns} from '../../constants/columns'; | ||
import {data} from '../../constants/data'; | ||
|
||
export const DefaultDemo = () => { | ||
const table = useTable({ | ||
columns, | ||
data, | ||
}); | ||
|
||
return <BaseTable table={table} />; | ||
}; |
2 changes: 1 addition & 1 deletion
2
...nts/__stories__/EmptyContent.classname.ts → ...nents/BaseTable/EmptyContent.classname.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import {cn} from '../../utils'; | ||
import {cn} from '../../../../utils'; | ||
|
||
export const cnEmptyContentDemo = cn('empty-content-demo'); |
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
src/components/__stories__/EmptyContent.tsx → ...s__/components/BaseTable/EmptyContent.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
2 changes: 1 addition & 1 deletion
2
...nts/__stories__/GroupingDemo.classname.ts → ...nents/BaseTable/GroupingDemo.classname.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import {cn} from '../../utils'; | ||
import {cn} from '../../../../utils'; | ||
|
||
export const cnGroupingDemo = cn('grouping-demo'); |
File renamed without changes.
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
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
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
2 changes: 1 addition & 1 deletion
2
...__stories__/HeaderGroupsDemo.classname.ts → ...s/BaseTable/HeaderGroupsDemo.classname.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import {cn} from '../../utils'; | ||
import {cn} from '../../../../utils'; | ||
|
||
export const cnHeaderGroupsDemo = cn('header-groups-demo'); |
File renamed without changes.
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.