-
Notifications
You must be signed in to change notification settings - Fork 2
feat: reogrganization main #47
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -1,7 +1,18 @@ | ||
| import { FlagIcon } from 'lucide-react'; | ||
|
|
||
| import { columns } from '@/constants/featureFlagColumns'; | ||
| import { TanstackTable } from '@/components/TanstackTable'; | ||
| import { ExampleData } from '@/constants/tableMockDatat'; | ||
|
|
||
| export default function Home() { | ||
| return ( | ||
| <div> | ||
| <h1>Light Switch</h1> | ||
| <div className="flex size-full flex-col gap-5 p-3"> | ||
| <header className="flex items-center gap-3"> | ||
| <FlagIcon size={20} /> | ||
| <span className="text-xl font-semibold">Feature Flag Management</span> | ||
| </header> | ||
|
|
||
| <TanstackTable columns={columns} data={ExampleData} /> | ||
| </div> | ||
| ); | ||
| } |
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,130 @@ | ||
| 'use client'; | ||
| import { | ||
| ColumnDef, | ||
| flexRender, | ||
| getCoreRowModel, | ||
| getPaginationRowModel, | ||
| useReactTable, | ||
| getSortedRowModel, | ||
| PaginationState, | ||
| } from '@tanstack/react-table'; | ||
| import { useState } from 'react'; | ||
|
|
||
| import { | ||
| Table, | ||
| TableBody, | ||
| TableCell, | ||
| TableHead, | ||
| TableHeader, | ||
| TableRow, | ||
| } from '@/components/ui/table'; | ||
| import { Button } from '@/components/ui/button'; | ||
| import { FeatureFlagTableType } from '@/types/types'; | ||
|
|
||
| export interface DataTableProps<TData extends FeatureFlagTableType, TValue> { | ||
| columns: ColumnDef<TData, TValue>[]; | ||
| data: TData[]; | ||
| } | ||
|
|
||
| export function TanstackTable<TData extends FeatureFlagTableType, TValue>({ | ||
| columns, | ||
| data, | ||
| }: DataTableProps<TData, TValue>) { | ||
| const [pagination, setPagination] = useState<PaginationState>({ | ||
| pageIndex: 0, | ||
| pageSize: 9, | ||
| }); | ||
|
|
||
| const table = useReactTable({ | ||
| data, | ||
| columns, | ||
| getCoreRowModel: getCoreRowModel(), | ||
| getPaginationRowModel: getPaginationRowModel(), | ||
| getSortedRowModel: getSortedRowModel(), | ||
| state: { | ||
| pagination, | ||
| }, | ||
| onPaginationChange: setPagination, | ||
| }); | ||
|
|
||
| return ( | ||
| <div className="flex w-[95%] flex-col items-center"> | ||
| <div className="w-full rounded-md border"> | ||
| <Table> | ||
| <TableHeader> | ||
| {table.getHeaderGroups().map((headerGroup) => ( | ||
| <TableRow key={headerGroup.id}> | ||
| {headerGroup.headers.map((header) => { | ||
| return ( | ||
| <TableHead key={header.id}> | ||
| {header.isPlaceholder | ||
| ? null | ||
| : flexRender( | ||
| header.column.columnDef.header, | ||
| header.getContext(), | ||
| )} | ||
| </TableHead> | ||
| ); | ||
| })} | ||
| </TableRow> | ||
| ))} | ||
| </TableHeader> | ||
| <TableBody> | ||
| {table.getRowModel().rows?.length ? ( | ||
| table.getRowModel().rows.map((row) => ( | ||
| <TableRow | ||
| key={row.id} | ||
| data-state={row.getIsSelected() && 'selected'} | ||
| > | ||
| {row.getVisibleCells().map((cell) => ( | ||
| <TableCell key={cell.id}> | ||
| {flexRender( | ||
| cell.column.columnDef.cell, | ||
| cell.getContext(), | ||
| )} | ||
| </TableCell> | ||
| ))} | ||
| </TableRow> | ||
| )) | ||
| ) : ( | ||
| <TableRow> | ||
| <TableCell | ||
| colSpan={columns.length} | ||
| className="h-24 text-center" | ||
| > | ||
| No results. | ||
| </TableCell> | ||
| </TableRow> | ||
| )} | ||
| </TableBody> | ||
| </Table> | ||
| </div> | ||
| <div className="flex w-full items-center justify-between space-x-2 py-4"> | ||
| {`${table.getFilteredSelectedRowModel().rows.length} of ${table.getFilteredRowModel().rows.length} row(s) selected`} | ||
| <div className="flex items-center justify-between"> | ||
| <span className="text-sm"> | ||
| {`Page ${pagination.pageIndex + 1} of ${table.getPageCount()}`} | ||
| </span> | ||
| <div className="flex items-center justify-between"> | ||
| <Button | ||
| variant="outline" | ||
| size="sm" | ||
| onClick={table.previousPage} | ||
| disabled={pagination.pageIndex === 0} | ||
| > | ||
| Previous | ||
| </Button> | ||
| <Button | ||
| variant="outline" | ||
| size="sm" | ||
| onClick={table.nextPage} | ||
| disabled={pagination.pageIndex >= table.getPageCount() - 1} | ||
| > | ||
| Next | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
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,30 @@ | ||
| 'use client'; | ||
|
|
||
| import * as React from 'react'; | ||
| import * as CheckboxPrimitive from '@radix-ui/react-checkbox'; | ||
| import { Check } from 'lucide-react'; | ||
|
|
||
| import { cn } from '@/lib/utils'; | ||
|
|
||
| const Checkbox = React.forwardRef< | ||
| React.ElementRef<typeof CheckboxPrimitive.Root>, | ||
| React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> | ||
| >(({ className, ...props }, ref) => ( | ||
| <CheckboxPrimitive.Root | ||
| ref={ref} | ||
| className={cn( | ||
| 'peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground', | ||
| className, | ||
| )} | ||
| {...props} | ||
| > | ||
| <CheckboxPrimitive.Indicator | ||
| className={cn('flex items-center justify-center text-current')} | ||
| > | ||
| <Check className="size-4" /> | ||
| </CheckboxPrimitive.Indicator> | ||
| </CheckboxPrimitive.Root> | ||
| )); | ||
| Checkbox.displayName = CheckboxPrimitive.Root.displayName; | ||
|
|
||
| export { Checkbox }; |
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.
flex size-full bg-background text-foreground이면 충분할것 같네요