diff --git a/packages/index.ts b/packages/index.ts index 63bbd0ac8..a8330f475 100644 --- a/packages/index.ts +++ b/packages/index.ts @@ -1,3 +1,7 @@ +import { injectGlobalCss } from "./shared/styles/global"; + export { Badge } from "./badge"; export { BadgeButton } from "./badge"; export { Column, Table, Cell, TextCell, HeaderCell } from "./table"; + +injectGlobalCss(); diff --git a/packages/shared/styles/global.ts b/packages/shared/styles/global.ts new file mode 100644 index 000000000..6f48979ff --- /dev/null +++ b/packages/shared/styles/global.ts @@ -0,0 +1,9 @@ +import { injectGlobal } from "emotion"; + +export const injectGlobalCss = () => { + return injectGlobal` + .ReactVirtualized__Grid { + outline: none; + } + `; +}; diff --git a/packages/table/components/Table.tsx b/packages/table/components/Table.tsx index d0e292eff..fb9a6e1e5 100644 --- a/packages/table/components/Table.tsx +++ b/packages/table/components/Table.tsx @@ -1,9 +1,11 @@ import * as React from "react"; import { css } from "emotion"; import { AutoSizer, MultiGrid, GridCellProps } from "react-virtualized"; + +import { headerCss, cellCss, tableCss } from "../style"; + import { IColumnProps, Column } from "./Column"; import memoizeOne from "memoize-one"; -import { coreColors as Colors } from "../../shared/styles/color"; export interface ITableProps { /** @@ -61,6 +63,7 @@ export class Table extends React.PureComponent { return ( extends React.PureComponent { } ) { const { key, style, column } = args; - const className = css({ - boxSizing: "border-box", - borderBottom: `1px solid ${Colors().black}`, + const className = css(headerCss, { ...style }); return ( @@ -145,9 +146,7 @@ export class Table extends React.PureComponent { } ) { const { style, key, column, data, rowIndex } = args; - const className = css({ - borderBottom: `1px solid ${Colors().greyLight}`, - boxSizing: "border-box", + const className = css(cellCss, { ...style }); return ( diff --git a/packages/table/stories/Table.stories.tsx b/packages/table/stories/Table.stories.tsx index 5aaf3eb35..fb48c0e8c 100644 --- a/packages/table/stories/Table.stories.tsx +++ b/packages/table/stories/Table.stories.tsx @@ -41,7 +41,7 @@ const cityCellRenderer = ({ city }: { city?: string }) => ( ); const roleCellRenderer = ({ role }: { role?: string }) => ( - {role} + {role} ); const stateCellRenderer = ({ state }: { state?: string }) => ( @@ -136,7 +136,7 @@ storiesOf("Table", module) width={width} /> zipcode} + header={zip code} cellRenderer={zipcodeCellRenderer} width={width} /> diff --git a/packages/table/style.ts b/packages/table/style.ts new file mode 100644 index 000000000..23934ac2f --- /dev/null +++ b/packages/table/style.ts @@ -0,0 +1,24 @@ +import { css } from "emotion"; +import { coreColors } from "../shared/styles/color"; +import { coreFonts } from "../shared/styles/typography"; + +const { black, greyLight } = coreColors(); +const { fontFamilySansSerif } = coreFonts(); + +export const headerCss = css` + box-sizing: border-box; + font-family: ${fontFamilySansSerif}; + border-top: 1px solid ${black}; + border-bottom: 1px solid ${black}; +`; + +export const cellCss = css` + box-sizing: border-box; + font-family: ${fontFamilySansSerif}; + border-bottom: 1px solid ${greyLight}; +`; + +export const tableCss = css` + font-family: ${fontFamilySansSerif}; + font-weight: normal; +`; diff --git a/packages/table/tests/__snapshots__/Table.test.tsx.snap b/packages/table/tests/__snapshots__/Table.test.tsx.snap index cbb60adf0..2ea09f970 100644 --- a/packages/table/tests/__snapshots__/Table.test.tsx.snap +++ b/packages/table/tests/__snapshots__/Table.test.tsx.snap @@ -1,6 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Table renders again with new data 1`] = ` +.emotion-0 { + font-family: -apple-system,BlinkMacSystemFont,'Segoe UI','Helvetica','Arial',sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'; + font-weight: normal; +} +