-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from mikecao/dev
v0.48.0
- Loading branch information
Showing
64 changed files
with
861 additions
and
452 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |
---|---|---|
|
@@ -20,5 +20,5 @@ | |
} | ||
|
||
.icon { | ||
padding-left: 10px; | ||
padding-left: 20px; | ||
} |
This file was deleted.
Oops, something went wrong.
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
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,58 @@ | ||
import React, { useState, useRef } from 'react'; | ||
import classNames from 'classnames'; | ||
import Menu from 'components/common/Menu'; | ||
import Button from 'components/common/Button'; | ||
import useDocumentClick from 'hooks/useDocumentClick'; | ||
import styles from './MenuButton.module.css'; | ||
|
||
export default function MenuButton({ | ||
icon, | ||
value, | ||
options, | ||
menuPosition = 'bottom', | ||
menuAlign = 'right', | ||
onSelect, | ||
renderValue, | ||
}) { | ||
const [showMenu, setShowMenu] = useState(false); | ||
const ref = useRef(); | ||
const selectedOption = options.find(e => e.value === value); | ||
|
||
function handleSelect(value) { | ||
onSelect(value); | ||
setShowMenu(false); | ||
} | ||
|
||
function toggleMenu() { | ||
setShowMenu(state => !state); | ||
} | ||
|
||
useDocumentClick(e => { | ||
if (!ref.current.contains(e.target)) { | ||
setShowMenu(false); | ||
} | ||
}); | ||
|
||
return ( | ||
<div className={styles.container} ref={ref}> | ||
<Button | ||
icon={icon} | ||
className={classNames(styles.button, { [styles.open]: showMenu })} | ||
onClick={toggleMenu} | ||
variant="light" | ||
> | ||
<div className={styles.text}>{renderValue ? renderValue(selectedOption) : value}</div> | ||
</Button> | ||
{showMenu && ( | ||
<Menu | ||
className={styles.menu} | ||
options={options} | ||
selectedOption={selectedOption} | ||
onSelect={handleSelect} | ||
float={menuPosition} | ||
align={menuAlign} | ||
/> | ||
)} | ||
</div> | ||
); | ||
} |
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,24 @@ | ||
.container { | ||
display: flex; | ||
position: relative; | ||
cursor: pointer; | ||
} | ||
|
||
.button { | ||
border: 1px solid transparent; | ||
border-radius: 4px; | ||
} | ||
|
||
.menu { | ||
z-index: 100; | ||
} | ||
|
||
.text { | ||
font-size: var(--font-size-small); | ||
} | ||
|
||
.open, | ||
.open:hover { | ||
background: var(--gray50); | ||
border: 1px solid var(--gray500); | ||
} |
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
418a24d
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.
Successfully deployed to the following URLs: