aboutsummaryrefslogtreecommitdiffstats
path: root/src/web
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-12-08 08:12:29 -0600
committerJP Dillingham <jpdillingham@gmail.com>2021-12-08 08:12:29 -0600
commitffc34a22cdb64665956f86aa44881b111128bc37 (patch)
treeaa3c26c22444980fc87b247a111f38d521342bfa /src/web
parentc36767953c623fb81eea0a0bd0796dd5093bd94b (diff)
downloadslskd-ffc34a22cdb64665956f86aa44881b111128bc37.tar.gz
add ShrinkableButton
Diffstat (limited to 'src/web')
-rw-r--r--src/web/src/components/Shared/ShrinkableButton.js30
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