import { createMemo, Show } from 'solid-js'; import { Switch, Label, SegmentedControl, ColorPicker, ProBadge } from '@components'; import { useSettings, useLicense } from '@util/context'; export default function ProgressBar() { const { settings } = useSettings(); const { isLocked, shakePromo } = useLicense(); const progressbarPositionOptions = [ { value: 'top', label: 'Top' }, { value: 'bottom', label: 'Bottom' } ]; const animationSpeedOptions = [ { value: '2.5', label: 'Slow' }, { value: '1.5', label: 'Normal' }, { value: '0.8', label: 'Fast' } ]; const thicknessOptions = [ { value: 'thin', label: 'Thin' }, { value: 'normal', label: 'Normal' }, { value: 'large', label: 'Large' }, { value: 'custom', label: 'Custom' } ]; const isValidThickness = createMemo(() => { const value = settings.progressbar_weight_custom; if (!value) return true; const validPattern = /^-?\d+(\.\d+)?(px|rem|em|%|vh|vw|vmin|vmax|ch|ex)$/i; return validPattern.test(value.trim()); }); const handleThicknessKeydown = (event) => { if (event.key !== 'ArrowUp' && event.key !== 'ArrowDown') return; event.preventDefault(); const currentValue = settings.progressbar_weight_custom || '7px'; const match = currentValue.match(/^(-?\d+(?:\.\d+)?)(px|rem|em|%|vh|vw|vmin|vmax|ch|ex)?$/i); if (!match) return; let number = parseFloat(match[1]); const unit = match[2] || 'px'; number += event.key === 'ArrowUp' ? 1 : -1; if (number < 0) number = 0; const formattedNumber = number % 1 === 0 ? number.toString() : number.toFixed(1); settings.progressbar_weight_custom = formattedNumber + unit; }; const adjustThickness = (direction) => { const currentValue = settings.progressbar_weight_custom || '7px'; const match = currentValue.match(/^(-?\d+(?:\.\d+)?)(px|rem|em|%|vh|vw|vmin|vmax|ch|ex)?$/i); if (!match) return; let number = parseFloat(match[1]); const unit = match[2] || 'px'; number += direction === 'increase' ? 1 : -1; if (number < 0) number = 0; const formattedNumber = number % 1 === 0 ? number.toString() : number.toFixed(1); settings.progressbar_weight_custom = formattedNumber + unit; }; return (