Skip to content

Commit

Permalink
feat(uikit): Td & Th components (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
hachiojidev authored Aug 6, 2021
1 parent 70a8afb commit c7f4283
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
16 changes: 16 additions & 0 deletions packages/pancake-uikit/src/components/Table/Cell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import styled from "styled-components";
import { typography, TypographyProps } from "styled-system";

export const Td = styled.td<TypographyProps>`
border-bottom: 1px solid ${({ theme }) => theme.colors.cardBorder};
color: ${({ theme }) => theme.colors.text};
padding: 16px;
${typography}
`;

export const Th = styled(Td).attrs({ as: "th" })`
color: ${({ theme }) => theme.colors.secondary};
font-size: 12px;
text-transform: uppercase;
`;
16 changes: 2 additions & 14 deletions packages/pancake-uikit/src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
import styled from "styled-components";
import { space } from "styled-system";
import { Td } from "./Cell";

const Table = styled.table`
max-width: 100%;
width: 100%;
th,
td {
border-bottom: 1px solid ${({ theme }) => theme.colors.cardBorder};
color: ${({ theme }) => theme.colors.text};
padding: 16px;
}
th {
color: ${({ theme }) => theme.colors.secondary};
font-size: 12px;
text-transform: uppercase;
}
tr:last-child {
td {
${Td} {
border-bottom: 0;
}
}
Expand Down
19 changes: 10 additions & 9 deletions packages/pancake-uikit/src/components/Table/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import Card from "../Card/Card";
import Table from "./Table";
import { Th, Td } from "./Cell";

export default {
title: "Components/Table",
Expand All @@ -15,21 +16,21 @@ export const Default: React.FC = () => {
<Table>
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<Th textAlign="left">Column 1</Th>
<Th>Column 2</Th>
<Th>Column 3</Th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell 1-1</td>
<td>Cell 1-2</td>
<td>Cell 1-3</td>
<Td>Cell 1-1</Td>
<Td>Cell 1-2</Td>
<Td>Cell 1-3</Td>
</tr>
<tr>
<td>Cell 2-1</td>
<td>Cell 2-2</td>
<td>Cell 2-3</td>
<Td>Cell 2-1</Td>
<Td>Cell 2-2</Td>
<Td>Cell 2-3</Td>
</tr>
</tbody>
</Table>
Expand Down
1 change: 1 addition & 0 deletions packages/pancake-uikit/src/components/Table/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as Table } from "./Table";
export * from "./Cell";
export * from "./hooks";
export * from "./types";
export * from "./utils";

0 comments on commit c7f4283

Please sign in to comment.