-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create DropDownWithLabel component and revamped all pages with dropdo…
…wn component to avoid repetitive code. Fixed dropdown styling to better match figma
- Loading branch information
Showing
6 changed files
with
283 additions
and
253 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,60 @@ | ||
/** | ||
* A dropdown component with a label. | ||
* | ||
* @component | ||
* @example | ||
* // Usage: | ||
* const menuItems = [ | ||
* { item: 'Item 1', callback: () => console.log('Item 1 selected') }, | ||
* { item: 'Item 2', callback: () => console.log('Item 2 selected') }, | ||
* { item: 'Item 3', callback: () => console.log('Item 3 selected') }, | ||
* ]; | ||
* | ||
* <DropDownWithLabel label="Select an item" menuItems={menuItems} isMobile={true} /> | ||
*/ | ||
import React from 'react'; | ||
import { Typography, Grid } from '@material-ui/core'; | ||
import DropDown from './DropDown'; | ||
|
||
type MenuElement = { | ||
item: string; | ||
callback: () => void; | ||
}; | ||
|
||
interface DropDownWithLabelProps { | ||
label: string; | ||
menuItems: MenuElement[]; | ||
labelStyle?: React.CSSProperties; | ||
isMobile: boolean; | ||
} | ||
|
||
const DropDownWithLabel: React.FC<DropDownWithLabelProps> = ({ | ||
label, | ||
menuItems, | ||
labelStyle, | ||
isMobile, | ||
}) => { | ||
return ( | ||
<div> | ||
<Grid container spacing={0} direction="row" alignItems="center" justifyContent="flex-end"> | ||
<Grid item> | ||
<Typography | ||
variant="body1" | ||
style={{ | ||
fontSize: isMobile ? '15px' : '23.157px', | ||
paddingRight: isMobile ? '0px' : '11px', | ||
...labelStyle, | ||
}} | ||
> | ||
{label} | ||
</Typography> | ||
</Grid> | ||
<Grid item> | ||
<DropDown menuItems={menuItems} isMobile={isMobile} /> | ||
</Grid> | ||
</Grid> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DropDownWithLabel; |
Oops, something went wrong.