Skip to content

Commit

Permalink
fix(Table): passing ref as prop
Browse files Browse the repository at this point in the history
  • Loading branch information
LamaEats committed Aug 17, 2023
1 parent ab1969a commit 8845a43
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
26 changes: 17 additions & 9 deletions src/components/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { forwardRef } from 'react';
import styled, { css } from 'styled-components';
import { gray4, gray6 } from '@taskany/colors';

Expand Down Expand Up @@ -70,8 +70,10 @@ const mapRuleSet: { [key in AlignProps['align'] | JustifyProps['justify']]: stri
between: 'space-between',
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const Table = styled(({ gap, width, ...props }: TableProps) => <div {...props} />)`
export const Table = styled(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
forwardRef<HTMLDivElement, TableProps>(({ gap, width, ...props }, ref) => <div {...props} ref={ref} />),
)`
display: flex;
flex-direction: column;
Expand All @@ -88,10 +90,12 @@ export const Table = styled(({ gap, width, ...props }: TableProps) => <div {...p
`}
`;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const TableRow = styled(({ gap, interactive, focused, justify, align, ...props }: TableRowProps) => (
<div {...props} />
))`
export const TableRow = styled(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
forwardRef<HTMLDivElement, TableRowProps>(({ gap, interactive, focused, justify, align, ...props }, ref) => (
<div {...props} ref={ref} />
)),
)`
display: flex;
flex-basis: 100%;
align-items: flex-start;
Expand Down Expand Up @@ -131,8 +135,12 @@ export const TableRow = styled(({ gap, interactive, focused, justify, align, ...
`}
`;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const TableCell = styled(({ col, min, justify, align, width, ...props }: TableCellProps) => <div {...props} />)`
export const TableCell = styled(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
forwardRef<HTMLDivElement, TableCellProps>(({ col, min, justify, align, width, ...props }, ref) => (
<div {...props} ref={ref} />
)),
)`
display: inline-flex;
align-items: baseline;
flex-wrap: wrap;
Expand Down
4 changes: 2 additions & 2 deletions src/stories/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const Default: Story = () => {
</TableCell>
<TableCell justify="end">
{tags.map((t) => (
<Tag size="s" title={t} />
<Tag size="s">{t}</Tag>
))}
</TableCell>
<TableCell min justify="center">
Expand Down Expand Up @@ -202,7 +202,7 @@ export const FocusAndHover: Story = () => {
</TableCell>
<TableCell justify="end">
{tags.map((t) => (
<Tag size="s" title={t} />
<Tag size="s">{t}</Tag>
))}
</TableCell>
<TableCell min justify="center">
Expand Down

0 comments on commit 8845a43

Please sign in to comment.