diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-12-08 08:12:29 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-12-08 08:12:29 -0600 |
| commit | ffc34a22cdb64665956f86aa44881b111128bc37 (patch) | |
| tree | aa3c26c22444980fc87b247a111f38d521342bfa /src/web | |
| parent | c36767953c623fb81eea0a0bd0796dd5093bd94b (diff) | |
| download | slskd-ffc34a22cdb64665956f86aa44881b111128bc37.tar.gz | |
add ShrinkableButton
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 |
