summaryrefslogtreecommitdiff
path: root/components/Tweaks/EnableSection.tsx
diff options
context:
space:
mode:
authorThomas F. K. Jorna <[email protected]>2021-09-25 16:11:31 +0200
committerThomas F. K. Jorna <[email protected]>2021-09-25 16:11:31 +0200
commitee8539a9351374a719c9026f85d85e7b4ea6e8f5 (patch)
treef9220fd304bd3669523df39ddaa0992919ccc4a6 /components/Tweaks/EnableSection.tsx
parent075d3831ffae63f128bcaabf9fc5e70ade41ad33 (diff)
chore: move tweaks to separate subfolder
Diffstat (limited to 'components/Tweaks/EnableSection.tsx')
-rw-r--r--components/Tweaks/EnableSection.tsx31
1 files changed, 31 insertions, 0 deletions
diff --git a/components/Tweaks/EnableSection.tsx b/components/Tweaks/EnableSection.tsx
new file mode 100644
index 0000000..b7981b3
--- /dev/null
+++ b/components/Tweaks/EnableSection.tsx
@@ -0,0 +1,31 @@
+import { Text, Box, Collapse, Switch } from '@chakra-ui/react'
+import React from 'react'
+import { InfoTooltip } from './InfoTooltip'
+
+export interface EnableSectionProps {
+ label: string
+ value: boolean | number
+ onChange: () => void
+ infoText?: string
+ children: React.ReactNode
+}
+
+export const EnableSection = (props: EnableSectionProps) => {
+ const { value, onChange, label, infoText, children } = props
+ return (
+ <Box paddingTop={2} key={label}>
+ <Box display="flex" justifyContent="space-between" paddingBottom={2}>
+ <Box display="flex" alignItems="center">
+ <Text>{label}</Text>
+ {infoText && <InfoTooltip infoText={infoText} />}
+ </Box>
+ <Switch isChecked={!!value} onChange={onChange} />
+ </Box>
+ <Collapse in={!!value} animateOpacity>
+ <Box paddingLeft={4} paddingTop={2} paddingBottom={2}>
+ {children}
+ </Box>
+ </Collapse>
+ </Box>
+ )
+}