import { Show, splitProps, mergeProps, createMemo } from 'solid-js'; import { useLicense } from '@util/context'; export default function Slider(props) { const { shakePromo } = useLicense(); const merged = mergeProps( { value: 1, unit: 'px', min: 0, max: 100, step: 1, fill: true, locked: false, }, props ); const [local, others] = splitProps(merged, [ 'value', 'unit', 'min', 'max', 'step', 'fill', 'onInput', 'class', 'disabled', 'locked', ]); const filled = createMemo(() => { const percentage = ((local.value - local.min) / (local.max - local.min)) * 100; return `linear-gradient(90deg, rgba(99, 102, 241, 1) ${percentage}%, #e2e8f0 ${percentage}%)`; }); const isDisabled = () => local.disabled || local.locked; const select = (value) => { if (isDisabled()) { if (local.locked) shakePromo(); return; } const numValue = parseFloat(value); if (!isNaN(numValue)) { local.onInput?.(numValue); } }; const decrease = () => { if (isDisabled() || local.value <= local.min) return; select(Math.max(local.value - local.step, local.min)); }; const increase = () => { if (isDisabled() || local.value >= local.max) return; select(Math.min(local.value + local.step, local.max)); }; const handleLockedClick = () => { if (local.locked) shakePromo(); }; return (