diff options
Diffstat (limited to 'src/web')
| -rw-r--r-- | src/web/src/components/Shared/ShrinkableButton.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/web/src/components/Shared/ShrinkableButton.js b/src/web/src/components/Shared/ShrinkableButton.js new file mode 100644 index 00000000..c5a96849 --- /dev/null +++ b/src/web/src/components/Shared/ShrinkableButton.js @@ -0,0 +1,30 @@ +import React from 'react'; + +import { useMediaQuery } from 'react-responsive'; +import { Button, Icon, Popup } from 'semantic-ui-react'; + +const ShrinkableButton = ({ iconName, mediaQuery, children, ...rest }) => { + const shouldShrink = useMediaQuery({ query: mediaQuery }) + + if (!shouldShrink) { + return ( + <Button {...rest}> + <Icon name={iconName}/> + {children} + </Button> + ) + } + + return ( + <Popup + content={children} + trigger={ + <Button icon {...rest}> + <Icon name={iconName}/> + </Button> + } + /> + ) +} + +export default ShrinkableButton;
\ No newline at end of file |
