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 (
{/* Settings Card */}

Progress Bar

{/* Position */}
settings.progressbar_position = v} options={progressbarPositionOptions} />

{/* Bar Thickness, Color, Transparency - Inline */}
{/* Bar Thickness */}
isLocked() ? shakePromo() : settings.progressbar_weight = v} options={thicknessOptions} classList={{ 'ap-opacity-60': isLocked() }} />
{/* Bar Color */}
isLocked() ? shakePromo() : settings.progressbar_color = v} colors={['#0ea5e9', '#a855f7', '#6366f1', '#0077b6', '#808000', '#cd5c5c', '#1f2937']} classList={{ 'ap-opacity-60': isLocked() }} />
{/* Bar Transparency */}
isLocked() && shakePromo()}> isLocked() ? shakePromo() : settings.progressbar_opacity = e.target.value} type="range" class="ajaxpress-slider ajaxpress-opacity ap-w-full !ap-h-[34px]" classList={{ 'ap-opacity-60 ap-pointer-events-none': isLocked() }} style={{ color: settings.progressbar_color }} />
{settings.progressbar_opacity || 100}%
{/* Custom Thickness */}
isLocked() ? shakePromo() : settings.progressbar_weight_custom = e.target.value} readonly={isLocked()} onClick={() => isLocked() && shakePromo()} placeholder="7px" style={{ 'max-width': '70px' }} class="ajaxpress-input-text ap-transition-all ap-duration-150 ap-border-none ap-bg-white ap-text-slate-900 ap-placeholder-slate-400 focus:ap-outline-none focus:ap-ring-0 focus:ap-bg-indigo-50 ap-px-3 ap-py-1.5 ap-text-sm ap-text-center" onKeyDown={handleThicknessKeydown} />
Invalid CSS value

{/* Wave Animation */} isLocked() ? shakePromo() : settings.progressbar_animate = v} plain={true} size="sm" locked={isLocked()} tooltip={ <> Add a wave/shimmer effect to the progress bar.

Creates a moving gradient animation that makes the progress bar more visually dynamic. } > Animate Bar Background
{/* Animation Speed */}
isLocked() ? shakePromo() : settings.progressbar_animation_speed = v} options={animationSpeedOptions} classList={{ 'ap-opacity-60': isLocked() }} />
); }