-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix(sistent): Added Table component documentation #7692
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
Open
kanishksingh23
wants to merge
19
commits into
layer5io:master
Choose a base branch
from
kanishksingh23:fix/sistent-table-docs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+508
−0
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
15bd901
fix(sistent): add Table component documentation
kanishksingh23 f8d86bd
fix(sistent): fix Table docs formatting and add ThemeWrapper CodeBlock
kanishksingh23 6ae4068
fix(sistent): add missing imports to Table code.mdx
kanishksingh23 a839e49
fix(sistent): remove live JSX preview from code.mdx to fix build
kanishksingh23 f37c07a
fix(sistent): add live preview demos to Table code.mdx
kanishksingh23 d6a2ff2
fix(sistent): remove TableFooter and TablePagination from live demo
kanishksingh23 30ff088
fix(sistent): improve paginated table with MUI pagination and richer …
kanishksingh23 6127af9
Merge branch 'master' into fix/sistent-table-docs
Rajesh-Nagarajan-11 f9072a7
fix(sistent): rewrite all table demos using ResponsiveDataTable from …
kanishksingh23 da58a9a
fix(sistent): use client-side only import for ResponsiveDataTable to …
kanishksingh23 c30f63d
fix(sistent): guard ResponsiveDataTable demos against SSR with mounte…
kanishksingh23 b253725
fix(sistent): move mounted check after all hooks to fix React hooks o…
kanishksingh23 c8859df
fix(sistent): fix selectable rows state and replace names with generi…
kanishksingh23 60897e6
fix(sistent): move selectable table data outside component for stable…
kanishksingh23 f00b30a
fix(sistent): use useMemo for stable refs in SelectableTableDemo
kanishksingh23 7149e0e
fix(sistent): remove unsupported selection state from SelectableTable…
kanishksingh23 ef7a6aa
Merge branch 'master' into fix/sistent-table-docs
kanishksingh23 e1d7768
Merge branch 'master' into fix/sistent-table-docs
kanishksingh23 469d4a0
Merge branch 'master' into fix/sistent-table-docs
Rajesh-Nagarajan-11 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
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rishiraj38, I have addressed all the feedback.
|
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,380 @@ | ||
| --- | ||
| title: Table Code | ||
| component: table | ||
| description: A table displays structured data in rows and columns, enabling users to scan, compare, and interact with information efficiently. | ||
| --- | ||
|
|
||
| import { useState, useEffect, useMemo } from "react"; | ||
| import { ResponsiveDataTable } from "@sistent/sistent"; | ||
|
|
||
| export const BasicTableDemo = () => { | ||
| const [mounted, setMounted] = useState(false); | ||
| useEffect(() => setMounted(true), []); | ||
| const columns = [ | ||
| { name: "name", label: "Name" }, | ||
| { name: "env", label: "Environment" }, | ||
| { name: "status", label: "Status" }, | ||
| ]; | ||
| const data = [ | ||
| ["meshery", "production", "Running"], | ||
| ["nighthawk", "staging", "Stopped"], | ||
| ["kanvas", "development", "Running"], | ||
| ]; | ||
| const [tableCols, updateCols] = useState(columns); | ||
| const [columnVisibility, setColumnVisibility] = useState({}); | ||
| const options = { | ||
| filter: false, download: false, print: false, viewColumns: false, | ||
| selectableRows: "none", responsive: "standard", pagination: false, | ||
| search: false, elevation: 1, | ||
| }; | ||
| if (!mounted) return null; | ||
| return ( | ||
| <ResponsiveDataTable | ||
| columns={columns} | ||
| data={data} | ||
| options={options} | ||
| tableCols={tableCols} | ||
| updateCols={updateCols} | ||
| columnVisibility={columnVisibility} | ||
| colViews={columnVisibility} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export const SortableTableDemo = () => { | ||
| const [mounted, setMounted] = useState(false); | ||
| useEffect(() => setMounted(true), []); | ||
| const columns = [ | ||
| { name: "name", label: "Name" }, | ||
| { name: "version", label: "Version" }, | ||
| ]; | ||
| const data = [ | ||
| ["meshery", "v0.7.1"], | ||
| ["kanvas", "v0.5.0"], | ||
| ["nighthawk", "v0.9.3"], | ||
| ]; | ||
| const [tableCols, updateCols] = useState(columns); | ||
| const [columnVisibility, setColumnVisibility] = useState({}); | ||
| const options = { | ||
| filter: false, download: false, print: false, viewColumns: false, | ||
| selectableRows: "none", responsive: "standard", pagination: false, | ||
| search: false, sort: true, elevation: 1, | ||
| }; | ||
| if (!mounted) return null; | ||
| return ( | ||
| <ResponsiveDataTable | ||
| columns={columns} | ||
| data={data} | ||
| options={options} | ||
| tableCols={tableCols} | ||
| updateCols={updateCols} | ||
| columnVisibility={columnVisibility} | ||
| colViews={columnVisibility} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
|
|
||
| export const SelectableTableDemo = () => { | ||
| const [mounted, setMounted] = useState(false); | ||
| useEffect(() => setMounted(true), []); | ||
| const columns = useMemo(() => [ | ||
| { name: "name", label: "Name" }, | ||
| { name: "env", label: "Environment" }, | ||
| ], []); | ||
| const data = useMemo(() => [ | ||
| ["Alice", "production"], | ||
| ["Bob", "staging"], | ||
| ["Charlie", "development"], | ||
| ], []); | ||
| const [tableCols, updateCols] = useState(columns); | ||
| const [columnVisibility, setColumnVisibility] = useState({}); | ||
| const options = { | ||
| filter: false, download: false, print: false, viewColumns: false, | ||
| selectableRows: "multiple", responsive: "standard", pagination: false, | ||
| search: false, elevation: 1, | ||
| }; | ||
| if (!mounted) return null; | ||
| return ( | ||
| <ResponsiveDataTable | ||
| columns={columns} | ||
| data={data} | ||
| options={options} | ||
| tableCols={tableCols} | ||
| updateCols={updateCols} | ||
| columnVisibility={columnVisibility} | ||
| colViews={columnVisibility} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export const PaginatedTableDemo = () => { | ||
| const [mounted, setMounted] = useState(false); | ||
| useEffect(() => setMounted(true), []); | ||
| const columns = [ | ||
| { name: "name", label: "Name" }, | ||
| { name: "owner", label: "Owner" }, | ||
| { name: "age", label: "Age" }, | ||
| { name: "status", label: "Status" }, | ||
| ]; | ||
| const data = Array.from({ length: 20 }, (_, i) => [ | ||
| "service-" + (i + 1), | ||
| i % 3 === 0 ? "Alice" : i % 3 === 1 ? "Bob" : "Charlie", | ||
| (i + 1) + " months ago", | ||
| i % 2 === 0 ? "Running" : "Stopped", | ||
| ]); | ||
| const [tableCols, updateCols] = useState(columns); | ||
| const [columnVisibility, setColumnVisibility] = useState({}); | ||
| const options = { | ||
| filter: false, download: false, print: false, viewColumns: false, | ||
| selectableRows: "none", responsive: "standard", pagination: true, | ||
| rowsPerPage: 5, rowsPerPageOptions: [5, 10, 20], elevation: 1, | ||
| }; | ||
| if (!mounted) return null; | ||
| return ( | ||
| <ResponsiveDataTable | ||
| columns={columns} | ||
| data={data} | ||
| options={options} | ||
| tableCols={tableCols} | ||
| updateCols={updateCols} | ||
| columnVisibility={columnVisibility} | ||
| colViews={columnVisibility} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| Tables communicate actions and data to users and can be placed at several places throughout the user interface. | ||
|
|
||
| <a id="Basic Table"> | ||
| <h2>Basic Table</h2> | ||
| </a> | ||
|
|
||
| A minimal read-only table with a header row and data rows. | ||
|
|
||
| <div className="showcase"> | ||
| <div className="items"> | ||
| <ThemeWrapper> | ||
| <BasicTableDemo /> | ||
| </ThemeWrapper> | ||
| </div> | ||
| <CodeBlock name="basic-table" collapsible code={`import { useState, useEffect, useMemo } from "react"; | ||
| import { ResponsiveDataTable } from "@sistent/sistent"; | ||
|
|
||
| const columns = [ | ||
| { name: "name", label: "Name" }, | ||
| { name: "env", label: "Environment" }, | ||
| { name: "status", label: "Status" }, | ||
| ]; | ||
|
|
||
| const data = [ | ||
| ["meshery", "production", "Running"], | ||
| ["nighthawk", "staging", "Stopped"], | ||
| ["kanvas", "development", "Running"], | ||
| ]; | ||
|
|
||
| export default function BasicTable() { | ||
| const [tableCols, updateCols] = useState(columns); | ||
| const [columnVisibility, setColumnVisibility] = useState({}); | ||
|
|
||
| const options = { | ||
| filter: false, | ||
| download: false, | ||
| print: false, | ||
| viewColumns: false, | ||
| selectableRows: "none", | ||
| responsive: "standard", | ||
| pagination: false, | ||
| search: false, | ||
| elevation: 1, | ||
| }; | ||
|
|
||
| if (!mounted) return null; | ||
| return ( | ||
| <ResponsiveDataTable | ||
| columns={columns} | ||
| data={data} | ||
| options={options} | ||
| tableCols={tableCols} | ||
| updateCols={updateCols} | ||
| columnVisibility={columnVisibility} | ||
| colViews={columnVisibility} | ||
| /> | ||
| ); | ||
| }`} /> | ||
| </div> | ||
|
|
||
| <a id="Sortable Table"> | ||
| <h2>Sortable Table</h2> | ||
| </a> | ||
|
|
||
| Clicking a column header sorts rows ascending or descending by that column. | ||
|
|
||
| <div className="showcase"> | ||
| <div className="items"> | ||
| <ThemeWrapper> | ||
| <SortableTableDemo /> | ||
| </ThemeWrapper> | ||
| </div> | ||
| <CodeBlock name="sortable-table" collapsible code={`import { useState, useEffect, useMemo } from "react"; | ||
| import { ResponsiveDataTable } from "@sistent/sistent"; | ||
|
|
||
| const columns = [ | ||
| { name: "name", label: "Name" }, | ||
| { name: "version", label: "Version" }, | ||
| ]; | ||
|
|
||
| const data = [ | ||
| ["meshery", "v0.7.1"], | ||
| ["kanvas", "v0.5.0"], | ||
| ["nighthawk", "v0.9.3"], | ||
| ]; | ||
|
|
||
| export default function SortableTable() { | ||
| const [tableCols, updateCols] = useState(columns); | ||
| const [columnVisibility, setColumnVisibility] = useState({}); | ||
|
|
||
| const options = { | ||
| filter: false, | ||
| download: false, | ||
| print: false, | ||
| viewColumns: false, | ||
| selectableRows: "none", | ||
| responsive: "standard", | ||
| pagination: false, | ||
| search: false, | ||
| sort: true, | ||
| elevation: 1, | ||
| }; | ||
|
|
||
| if (!mounted) return null; | ||
| return ( | ||
| <ResponsiveDataTable | ||
| columns={columns} | ||
| data={data} | ||
| options={options} | ||
| tableCols={tableCols} | ||
| updateCols={updateCols} | ||
| columnVisibility={columnVisibility} | ||
| colViews={columnVisibility} | ||
| /> | ||
| ); | ||
| }`} /> | ||
| </div> | ||
|
|
||
| <a id="Selectable Rows Table"> | ||
| <h2>Selectable Rows Table</h2> | ||
| </a> | ||
|
|
||
| Setting <code>selectableRows</code> to <code>"multiple"</code> enables checkbox selection on each row. | ||
|
|
||
| <div className="showcase"> | ||
| <div className="items"> | ||
| <ThemeWrapper> | ||
| <SelectableTableDemo /> | ||
| </ThemeWrapper> | ||
| </div> | ||
| <CodeBlock name="selectable-table" collapsible code={`import { useState, useEffect, useMemo } from "react"; | ||
| import { ResponsiveDataTable } from "@sistent/sistent"; | ||
|
|
||
| const columns = [ | ||
| { name: "name", label: "Name" }, | ||
| { name: "env", label: "Environment" }, | ||
| ]; | ||
|
|
||
| const data = [ | ||
| ["Alice", "production"], | ||
| ["Bob", "staging"], | ||
| ["Charlie", "development"], | ||
| ]; | ||
|
|
||
| export default function SelectableTable() { | ||
| const [tableCols, updateCols] = useState(columns); | ||
| const [columnVisibility, setColumnVisibility] = useState({}); | ||
| const options = { | ||
| filter: false, | ||
| download: false, | ||
| print: false, | ||
| viewColumns: false, | ||
| selectableRows: "multiple", | ||
| responsive: "standard", | ||
| pagination: false, | ||
| search: false, | ||
| elevation: 1, | ||
| }; | ||
|
|
||
| if (!mounted) return null; | ||
| return ( | ||
| <ResponsiveDataTable | ||
| columns={columns} | ||
| data={data} | ||
| options={options} | ||
| tableCols={tableCols} | ||
| updateCols={updateCols} | ||
| columnVisibility={columnVisibility} | ||
| colViews={columnVisibility} | ||
| /> | ||
| ); | ||
| }`} /> | ||
| </div> | ||
|
|
||
| <a id="Paginated Table"> | ||
| <h2>Paginated Table</h2> | ||
| </a> | ||
|
|
||
| <code>ResponsiveDataTable</code> from <code>@sistent/sistent</code> provides built-in pagination, column visibility, and responsive layout controls. | ||
|
|
||
| <div className="showcase"> | ||
| <div className="items"> | ||
| <ThemeWrapper> | ||
| <PaginatedTableDemo /> | ||
| </ThemeWrapper> | ||
| </div> | ||
| <CodeBlock name="paginated-table" collapsible code={`import { useState, useEffect, useMemo } from "react"; | ||
| import { ResponsiveDataTable } from "@sistent/sistent"; | ||
|
|
||
| const columns = [ | ||
| { name: "name", label: "Name" }, | ||
| { name: "owner", label: "Owner" }, | ||
| { name: "age", label: "Age" }, | ||
| { name: "status", label: "Status" }, | ||
| ]; | ||
|
|
||
| const data = Array.from({ length: 20 }, (_, i) => [ | ||
| "service-" + (i + 1), | ||
| i % 3 === 0 ? "Alice" : i % 3 === 1 ? "Bob" : "Charlie", | ||
| (i + 1) + " months ago", | ||
| i % 2 === 0 ? "Running" : "Stopped", | ||
| ]); | ||
|
|
||
| export default function PaginatedTable() { | ||
| const [tableCols, updateCols] = useState(columns); | ||
| const [columnVisibility, setColumnVisibility] = useState({}); | ||
|
|
||
| const options = { | ||
| filter: false, | ||
| download: false, | ||
| print: false, | ||
| viewColumns: false, | ||
| selectableRows: "none", | ||
| responsive: "standard", | ||
| pagination: true, | ||
| rowsPerPage: 5, | ||
| rowsPerPageOptions: [5, 10, 20], | ||
| elevation: 1, | ||
| }; | ||
|
|
||
| if (!mounted) return null; | ||
| return ( | ||
| <ResponsiveDataTable | ||
| columns={columns} | ||
| data={data} | ||
| options={options} | ||
| tableCols={tableCols} | ||
| updateCols={updateCols} | ||
| columnVisibility={columnVisibility} | ||
| colViews={columnVisibility} | ||
| /> | ||
| ); | ||
| }`} /> | ||
| </div> |
Oops, something went wrong.
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.
Where is the code part ?