bref-ui 0.2.3 → 0.2.4

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.
package/README.md CHANGED
@@ -55,7 +55,8 @@ Bref handles:
55
55
  - [x] Icon
56
56
  - [x] Button
57
57
  - [x] Icon Button
58
- - [x] Loading
58
+ - [x] Progress / Loading
59
+ - [x] Progress Bar
59
60
  - [x] Circular
60
61
  - [x] Pulsing Dots
61
62
  - [x] Morphing Shapes
@@ -64,12 +65,11 @@ Bref handles:
64
65
  - [-] Inputs
65
66
  - [x] Text Input (single line)
66
67
  - [x] Area Text Input
68
+ - [x] Slider (range)
67
69
  - [ ] File Input
68
70
  - [ ] Image Input
69
71
  - [ ] Avatar
70
- - [ ] Progress
71
72
  - [ ] Select
72
- - [ ] Slider
73
73
  - [ ] Skeleton
74
74
  - [ ] Checkbox
75
75
  - [ ] Badge
@@ -6,3 +6,4 @@ export * from './loading/index.ts';
6
6
  export * from './tree-view/index.ts';
7
7
  export * from './text-input/index.ts';
8
8
  export * from './slider/index.ts';
9
+ export * from './progress-bar/index.ts';
@@ -6,3 +6,4 @@ export * from "./loading/index.js";
6
6
  export * from "./tree-view/index.js";
7
7
  export * from "./text-input/index.js";
8
8
  export * from "./slider/index.js";
9
+ export * from "./progress-bar/index.js";
@@ -0,0 +1 @@
1
+ export { default as ProgressBar } from './progress-bar.svelte';
@@ -0,0 +1 @@
1
+ export { default as ProgressBar } from './progress-bar.svelte';
@@ -0,0 +1,172 @@
1
+ <script lang="ts">
2
+ import type { ProgressBarProps } from './types.js';
3
+
4
+ const {
5
+ value,
6
+ size = 'medium',
7
+ color = 'primary',
8
+ wide = false,
9
+ animateValue = false,
10
+ onValueClick
11
+ }: ProgressBarProps = $props();
12
+
13
+ const isIndeterminate = $derived(value === undefined);
14
+ const progressWidth = $derived(
15
+ value === undefined ? undefined : `${Math.min(100, Math.max(0, value))}%`
16
+ );
17
+ const isClickable = $derived(onValueClick !== undefined);
18
+
19
+ const handleClick = (e: MouseEvent) => {
20
+ if (!onValueClick) return;
21
+ const element = e.currentTarget as HTMLElement;
22
+ const rect = element.getBoundingClientRect();
23
+ const clickX = e.clientX - rect.left;
24
+ const percentage = Math.round((clickX / rect.width) * 100);
25
+ onValueClick(Math.min(100, Math.max(0, percentage)));
26
+ };
27
+ </script>
28
+
29
+ <!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
30
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
31
+ <!-- aria-valuenow={isIndeterminate ? undefined : clampedValue} -->
32
+ <div
33
+ class={`${size} ${color}`}
34
+ class:wide
35
+ class:clickable={isClickable}
36
+ class:indeterminate={isIndeterminate}
37
+ class:animate={animateValue}
38
+ role="progressbar"
39
+ aria-valuemin={0}
40
+ aria-valuemax={100}
41
+ onclick={isClickable ? handleClick : undefined}
42
+ >
43
+ <span class:indeterminate={isIndeterminate} style:width={progressWidth}></span>
44
+ </div>
45
+
46
+ <style>
47
+ div {
48
+ --internal-progress-height: 0.5rem;
49
+ --internal-progress-radius: calc(var(--internal-progress-height) * 0.5);
50
+
51
+ position: relative;
52
+ display: flex;
53
+ width: 12rem;
54
+ height: var(--internal-progress-height);
55
+ background-color: var(--internal-current-color-soft);
56
+ border-radius: var(--internal-progress-radius);
57
+ overflow: hidden;
58
+ }
59
+
60
+ .wide {
61
+ width: 100%;
62
+ }
63
+
64
+ .clickable {
65
+ cursor: pointer;
66
+ }
67
+
68
+ span {
69
+ height: 100%;
70
+ display: flex;
71
+ background-color: var(--internal-current-color);
72
+ border-radius: var(--internal-progress-radius);
73
+ }
74
+
75
+ .animate span:not(.indeterminate) {
76
+ transition: width 0.3s ease-out;
77
+ }
78
+
79
+ span.indeterminate {
80
+ animation: indeterminate-fill 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
81
+ }
82
+
83
+ div.indeterminate {
84
+ justify-content: flex-start;
85
+ animation: indeterminate-container 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
86
+ }
87
+
88
+ @keyframes indeterminate-fill {
89
+ 0%,
90
+ 100% {
91
+ width: 25%;
92
+ opacity: 0.5;
93
+ }
94
+
95
+ 50% {
96
+ width: 100%;
97
+ opacity: 0.25;
98
+ }
99
+ }
100
+
101
+ @keyframes indeterminate-container {
102
+ 0%,
103
+ 100% {
104
+ padding-left: 0;
105
+ }
106
+ 50% {
107
+ padding-left: 75%;
108
+ }
109
+ }
110
+
111
+ /* Sizes */
112
+ .x-small {
113
+ --internal-progress-height: 0.25rem;
114
+ }
115
+
116
+ .small {
117
+ --internal-progress-height: 0.375rem;
118
+ }
119
+
120
+ .medium {
121
+ --internal-progress-height: 0.5rem;
122
+ }
123
+
124
+ .large {
125
+ --internal-progress-height: 0.625rem;
126
+ }
127
+
128
+ .x-large {
129
+ --internal-progress-height: 0.75rem;
130
+ }
131
+
132
+ /* Color mappings */
133
+ .primary {
134
+ --internal-current-color: var(--color-primary);
135
+ --internal-current-color-soft: var(--color-primary-soft);
136
+ }
137
+
138
+ .secondary {
139
+ --internal-current-color: var(--color-secondary);
140
+ --internal-current-color-soft: var(--color-secondary-soft);
141
+ }
142
+
143
+ .success {
144
+ --internal-current-color: var(--color-success);
145
+ --internal-current-color-soft: var(--color-success-soft);
146
+ }
147
+
148
+ .warning {
149
+ --internal-current-color: var(--color-warning);
150
+ --internal-current-color-soft: var(--color-warning-soft);
151
+ }
152
+
153
+ .danger {
154
+ --internal-current-color: var(--color-danger);
155
+ --internal-current-color-soft: var(--color-danger-soft);
156
+ }
157
+
158
+ .info {
159
+ --internal-current-color: var(--color-info);
160
+ --internal-current-color-soft: var(--color-info-soft);
161
+ }
162
+
163
+ .foreground {
164
+ --internal-current-color: var(--color-foreground);
165
+ --internal-current-color-soft: var(--color-background-saturated);
166
+ }
167
+
168
+ .background {
169
+ --internal-current-color: var(--color-background);
170
+ --internal-current-color-soft: var(--color-foreground-saturated);
171
+ }
172
+ </style>
@@ -0,0 +1,4 @@
1
+ import type { ProgressBarProps } from './types.ts';
2
+ declare const ProgressBar: import("svelte").Component<ProgressBarProps, {}, "">;
3
+ type ProgressBar = ReturnType<typeof ProgressBar>;
4
+ export default ProgressBar;
@@ -0,0 +1,9 @@
1
+ import type { Size, Color } from '../types.ts';
2
+ export interface ProgressBarProps {
3
+ value?: number;
4
+ size?: Size;
5
+ color?: Color;
6
+ wide?: boolean;
7
+ animateValue?: boolean;
8
+ onValueClick?: (clickedValue: number) => void;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -70,33 +70,39 @@ export const PAGES = [
70
70
  ]
71
71
  },
72
72
  {
73
- title: 'Loading',
74
- description: 'Multiple loading indicator styles for different visual contexts',
75
- href: '/loadings',
73
+ title: 'Progress / Loading',
74
+ description: 'Progress indicators and loading animations',
75
+ href: '/progress',
76
76
  icon: 'hourglass_empty',
77
77
  children: [
78
+ {
79
+ title: 'Progress Bar',
80
+ description: 'A progress bar with determinate and indeterminate states',
81
+ href: '/progress/progress-bar',
82
+ icon: 'linear_scale'
83
+ },
78
84
  {
79
85
  title: 'Circular',
80
86
  description: 'A classic spinning circle indicator for loading states',
81
- href: '/loadings/circular',
87
+ href: '/progress/circular',
82
88
  icon: 'autorenew'
83
89
  },
84
90
  {
85
91
  title: 'Pulsing Dots',
86
92
  description: 'Three dots that pulse in sequence to indicate loading',
87
- href: '/loadings/pulsing-dots',
93
+ href: '/progress/pulsing-dots',
88
94
  icon: 'more_horiz'
89
95
  },
90
96
  {
91
97
  title: 'Morphing Shapes',
92
98
  description: 'A shape that transforms through organic forms while rotating',
93
- href: '/loadings/morphing-shapes',
99
+ href: '/progress/morphing-shapes',
94
100
  icon: 'animation'
95
101
  },
96
102
  {
97
103
  title: 'Textual',
98
104
  description: 'Animated text with a typewriter effect that cycles through words',
99
- href: '/loadings/textual',
105
+ href: '/progress/textual',
100
106
  icon: 'text_fields'
101
107
  }
102
108
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bref-ui",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "A Svelte UI component library using scoped CSS - minimal and flexible",
5
5
  "license": "MIT",
6
6
  "author": "feuerstein",