Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactored row numbers #8

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ interface Person {

const Home: FC = () => {
const [code, setCode] = useState<string>(DEFAULT_INTERFACE);
const [selectedKeys, setSelectedKeys] = useState(new Set(['10']));
const [numberOfRows, setNumberOfRows] = useState(new Set(['10']));

const handleOnGenerate = (): void => {
console.log('*********', code);
};

const handleOnRowCountChange = (newRowCount: any): void => {
setSelectedKeys(newRowCount);
setNumberOfRows(newRowCount);
};
const handleOnCodeChange = (newCode: string): void => {
setCode(newCode);
Expand All @@ -34,7 +34,7 @@ const Home: FC = () => {
<section className='h-full'>
<Header
onGenerate={handleOnGenerate}
selectedKeys={selectedKeys}
numberOfRows={numberOfRows}
onRowCountChange={handleOnRowCountChange}
/>
<div className='flex justify-center gap-6 h-[calc(100vh-12rem)]'>
Expand Down
10 changes: 5 additions & 5 deletions components/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import {
type Props = {
onGenerate: () => void;
onRowCountChange: (rowCount: Selection) => void;
selectedKeys: any;
numberOfRows: any;
};

const Header: FC<Props> = ({ onGenerate, onRowCountChange, selectedKeys }) => {
const Header: FC<Props> = ({ onGenerate, onRowCountChange, numberOfRows }) => {
const selectedValue = React.useMemo(
() => Array.from(selectedKeys).join(', ').replaceAll('_', ' '),
[selectedKeys],
() => Array.from(numberOfRows).join(', ').replaceAll('_', ' '),
[numberOfRows],
);

return (
Expand All @@ -37,7 +37,7 @@ const Header: FC<Props> = ({ onGenerate, onRowCountChange, selectedKeys }) => {
variant='flat'
disallowEmptySelection
selectionMode='single'
selectedKeys={selectedKeys}
selectedKeys={numberOfRows}
onSelectionChange={onRowCountChange}
>
<DropdownItem key='10'>10</DropdownItem>
Expand Down