-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ff9648
commit b298a96
Showing
9 changed files
with
872 additions
and
326 deletions.
There are no files selected for viewing
This file contains 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 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 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,61 @@ | ||
import React, { FC, useState } from 'react'; | ||
import { Listbox, ListboxItem } from '@nextui-org/react'; | ||
import { Chip } from '@nextui-org/react'; | ||
|
||
const InterfaceSelectContent: FC = () => { | ||
const [selectedKeys, setSelectedKeys] = useState<Set<string> | any>(new Set(['text'])); | ||
|
||
const backgroundColors: string[] = [ | ||
'bg-primary', | ||
'bg-secondary', | ||
'bg-warning', | ||
'bg-danger', | ||
'bg-default', | ||
]; | ||
const handleChipClose = (closedInterface: string): void => { | ||
if (selectedKeys.size === 1) return; | ||
const newSelectedKeys = new Set( | ||
Array.from(selectedKeys).filter(key => key !== closedInterface), | ||
); | ||
setSelectedKeys(newSelectedKeys); | ||
}; | ||
|
||
return ( | ||
<div className='flex flex-col gap-2'> | ||
<Listbox | ||
aria-label='Multiple selection example' | ||
variant='flat' | ||
disallowEmptySelection | ||
selectionMode='multiple' | ||
selectedKeys={selectedKeys} | ||
onSelectionChange={setSelectedKeys} | ||
> | ||
<ListboxItem key='text'>⚡ Text</ListboxItem> | ||
<ListboxItem key='number'>⚡ Number</ListboxItem> | ||
<ListboxItem key='date'>⚡ Date</ListboxItem> | ||
<ListboxItem key='single_date'>⚡ Single Date</ListboxItem> | ||
<ListboxItem key='iteration'>⚡ Iteration</ListboxItem> | ||
</Listbox> | ||
<div className='flex flex-wrap gap-2 items-center'> | ||
<p className='text-small text-default-500'>Selected interfaces: </p> | ||
{Array.from(selectedKeys).map((selectedInterface: any, index: number) => ( | ||
<Chip | ||
size='sm' | ||
radius='full' | ||
variant='flat' | ||
key={selectedInterface} | ||
onClose={(): void => handleChipClose(selectedInterface)} | ||
classNames={{ | ||
base: backgroundColors[index % backgroundColors.length], | ||
content: 'text-white', | ||
}} | ||
> | ||
{selectedInterface} | ||
</Chip> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default InterfaceSelectContent; |
This file contains 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,50 @@ | ||
import React, { FC } from 'react'; | ||
import { | ||
Modal, | ||
ModalContent, | ||
ModalHeader, | ||
ModalBody, | ||
ModalFooter, | ||
Button, | ||
} from '@nextui-org/react'; | ||
import InterfaceSelectContent from '@/components/interface-select-content'; | ||
|
||
interface Props { | ||
isOpen: boolean; | ||
selectedInterfaces: string[] | null; | ||
onOpenChange: () => void; | ||
} | ||
|
||
const InterfaceSelectModal: FC<Props> = ({ isOpen, onOpenChange, selectedInterfaces }) => { | ||
console.log('🚀 ~ file: index.tsx:18 ~ selectedInterfaces:', selectedInterfaces); | ||
|
||
return ( | ||
<> | ||
<Modal isOpen={isOpen} onOpenChange={onOpenChange}> | ||
<ModalContent> | ||
{(onClose): any => ( | ||
<> | ||
<ModalHeader className='flex flex-col gap-1'> | ||
Following 𝕀𝕟𝕥𝕖𝕣𝕗𝕒𝕔𝕖𝕤 Detected | ||
</ModalHeader> | ||
<ModalBody> | ||
<p>Please select the interfaces you want to generate mock data for.</p> | ||
<InterfaceSelectContent /> | ||
</ModalBody> | ||
<ModalFooter> | ||
<Button color='danger' variant='bordered' onPress={onClose}> | ||
Close | ||
</Button> | ||
<Button color='primary' onPress={onClose}> | ||
🪄 Generate | ||
</Button> | ||
</ModalFooter> | ||
</> | ||
)} | ||
</ModalContent> | ||
</Modal> | ||
</> | ||
); | ||
}; | ||
|
||
export default InterfaceSelectModal; |
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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,15 @@ | ||
import { mock } from 'intermock'; | ||
|
||
export const generateMocks = ( | ||
code: string, | ||
selectedInterfaces: string[], | ||
): string | Record<string | number, {}> => { | ||
const mockedData = mock({ | ||
language: 'typescript', | ||
files: [['docs', code]], | ||
output: 'string', | ||
interfaces: selectedInterfaces, | ||
}); | ||
|
||
return mockedData; | ||
}; |
This file contains 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,2 +1,2 @@ | ||
export * from './extract-interfaces'; | ||
export * from './extract-interface-names'; | ||
export * from './generate-mocks'; |
Oops, something went wrong.