From 075d3831ffae63f128bcaabf9fc5e70ade41ad33 Mon Sep 17 00:00:00 2001
From: "Thomas F. K. Jorna" <thomas@thomass-air.kpn>
Date: Tue, 21 Sep 2021 21:00:21 +0200
Subject: chore: separated out all tweak panels

---
 components/SliderWithInfo.tsx | 48 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 components/SliderWithInfo.tsx

(limited to 'components/SliderWithInfo.tsx')

diff --git a/components/SliderWithInfo.tsx b/components/SliderWithInfo.tsx
new file mode 100644
index 0000000..d4f0372
--- /dev/null
+++ b/components/SliderWithInfo.tsx
@@ -0,0 +1,48 @@
+import {
+  Text,
+  Box,
+  Slider,
+  SliderFilledTrack,
+  SliderThumb,
+  SliderTrack,
+  Tooltip,
+} from '@chakra-ui/react'
+import React, { useContext } from 'react'
+import { ThemeContext } from '../util/themecontext'
+import { InfoTooltip } from './InfoTooltip'
+
+export interface SliderWithInfoProps {
+  min?: number
+  max?: number
+  step?: number
+  value: number
+  onChange: (arg0: number) => void
+  label: string
+  infoText?: string
+}
+export const SliderWithInfo = ({
+  min = 0,
+  max = 10,
+  step = 0.1,
+  value = 1,
+  ...rest
+}: SliderWithInfoProps) => {
+  const { onChange, label, infoText } = rest
+  const { highlightColor } = useContext(ThemeContext)
+  return (
+    <Box key={label}>
+      <Box display="flex" alignItems="flex-end">
+        <Text>{label}</Text>
+        {infoText && <InfoTooltip infoText={infoText} />}
+      </Box>
+      <Slider value={value} onChange={onChange} min={min} max={max} step={step}>
+        <SliderTrack>
+          <SliderFilledTrack />
+        </SliderTrack>
+        <Tooltip bg={highlightColor} label={value.toFixed(1)}>
+          <SliderThumb bg="white" />
+        </Tooltip>
+      </Slider>
+    </Box>
+  )
+}
-- 
cgit v1.2.3

