-
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
Showing
8 changed files
with
711 additions
and
1,009 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
Large diffs are not rendered by default.
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
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,62 @@ | ||
import { FC, useState, ReactNode } from 'react'; | ||
import { useCollapse } from 'react-collapsed'; | ||
import { FaChevronRight, FaChevronDown } from 'react-icons/fa'; | ||
import './MeshSelector.css'; | ||
|
||
interface MeshSelectorProps { | ||
typeList: string[]; | ||
} | ||
|
||
type SectionProps = { | ||
title: string; | ||
children: ReactNode; | ||
}; | ||
|
||
function Section(props: SectionProps) { | ||
const { getCollapseProps, getToggleProps, isExpanded } = useCollapse(); | ||
return ( | ||
<div className='collapsible'> | ||
<div className='header' {...getToggleProps()}> | ||
<span className='icon'> | ||
{isExpanded ? ( | ||
<FaChevronDown size={10} /> | ||
) : ( | ||
<FaChevronRight size={10} /> | ||
)} | ||
<span className='title'>{props.title}</span> | ||
</span> | ||
</div> | ||
<div {...getCollapseProps()}> | ||
<div className='content'>{props.children}</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
const LocationSelector: FC<MeshSelectorProps> = ({ typeList }) => { | ||
const [selected, setSelected] = useState([] as string[]); | ||
|
||
function handleChange(e: React.ChangeEvent<HTMLInputElement>) { | ||
if (!e.target.checked) { | ||
setSelected(selected.filter((number) => number !== e.target.value)); | ||
} else { | ||
setSelected(selected.concat(e.target.value)); | ||
} | ||
} | ||
|
||
return ( | ||
<div className='preferences'> | ||
<Section title='Location'> | ||
<div onChange={handleChange}> | ||
{typeList.map((type, i) => ( | ||
<label key={i}> | ||
<input type='checkbox' key={i} value={type} /> {type} | ||
</label> | ||
))} | ||
</div> | ||
</Section> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LocationSelector; |
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
Oops, something went wrong.