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

feat: add shadow on the left of the columns #288

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions src/components/TableV2/base/HeaderCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export interface HeaderCellProps
* Show a shadow when cell is sticky
*/
stickyShadow?: boolean
/**
* Show a shadow when cell is sticky in left
*/
leftStickyShadow?: boolean
}

const HeaderCell = ({
Expand All @@ -60,6 +64,7 @@ const HeaderCell = ({
sortValue,
align = 'left',
stickyShadow,
leftStickyShadow,
...props
}: HeaderCellProps) => {
const [sort, setSort] = useState<SortType>(sortValue ? sortValue : 'DESC')
Expand All @@ -84,6 +89,7 @@ const HeaderCell = ({
className={composeClasses(
props.className,
stickyShadow && 'sticky-shadow',
leftStickyShadow && 'left-sticky-shadow',
'h-8 px-2 text-[10px] text-gray-700 font-semibold'
)}
style={{
Expand Down
6 changes: 6 additions & 0 deletions src/components/TableV2/base/TableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export interface CellProps
* Show a shadow when cell is sticky
*/
stickyShadow?: boolean
/**
* Show a shadow when cell is sticky left
*/
leftStickyShadow?: boolean
}

const Cell = ({
Expand All @@ -100,6 +104,7 @@ const Cell = ({
type = 'text',
align = 'left',
stickyShadow,
leftStickyShadow,
indexCell,
onEdit,
textClassName,
Expand Down Expand Up @@ -149,6 +154,7 @@ const Cell = ({
{...props}
className={composeClasses(
stickyShadow && 'sticky-shadow',
leftStickyShadow && 'left-sticky-shadow',
disabled && 'text-gray-200',
error && 'error-100',
inputProps && 'p-0',
Expand Down
15 changes: 15 additions & 0 deletions src/components/TableV2/base/tableV2.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,19 @@
box-shadow: 4px 0px 6px 0px #adafb5;
transform: translateZ(0);
-webkit-transform: translateZ(0);
}

.tableV2-container-cmpnt thead tr th.left-sticky-shadow::after,
.tableV2-container-cmpnt tbody tr td.left-sticky-shadow::after {
content: '';
position: absolute;
bottom: 0px;
left: 0px;
width: 1px;
height: 100%;
z-index: 2;
background-color: #adafb5;
box-shadow: -4px 0px 6px 0px #adafb5;
transform: translateZ(0);
-webkit-transform: translateZ(0);
}
13 changes: 13 additions & 0 deletions src/stories/TableV2.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ const Template: ComponentStory<typeof TableV2Comp> = (_args) => {
Column Head
</TableV2Comp.HeaderCell>
))}
<TableV2Comp.HeaderCell
style={{ minWidth: 108 }}
leftStickyShadow
stickyRight="0px"
>
Column Head
</TableV2Comp.HeaderCell>
</TableV2Comp.HeaderRow>
</TableV2Comp.Header>
<TableV2Comp.Body>
Expand All @@ -56,6 +63,9 @@ const Template: ComponentStory<typeof TableV2Comp> = (_args) => {
{columns.map((val) => (
<TableV2Comp.Cell key={val}>Cell</TableV2Comp.Cell>
))}
<TableV2Comp.Cell leftStickyShadow stickyRight="0px">
Cell
</TableV2Comp.Cell>
</TableV2Comp.Row>
<TableV2Comp.Row>
<TableV2Comp.Cell stickyShadow stickyLeft="0px">
Expand All @@ -64,6 +74,9 @@ const Template: ComponentStory<typeof TableV2Comp> = (_args) => {
{columns.map((val) => (
<TableV2Comp.Cell key={val}>Cell</TableV2Comp.Cell>
))}
<TableV2Comp.Cell leftStickyShadow stickyRight="0px">
Cell
</TableV2Comp.Cell>
</TableV2Comp.Row>
</TableV2Comp.Body>
</TableV2Comp>
Expand Down