1.1.1 • Published 1 year ago

react-styled-table v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago
  • Run Storybook to test UI
npm run storybook
  • Example Code
import { Table, Tbody, Td, Th, Thead, Tr, TextAlign } from "styled-react-table";

const theme = {
  tableStyle: {
    breakpoints: {
      mobile: "@media only screen and (max-width: 768px)",
      tablet: "@media only screen and (max-width: 992px)",
      desktop: "@media only screen and (min-width: 1200px)"
    },
    colors: {
      primary: "#7256f8",
      secondary: "#EFEDFD",
      dark: "#000000",
      light: "#FFFFFF",

      primaryColorScaleOne: "#EFEDFD",
      primaryColorScaleTwo: "#DEDAFA",

      fontColor: "#000000",

      grayScaleLevelOne: "#f7f7f7",
      grayScaleLevelTwo: "#a8a8a8",

      tableHeader: "#f7f7f7",
      tableBorderColor: "#e1e1e1"
    },

    fontSize: {
      mobile: "16px",
      tablet: "18px",
      desktop: "20px"
    }
  }
};

export interface Operations {
  id: string;
  operator: string;
  headsetDisplay: string;
  availability: string;
}

export interface TablePropsType {
  tableData: Operations[];
};

const headers = [
  {
    name: "Operator",
    textAlign: TextAlign.START
  },
  {
    name: "Headset Display",
    textAlign: TextAlign.START
  },
  {
    name: "3G Availability",
    textAlign: TextAlign.START
  }
];


const App: React.FC<TablePropsType> = (props) => {
  const { tableData } = props;

  return (
    <Table theme={theme}>
      <Thead>
        <Tr>
          {headers.map((header, index) => (
            <Th key={index} textAlign={header.textAlign}>
              {header.name}
            </Th>
          ))}
        </Tr>
      </Thead>
      <Tbody>
        {tableData?.map((company: Operations) => (
          <Tr key={company.id} id={company.id}>
            <Td firstColumn>{company.operator}</Td>
            <Td>{company.headsetDisplay}</Td>
            <Td lastColumn>{company.availability}</Td>
          </Tr>
        ))}
      </Tbody>
    </Table>
  );
};

export default App;

Demo

1.1.1

1 year ago

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago