bref-ui 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,3 +5,4 @@ export * from './button/index.ts';
5
5
  export * from './loading/index.ts';
6
6
  export * from './tree-view/index.ts';
7
7
  export * from './text-input/index.ts';
8
+ export * from './slider/index.ts';
@@ -5,3 +5,4 @@ export * from "./button/index.js";
5
5
  export * from "./loading/index.js";
6
6
  export * from "./tree-view/index.js";
7
7
  export * from "./text-input/index.js";
8
+ export * from "./slider/index.js";
@@ -0,0 +1 @@
1
+ export { default as Slider } from './slider.svelte';
@@ -0,0 +1 @@
1
+ export { default as Slider } from './slider.svelte';
@@ -0,0 +1,190 @@
1
+ <script lang="ts">
2
+ import type { SvelteHTMLElements } from 'svelte/elements';
3
+ import type { SliderProps } from './types.js';
4
+
5
+ const {
6
+ value,
7
+ min = 0,
8
+ max = 100,
9
+ step = 1,
10
+ disabled = false,
11
+ wide = false,
12
+ size = 'medium',
13
+ color = 'primary',
14
+ onChange,
15
+ ...rest
16
+ }: SliderProps &
17
+ Omit<
18
+ SvelteHTMLElements['input'],
19
+ 'value' | 'step' | 'min' | 'max' | 'disabled' | 'size'
20
+ > = $props();
21
+
22
+ const ratio = $derived((value - min) / (max - min));
23
+
24
+ const handleInput = (e: Event) => {
25
+ const newValue = Number((e.currentTarget as HTMLInputElement).value);
26
+ onChange(newValue);
27
+ };
28
+ </script>
29
+
30
+ <div class="track {size} {color}" class:wide class:disabled>
31
+ <div
32
+ class="fill"
33
+ style:width="calc({ratio} * (100% - var(--internal-track-height)) + var(--internal-track-height) /
34
+ 2)"
35
+ ></div>
36
+ <input {...rest} type="range" {min} {max} {step} {value} {disabled} oninput={handleInput} />
37
+ </div>
38
+
39
+ <style>
40
+ .track {
41
+ --internal-track-height: 0.5rem;
42
+ --internal-color: var(--color-primary);
43
+ --internal-color-soft: var(--color-primary-soft);
44
+ --internal-thumb-color: var(--color-primary-saturated);
45
+
46
+ position: relative;
47
+ min-width: 7.5rem;
48
+ height: var(--internal-track-height);
49
+ background: var(--internal-color-soft);
50
+ border-radius: calc(var(--internal-track-height) / 2);
51
+ }
52
+
53
+ .track.wide {
54
+ width: 100%;
55
+ }
56
+
57
+ /* Color variants */
58
+ .track.primary {
59
+ --internal-color: var(--color-primary);
60
+ --internal-color-soft: var(--color-primary-soft);
61
+ --internal-thumb-color: var(--color-primary-saturated);
62
+ }
63
+
64
+ .track.foreground {
65
+ --internal-color: var(--color-foreground);
66
+ --internal-color-soft: var(--color-foreground-soft);
67
+ --internal-thumb-color: var(--color-foreground-saturated);
68
+ }
69
+
70
+ /* Size variants */
71
+ .track.x-small {
72
+ --internal-track-height: 0.25rem;
73
+ }
74
+
75
+ .track.small {
76
+ --internal-track-height: 0.375rem;
77
+ }
78
+
79
+ .track.medium {
80
+ --internal-track-height: 0.5rem;
81
+ }
82
+
83
+ .track.large {
84
+ --internal-track-height: 0.625rem;
85
+ }
86
+
87
+ .track.x-large {
88
+ --internal-track-height: 0.75rem;
89
+ }
90
+
91
+ /* Fill bar */
92
+ .fill {
93
+ position: absolute;
94
+ top: 0;
95
+ left: 0;
96
+ height: 100%;
97
+ background: var(--internal-color);
98
+ border-radius: calc(var(--internal-track-height) / 2) 0 0 calc(var(--internal-track-height) / 2);
99
+ pointer-events: none;
100
+ }
101
+
102
+ /* Input */
103
+ input {
104
+ position: absolute;
105
+ top: 0;
106
+ left: 0;
107
+ width: 100%;
108
+ height: 100%;
109
+ -webkit-appearance: none;
110
+ appearance: none;
111
+ background: transparent;
112
+ outline: none;
113
+ cursor: pointer;
114
+ }
115
+
116
+ input:focus-visible {
117
+ outline: 0.1rem solid var(--internal-color);
118
+ outline-offset: 0.2rem;
119
+ }
120
+
121
+ /* Webkit thumb */
122
+ input::-webkit-slider-thumb {
123
+ -webkit-appearance: none;
124
+ appearance: none;
125
+ width: var(--internal-track-height);
126
+ height: var(--internal-track-height);
127
+ border-radius: 50%;
128
+ background: var(--internal-thumb-color);
129
+ cursor: pointer;
130
+ border: none;
131
+ box-shadow: 0 0.03rem 0.125rem rgba(0, 0, 0, 0.08);
132
+ transition:
133
+ transform 0.2s ease,
134
+ box-shadow 0.2s ease;
135
+ }
136
+
137
+ input::-webkit-slider-thumb:hover {
138
+ transform: scale(1.2);
139
+ box-shadow: 0 0.0625rem 0.25rem rgba(0, 0, 0, 0.1);
140
+ }
141
+
142
+ input::-webkit-slider-thumb:active {
143
+ transform: scale(1.1);
144
+ }
145
+
146
+ /* Firefox thumb */
147
+ input::-moz-range-thumb {
148
+ width: var(--internal-track-height);
149
+ height: var(--internal-track-height);
150
+ border-radius: 50%;
151
+ background: var(--internal-thumb-color);
152
+ cursor: pointer;
153
+ border: none;
154
+ box-shadow: 0 0.03rem 0.125rem rgba(0, 0, 0, 0.08);
155
+ transition:
156
+ transform 0.2s ease,
157
+ box-shadow 0.2s ease;
158
+ }
159
+
160
+ input::-moz-range-thumb:hover {
161
+ transform: scale(1.2);
162
+ box-shadow: 0 0.0625rem 0.25rem rgba(0, 0, 0, 0.1);
163
+ }
164
+
165
+ input::-moz-range-thumb:active {
166
+ transform: scale(1.1);
167
+ }
168
+
169
+ /* Firefox track */
170
+ input::-moz-range-track {
171
+ background: transparent;
172
+ }
173
+
174
+ /* Disabled state */
175
+ .track.disabled {
176
+ opacity: 0.4;
177
+ }
178
+
179
+ .track.disabled input {
180
+ cursor: not-allowed;
181
+ }
182
+
183
+ .track.disabled input::-webkit-slider-thumb {
184
+ cursor: not-allowed;
185
+ }
186
+
187
+ .track.disabled input::-moz-range-thumb {
188
+ cursor: not-allowed;
189
+ }
190
+ </style>
@@ -0,0 +1,6 @@
1
+ import type { SvelteHTMLElements } from 'svelte/elements';
2
+ import type { SliderProps } from './types.ts';
3
+ type $$ComponentProps = SliderProps & Omit<SvelteHTMLElements['input'], 'value' | 'step' | 'min' | 'max' | 'disabled' | 'size'>;
4
+ declare const Slider: import("svelte").Component<$$ComponentProps, {}, "">;
5
+ type Slider = ReturnType<typeof Slider>;
6
+ export default Slider;
@@ -0,0 +1,12 @@
1
+ import type { Size, Color } from '../types.ts';
2
+ export interface SliderProps {
3
+ value: number;
4
+ min?: number;
5
+ max?: number;
6
+ step?: number;
7
+ disabled?: boolean;
8
+ wide?: boolean;
9
+ size?: Size;
10
+ color?: Extract<Color, 'primary' | 'foreground'>;
11
+ onChange: (value: number) => void;
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -44,22 +44,28 @@ export const PAGES = [
44
44
  ]
45
45
  },
46
46
  {
47
- title: 'Text Inputs',
48
- description: 'Text input fields with customizable size, color, and validation states',
49
- href: '/text-inputs',
47
+ title: 'Inputs',
48
+ description: 'Input fields for text, numbers, and selections',
49
+ href: '/inputs',
50
50
  icon: 'input',
51
51
  children: [
52
52
  {
53
53
  title: 'Text Input',
54
54
  description: 'Single-line text input fields with labels, placeholders, and icons',
55
- href: '/text-inputs/text-input',
55
+ href: '/inputs/text-input',
56
56
  icon: 'short_text'
57
57
  },
58
58
  {
59
59
  title: 'Area Text Input',
60
60
  description: 'Multi-line text area input fields with labels and placeholders',
61
- href: '/text-inputs/area-text-input',
61
+ href: '/inputs/area-text-input',
62
62
  icon: 'notes'
63
+ },
64
+ {
65
+ title: 'Slider',
66
+ description: 'Range slider for selecting numeric values within a range',
67
+ href: '/inputs/slider',
68
+ icon: 'tune'
63
69
  }
64
70
  ]
65
71
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bref-ui",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "A Svelte UI component library using scoped CSS - minimal and flexible",
5
5
  "license": "MIT",
6
6
  "author": "feuerstein",