Skip to content

Commit

Permalink
basic example
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneeza committed Feb 3, 2025
1 parent 5768f7b commit 1bbc630
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 21 deletions.
4 changes: 2 additions & 2 deletions packages/table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"@leafygreen-ui/palette": "workspace:^",
"@leafygreen-ui/polymorphic": "workspace:^",
"@leafygreen-ui/tokens": "workspace:^",
"@leafygreen-ui/tooltip": "workspace:^",
"@leafygreen-ui/typography": "workspace:^",
"@lg-tools/test-harnesses": "workspace:^",
"@tanstack/react-table": "^8.20.5",
Expand All @@ -46,7 +45,8 @@
"@leafygreen-ui/code": "workspace:^",
"@leafygreen-ui/button": "workspace:^",
"@leafygreen-ui/badge": "workspace:^",
"@leafygreen-ui/pagination": "workspace:^"
"@leafygreen-ui/pagination": "workspace:^",
"@leafygreen-ui/tooltip": "workspace:^"
},
"peerDependencies": {
"@leafygreen-ui/leafygreen-provider": "workspace:^"
Expand Down
41 changes: 29 additions & 12 deletions packages/table/src/Cell/InternalCellWithoutRT.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,36 @@ import { InternalCellProps } from '.';
const InternalCellWithoutRT = forwardRef<
HTMLTableCellElement,
InternalCellProps
>(({ children, className, ...rest }: InternalCellProps, fwdRef) => {
const { shouldTruncate = true } = useTableContext();
>(
(
{
children,
className,
overrideTruncation = false,
...rest
}: InternalCellProps,
fwdRef,
) => {
const { shouldTruncate = true } = useTableContext();

return (
<InternalCellBase
ref={fwdRef}
className={cx(getCellStyles(), className)}
{...rest}
>
<div className={getCellEllipsisStyles(shouldTruncate)}>{children}</div>
</InternalCellBase>
);
});
return (
<InternalCellBase
ref={fwdRef}
className={cx(getCellStyles(), className)}
{...rest}
>
<div
className={getCellEllipsisStyles({
shouldTruncate,
overrideTruncation,
})}
>
{children}
</div>
</InternalCellBase>
);
},
);

InternalCellWithoutRT.displayName = 'InternalCellWithoutRT';

Expand Down
26 changes: 25 additions & 1 deletion packages/table/src/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,26 @@ const Template: StoryFn<StoryTableProps> = args => {
{data.map((row: AnyDict) => (
<Row key={row.id}>
{Object.keys(row).map((cellKey: string, index: number) => {
return <Cell key={`${cellKey}-${index}`}>{row[cellKey]}</Cell>;
return (
<Cell
key={`${cellKey}-${index}`}
overrideTruncation={index === 6}
>
{index === 6 ? (
<Tooltip
trigger={
<Button type="button" size="small">
{row[cellKey]}
</Button>
}
>
{"I'm leafy, you're leafy"}
</Tooltip>
) : (
row[cellKey]
)}
</Cell>
);
})}
</Row>
))}
Expand Down Expand Up @@ -492,6 +511,11 @@ export const WithButtons: StoryFn<StoryTableProps> = args => {
</Table>
);
};
WithButtons.parameters = {
chromatic: {
disableSnapshot: true,
},
};

export const NoTruncation = LiveExample.bind({});
NoTruncation.args = {
Expand Down
3 changes: 0 additions & 3 deletions packages/table/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@
{
"path": "../tokens"
},
{
"path": "../tooltip"
},
{
"path": "../typography"
},
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1bbc630

Please sign in to comment.