-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Components] Add Table component and update navigation links #6372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8a1b0d8
[Components] Add Table component and update navigation links
Souradip121 98d1195
Merge branch 'master' into work-on-table
vishalvivekm 5a4a5e1
Merge branch 'layer5io:master' into work-on-table
Souradip121 9fe7f9c
[Components] Replace Table component with ResponsiveDataTable for imp…
Souradip121 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| import React from "react"; | ||
| import { navigate } from "gatsby"; | ||
| import { useLocation } from "@reach/router"; | ||
| import { | ||
| SistentThemeProvider, | ||
| Table, | ||
| TableBody, | ||
| TableCell, | ||
| TableContainer, | ||
| TableHead, | ||
| TableRow, | ||
| } from "@layer5/sistent"; | ||
| import { SistentLayout } from "../../sistent-layout"; | ||
| import { CodeBlock } from "../button/code-block"; | ||
| import TabButton from "../../../../../reusecore/Button"; | ||
| import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; | ||
|
|
||
| const codes = [ | ||
| // Basic Table | ||
| ` | ||
| <TableContainer> | ||
| <Table> | ||
| <TableHead> | ||
| <TableRow> | ||
| <TableCell>Column 1</TableCell> | ||
| <TableCell>Column 2</TableCell> | ||
| </TableRow> | ||
| </TableHead> | ||
| <TableBody> | ||
| <TableRow> | ||
| <TableCell>Row 1</TableCell> | ||
| <TableCell>Data 1</TableCell> | ||
| </TableRow> | ||
| </TableBody> | ||
| </Table> | ||
| </TableContainer> | ||
| ` | ||
| ]; | ||
|
|
||
| const TableCode = () => { | ||
| const { isDark } = useStyledDarkMode(); | ||
| const location = useLocation(); | ||
|
|
||
| return ( | ||
| <SistentLayout title="Table"> | ||
| <div className="content"> | ||
| <a id="Identity"> | ||
| <h2>Table</h2> | ||
| </a> | ||
| <p> | ||
| To use the Table component from Layer5's Sistent design system, you begin by wrapping your table inside the TableContainer, which provides scrollability and styling. Inside it, the Table acts as the root element that holds the structure. The TableHead defines the table headers using a TableRow filled with TableCell elements for each column title. The TableBody follows, containing the actual data rows. Each data row is created using a TableRow, with individual data values placed inside corresponding TableCell elements. This modular structure allows for clean, accessible, and themable table layouts that integrate seamlessly into your UI. | ||
| </p> | ||
|
|
||
| {/* Navigation Tabs */} | ||
| <div className="filterBtns"> | ||
| <TabButton | ||
| className={location.pathname === "/projects/sistent/components/table" ? "active" : ""} | ||
| onClick={() => navigate("/projects/sistent/components/table")} | ||
| title="Overview" | ||
| /> | ||
| <TabButton | ||
| className={location.pathname === "/projects/sistent/components/table/guidance" ? "active" : ""} | ||
| onClick={() => navigate("/projects/sistent/components/table/guidance")} | ||
| title="Guidance" | ||
| /> | ||
| <TabButton | ||
| className={location.pathname === "/projects/sistent/components/table/code" ? "active" : ""} | ||
| onClick={() => navigate("/projects/sistent/components/table/code")} | ||
| title="Code" | ||
| /> | ||
| </div> | ||
|
|
||
| {/* Basic Table */} | ||
| <h3>Basic Table</h3> | ||
| <div className="showcase"> | ||
| <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> | ||
| <TableContainer> | ||
| <Table> | ||
| <TableHead> | ||
| <TableRow> | ||
| <TableCell>Column 1</TableCell> | ||
| <TableCell>Column 2</TableCell> | ||
| </TableRow> | ||
| </TableHead> | ||
| <TableBody> | ||
| <TableRow> | ||
| <TableCell>Row 1</TableCell> | ||
| <TableCell>Data 1</TableCell> | ||
| </TableRow> | ||
| </TableBody> | ||
| </Table> | ||
| </TableContainer> | ||
| </SistentThemeProvider> | ||
| <CodeBlock name="basic-table" code={codes[0]} /> | ||
| </div> | ||
| </div> | ||
| </SistentLayout> | ||
| ); | ||
| }; | ||
|
|
||
| export default TableCode; | ||
116 changes: 116 additions & 0 deletions
116
src/sections/Projects/Sistent/components/table/guidance.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| import React from "react"; | ||
| import { navigate } from "gatsby"; | ||
| import { useLocation } from "@reach/router"; | ||
| import { | ||
| SistentThemeProvider, | ||
| Table, | ||
| TableHead, | ||
| TableBody, | ||
| TableRow, | ||
| TableCell, | ||
| TableContainer, | ||
| } from "@layer5/sistent"; | ||
| import { SistentLayout } from "../../sistent-layout"; | ||
| import TabButton from "../../../../../reusecore/Button"; | ||
| import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; | ||
|
|
||
| const TableGuidance = () => { | ||
| const location = useLocation(); | ||
| const { isDark } = useStyledDarkMode(); | ||
|
|
||
| return ( | ||
| <SistentLayout title="Table"> | ||
| <div className="content"> | ||
| <a id="Identity"> | ||
| <h2>Table</h2> | ||
| </a> | ||
| <p> | ||
| The <code>Table</code> component from the Sistent design system helps structure and display tabular data with accessibility and consistent styling in mind. It wraps MUI’s native table components to provide an enhanced and theme-friendly experience. | ||
| </p> | ||
|
|
||
| {/* Navigation Tabs */} | ||
| <div className="filterBtns"> | ||
| <TabButton | ||
| className={location.pathname === "/projects/sistent/components/table" ? "active" : ""} | ||
| onClick={() => navigate("/projects/sistent/components/table")} | ||
| title="Overview" | ||
| /> | ||
| <TabButton | ||
| className={location.pathname === "/projects/sistent/components/table/guidance" ? "active" : ""} | ||
| onClick={() => navigate("/projects/sistent/components/table/guidance")} | ||
| title="Guidance" | ||
| /> | ||
| <TabButton | ||
| className={location.pathname === "/projects/sistent/components/table/code" ? "active" : ""} | ||
| onClick={() => navigate("/projects/sistent/components/table/code")} | ||
| title="Code" | ||
| /> | ||
| </div> | ||
|
|
||
| <div className="main-content"> | ||
| <a id="BasicTable"> | ||
| <h2>How to Use</h2> | ||
| </a> | ||
|
|
||
| <p>Here’s a breakdown of each component used to construct a table:</p> | ||
|
|
||
| <ul> | ||
| <li> | ||
| <strong>TableContainer</strong>: Acts as a wrapper around the entire table. Useful for scrollability and border rounding. | ||
| </li> | ||
| <li> | ||
| <strong>Table</strong>: The root element that holds all rows and columns. | ||
| </li> | ||
| <li> | ||
| <strong>TableHead</strong>: Defines the header section of the table. Usually contains one <code>TableRow</code> with multiple <code>TableCell</code> elements as headers. | ||
| </li> | ||
| <li> | ||
| <strong>TableBody</strong>: Wraps all the dynamic content (rows of data). It follows the <code>TableHead</code>. | ||
| </li> | ||
| <li> | ||
| <strong>TableRow</strong>: Represents a single row inside either the head or body. It holds <code>TableCell</code> components. | ||
| </li> | ||
| <li> | ||
| <strong>TableCell</strong>: The actual data cell. Used inside both <code>TableRow</code> in the head and body. | ||
| </li> | ||
| </ul> | ||
|
|
||
| <p>Below is a simple example of how these components come together:</p> | ||
|
|
||
| <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> | ||
| <TableContainer className="overflow-x-auto shadow rounded border border-gray-200 my-6"> | ||
| <Table> | ||
| <TableHead> | ||
| <TableRow> | ||
| <TableCell>Name</TableCell> | ||
| <TableCell>Age</TableCell> | ||
| <TableCell>City</TableCell> | ||
| </TableRow> | ||
| </TableHead> | ||
| <TableBody> | ||
| <TableRow> | ||
| <TableCell>John Doe</TableCell> | ||
| <TableCell>28</TableCell> | ||
| <TableCell>New York</TableCell> | ||
| </TableRow> | ||
| <TableRow> | ||
| <TableCell>Jane Smith</TableCell> | ||
| <TableCell>34</TableCell> | ||
| <TableCell>London</TableCell> | ||
| </TableRow> | ||
| </TableBody> | ||
| </Table> | ||
| </TableContainer> | ||
| </SistentThemeProvider> | ||
|
|
||
| <p> | ||
| You can customize the layout by applying conditional styles, using responsive wrappers, | ||
| or enhancing interactivity with row click handlers, sort functionality, etc. | ||
| </p> | ||
| </div> | ||
| </div> | ||
| </SistentLayout> | ||
| ); | ||
| }; | ||
|
|
||
| export default TableGuidance; |
108 changes: 108 additions & 0 deletions
108
src/sections/Projects/Sistent/components/table/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| import React from "react"; | ||
| import { navigate } from "gatsby"; | ||
| import { useLocation } from "@reach/router"; | ||
| import { | ||
| Table, | ||
| TableHead, | ||
| TableBody, | ||
| TableRow, | ||
| TableCell, | ||
| TableContainer, | ||
| SistentThemeProvider, | ||
| } from "@layer5/sistent"; | ||
| import TabButton from "../../../../../reusecore/Button"; | ||
| import { SistentLayout } from "../../sistent-layout"; | ||
| import { Row } from "../../../../../reusecore/Layout"; | ||
| import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; | ||
|
|
||
| // Sample table data | ||
| const tableData = [ | ||
| { id: 1, name: "John Doe", age: 25, role: "Developer" }, | ||
| { id: 2, name: "Jane Smith", age: 28, role: "Designer" }, | ||
| { id: 3, name: "Sam Wilson", age: 30, role: "Manager" }, | ||
| ]; | ||
|
|
||
| const SistentTable = () => { | ||
| const location = useLocation(); | ||
| const { isDark } = useStyledDarkMode(); | ||
|
|
||
| return ( | ||
| <SistentLayout title="Table"> | ||
| <div className="content"> | ||
| <a id="Identity"> | ||
| <h2>Table</h2> | ||
| </a> | ||
|
|
||
| {/* 🔰 Introduction to Sistent Table */} | ||
| <p> | ||
| The <code>Table</code> component in the Sistent design system is a wrapper | ||
| around MUI’s Table components, offering consistent styling and structure | ||
| aligned with Layer5’s UI philosophy. It helps developers display structured | ||
| data in a clean, responsive, and accessible way with minimal effort. | ||
| </p> | ||
|
|
||
| {/* Navigation Tabs */} | ||
| <div className="filterBtns"> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === "/projects/sistent/components/table" ? "active" : "" | ||
| } | ||
| onClick={() => navigate("/projects/sistent/components/table")} | ||
| title="Overview" | ||
| /> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === "/projects/sistent/components/table/guidance" ? "active" : "" | ||
| } | ||
| onClick={() => navigate("/projects/sistent/components/table/guidance")} | ||
| title="Guidance" | ||
| /> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === "/projects/sistent/components/table/code" ? "active" : "" | ||
| } | ||
| onClick={() => navigate("/projects/sistent/components/table/code")} | ||
| title="Code" | ||
| /> | ||
| </div> | ||
|
|
||
| {/* Basic Table */} | ||
| <div className="main-content"> | ||
| <a id="Basic Usage"> | ||
| <h2>Basic Usage</h2> | ||
| </a> | ||
| <p>A simple table displaying structured data with column headers and rows.</p> | ||
|
|
||
| <Row $Hcenter className="image-container"> | ||
| <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> | ||
| <TableContainer className="border border-gray-200 rounded shadow-md overflow-auto"> | ||
| <Table> | ||
| <TableHead> | ||
| <TableRow> | ||
| <TableCell>ID</TableCell> | ||
| <TableCell>Name</TableCell> | ||
| <TableCell>Age</TableCell> | ||
| <TableCell>Role</TableCell> | ||
| </TableRow> | ||
| </TableHead> | ||
| <TableBody> | ||
| {tableData.map((row) => ( | ||
| <TableRow key={row.id}> | ||
| <TableCell>{row.id}</TableCell> | ||
| <TableCell>{row.name}</TableCell> | ||
| <TableCell>{row.age}</TableCell> | ||
| <TableCell>{row.role}</TableCell> | ||
| </TableRow> | ||
| ))} | ||
| </TableBody> | ||
| </Table> | ||
| </TableContainer> | ||
| </SistentThemeProvider> | ||
| </Row> | ||
| </div> | ||
| </div> | ||
| </SistentLayout> | ||
| ); | ||
| }; | ||
|
|
||
| export default SistentTable; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use this table , we have already a component named responsive table in place use that to document. Including how columns and search are displayed as optional for tables. Checkout sistent and meshery for actual component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you referring to ResponsiveDataTable @sudhanshutech ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Souradip121 yes.