noph-ui 0.20.1 → 0.21.1

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.
@@ -97,7 +97,15 @@
97
97
  aria-describedby={title ? uid : attributes['aria-describedby']}
98
98
  aria-label={title || attributes['aria-label']}
99
99
  bind:this={element}
100
- class={['np-button', size, selected ? 'square' : 'round', 'enabled', variant, attributes.class]}
100
+ class={[
101
+ 'np-button',
102
+ size,
103
+ selected ? 'square' : 'round',
104
+ toggle ? 'toggle' : '',
105
+ 'enabled',
106
+ variant,
107
+ attributes.class,
108
+ ]}
101
109
  >
102
110
  {@render content()}
103
111
  </a>
@@ -140,6 +148,7 @@
140
148
  overflow: hidden;
141
149
  font-weight: 500;
142
150
  text-decoration: none;
151
+ --np-icon-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
143
152
  transition:
144
153
  background-color 150ms linear,
145
154
  border-radius 150ms ease-in-out,
@@ -230,6 +239,12 @@
230
239
  .xl:active {
231
240
  border-radius: 1rem;
232
241
  }
242
+ .toggle {
243
+ --np-icon-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
244
+ }
245
+ .selected {
246
+ --np-icon-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
247
+ }
233
248
  .disabled {
234
249
  pointer-events: none;
235
250
  color: color-mix(in srgb, var(--np-color-on-surface) 38%, transparent);
@@ -346,7 +361,7 @@
346
361
  .outlined {
347
362
  background-color: var(--np-outlined-button-container-color, transparent);
348
363
  outline-style: solid;
349
- outline-color: var(--np-outlined-button-outline-color, var(--np-color-outline));
364
+ outline-color: var(--np-outlined-button-outline-color, var(--np-color-outline-variant));
350
365
  outline-width: 1px;
351
366
  outline-offset: -1px;
352
367
  --np-ripple-hover-color: var(--np-outlined-button-label-text-color, var(--np-color-primary));
@@ -21,6 +21,9 @@
21
21
  selected = $bindable(false),
22
22
  selectedIcon,
23
23
  keepTooltipOnClick,
24
+ width = 'default',
25
+ size = 's',
26
+ shape = 'round',
24
27
  onclick,
25
28
  ...attributes
26
29
  }: IconButtonProps = $props()
@@ -69,9 +72,12 @@
69
72
  }}
70
73
  class={[
71
74
  'np-icon-button',
75
+ size,
76
+ width,
77
+ selected || loading ? 'square' : shape,
72
78
  disabled || loading ? `${variant}-disabled disabled` : `${variant} enabled`,
73
79
  toggle && 'toggle',
74
- (selected || (variant !== 'outlined' && variant !== 'text' && !toggle)) && 'selected',
80
+ selected ? 'selected' : '',
75
81
  attributes.class,
76
82
  ]}
77
83
  >
@@ -85,9 +91,13 @@
85
91
  bind:this={element}
86
92
  class={[
87
93
  'np-icon-button',
94
+ size,
95
+ width,
88
96
  variant,
97
+ selected || loading ? 'square' : shape,
89
98
  'enabled',
90
- (selected || (variant !== 'outlined' && variant !== 'text' && !toggle)) && 'selected',
99
+ toggle && 'toggle',
100
+ selected ? 'selected' : '',
91
101
  attributes.class,
92
102
  ]}
93
103
  >
@@ -114,14 +124,129 @@
114
124
  text-decoration: none;
115
125
  align-items: center;
116
126
  justify-content: center;
127
+ --np-icon-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
128
+ transition:
129
+ background-color 150ms linear,
130
+ border-radius 150ms ease-in-out;
117
131
  }
118
132
 
119
133
  :global(.np-icon-button svg) {
120
- width: var(--_icon-size, 1.5rem);
121
- height: var(--_icon-size, 1.5rem);
122
134
  fill: currentColor;
123
- display: block;
124
135
  }
136
+
137
+ .xs {
138
+ --_icon-size: var(--np-icon-button-icon-size, 1.25rem);
139
+ height: 2rem;
140
+ width: 2rem;
141
+ --np-circular-progress-size: 1.75rem;
142
+ }
143
+ .xs.round {
144
+ border-radius: 1rem;
145
+ }
146
+ .xs.square {
147
+ border-radius: var(--np-icon-button-shape, 0.75rem);
148
+ }
149
+ .xs:active {
150
+ border-radius: 0.5rem;
151
+ }
152
+ .xs.narrow {
153
+ width: 1.75rem;
154
+ }
155
+ .xs.wide {
156
+ width: 2.5rem;
157
+ }
158
+ .s {
159
+ --_icon-size: var(--np-icon-button-icon-size, 1.5rem);
160
+ height: 2.5rem;
161
+ width: 2.5rem;
162
+ --np-circular-progress-size: 2rem;
163
+ }
164
+ .s.round {
165
+ border-radius: 1.25rem;
166
+ }
167
+ .s.square {
168
+ border-radius: var(--np-button-shape, 0.75rem);
169
+ }
170
+ .s.narrow {
171
+ width: 2rem;
172
+ }
173
+ .s.wide {
174
+ width: 3.25rem;
175
+ }
176
+ .s:active {
177
+ border-radius: 0.5rem;
178
+ }
179
+ .m {
180
+ --_icon-size: var(--np-icon-button-icon-size, 1.5rem);
181
+ height: 3.5rem;
182
+ width: 3.5rem;
183
+ --np-circular-progress-size: 3rem;
184
+ }
185
+ .m.round {
186
+ border-radius: 1.75rem;
187
+ }
188
+ .m.square {
189
+ border-radius: var(--np-button-shape, 1rem);
190
+ }
191
+ .m.narrow {
192
+ width: 3rem;
193
+ }
194
+ .m.wide {
195
+ width: 4.5rem;
196
+ }
197
+ .m:active {
198
+ border-radius: 0.75rem;
199
+ }
200
+ .l {
201
+ --_icon-size: var(--np-icon-button-icon-size, 2rem);
202
+ height: 6rem;
203
+ width: 6rem;
204
+ --np-circular-progress-size: 5rem;
205
+ }
206
+ .l.round {
207
+ border-radius: 3rem;
208
+ }
209
+ .l.square {
210
+ border-radius: var(--np-button-shape, 1.75rem);
211
+ }
212
+ .l.narrow {
213
+ width: 4rem;
214
+ }
215
+ .l.wide {
216
+ width: 8rem;
217
+ }
218
+ .l:active {
219
+ border-radius: 1rem;
220
+ }
221
+ .xl {
222
+ --_icon-size: var(--np-icon-button-icon-size, 2.5rem);
223
+ height: 8.5rem;
224
+ width: 8.5rem;
225
+ --np-circular-progress-size: 7rem;
226
+ }
227
+ .xl.round {
228
+ border-radius: 4.25rem;
229
+ }
230
+ .xl.square {
231
+ border-radius: var(--np-button-shape, 1.75rem);
232
+ }
233
+ .xl.narrow {
234
+ width: 6.5rem;
235
+ }
236
+ .xl.wide {
237
+ width: 11.5rem;
238
+ }
239
+ .xl:active {
240
+ border-radius: 1rem;
241
+ }
242
+
243
+ .toggle {
244
+ --np-icon-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
245
+ }
246
+ .selected {
247
+ --np-icon-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
248
+ }
249
+
125
250
  .disabled {
126
251
  pointer-events: none;
127
252
  color: color-mix(in srgb, var(--np-color-on-surface) 38%, transparent);
@@ -130,37 +255,12 @@
130
255
  .tonal-disabled {
131
256
  background-color: color-mix(in srgb, var(--np-color-on-surface) 12%, transparent);
132
257
  }
133
- .text-disabled {
134
- border-radius: var(--np-icon-button-container-shape, var(--np-shape-corner-full));
135
- --_button-height: var(--np-icon-button-container-height, 2.5rem);
136
- --_button-width: var(--np-icon-button-container-width, 2.5rem);
137
- height: var(--_button-height);
138
- width: var(--_button-width);
139
- --_icon-size: var(--np-icon-button-icon-size);
140
- }
141
- .filled-disabled {
142
- border-radius: var(--np-filled-icon-button-container-shape, var(--np-shape-corner-full));
143
- height: var(--np-filled-icon-button-container-height, 2.5rem);
144
- width: var(--np-filled-icon-button-container-width, 2.5rem);
145
- --_icon-size: var(--np-filled-icon-button-icon-size);
146
- }
147
- .tonal-disabled {
148
- border-radius: var(--np-tonal-icon-button-container-shape, var(--np-shape-corner-full));
149
- height: var(--np-tonal-icon-button-container-height, 2.5rem);
150
- width: var(--np-tonal-icon-button-container-width, 2.5rem);
151
- --_icon-size: var(--np-tonal-icon-button-icon-size);
152
- }
153
258
 
154
259
  .outlined-disabled {
155
- border: 1px solid;
156
- border-color: color-mix(in srgb, var(--np-color-on-surface) 12%, transparent);
157
- border-radius: var(--np-outlined-icon-button-container-shape, var(--np-shape-corner-full));
158
- height: var(--np-outlined-icon-button-container-height, 2.5rem);
159
- width: var(--np-outlined-icon-button-container-width, 2.5rem);
160
- --_icon-size: var(--np-outlined-icon-button-icon-size);
161
- }
162
- .enabled {
163
- transition: background-color 0.3s ease;
260
+ outline-style: solid;
261
+ outline-color: color-mix(in srgb, var(--np-color-on-surface) 12%, transparent);
262
+ outline-width: 1px;
263
+ outline-offset: -1px;
164
264
  }
165
265
  .enabled:focus-visible {
166
266
  outline-style: solid;
@@ -184,81 +284,70 @@
184
284
  --np-ripple-hover-color: var(--np-icon-button-icon-color, var(--np-color-on-surface-variant));
185
285
  --np-ripple-pressed-color: var(--np-icon-button-icon-color, var(--np-color-on-surface-variant));
186
286
  color: var(--np-icon-button-icon-color, var(--np-color-on-surface-variant));
187
- border-radius: var(--np-icon-button-container-shape, var(--np-shape-corner-full));
188
- --_button-height: var(--np-icon-button-container-height, 2.5rem);
189
- --_button-width: var(--np-icon-button-container-width, 2.5rem);
190
- height: var(--_button-height);
191
- width: var(--_button-width);
192
- --_icon-size: var(--np-icon-button-icon-size);
193
- }
194
- .text.toggle {
195
- --np-ripple-hover-color: var(--np-color-on-surface-variant);
196
- --np-ripple-pressed-color: var(--np-color-on-surface-variant);
197
- color: var(--np-color-on-surface-variant);
198
287
  }
199
288
  .text.selected {
200
- --np-ripple-hover-color: var(--np-icon-button-icon-color, var(--np-color-primary));
201
- --np-ripple-pressed-color: var(--np-icon-button-icon-color, var(--np-color-primary));
202
- color: var(--np-icon-button-icon-color, var(--np-color-primary));
289
+ --np-ripple-hover-color: var(--np-color-primary);
290
+ --np-ripple-pressed-color: var(--np-color-primary);
291
+ color: var(--np-color-primary);
203
292
  }
204
293
  .filled {
205
- transition: background-color 150ms linear;
206
- --np-ripple-hover-color: var(--np-filled-icon-button-container-color, var(--np-color-primary));
207
- --np-ripple-pressed-color: var(
208
- --np-filled-icon-button-container-color,
209
- var(--np-color-primary)
210
- );
211
- color: var(--np-filled-icon-button-container-color, var(--np-color-primary));
212
- background-color: var(--np-color-surface-container-highest);
213
- border-radius: var(--np-filled-icon-button-container-shape, var(--np-shape-corner-full));
214
- height: var(--np-filled-icon-button-container-height, 2.5rem);
215
- width: var(--np-filled-icon-button-container-width, 2.5rem);
216
- --_icon-size: var(--np-filled-icon-button-icon-size);
217
- }
218
- .filled.selected {
219
- --np-ripple-hover-opacity: 0.12;
220
- --np-ripple-hover-color: var(--np-color-surface);
221
- --np-ripple-pressed-color: var(--np-color-surface);
294
+ --np-ripple-hover-color: var(--np-filled-icon-button-icon-color, var(--np-color-on-primary));
295
+ --np-ripple-pressed-color: var(--np-filled-icon-button-icon-color, var(--np-color-on-primary));
222
296
  color: var(--np-filled-icon-button-icon-color, var(--np-color-on-primary));
223
297
  background-color: var(--np-filled-icon-button-container-color, var(--np-color-primary));
224
298
  }
225
-
226
- .tonal {
227
- transition: background-color 150ms linear;
228
- border-radius: var(--np-tonal-icon-button-container-shape, var(--np-shape-corner-full));
299
+ .filled.toggle {
229
300
  --np-ripple-hover-color: var(--np-color-on-surface-variant);
230
301
  --np-ripple-pressed-color: var(--np-color-on-surface-variant);
231
302
  color: var(--np-color-on-surface-variant);
232
- background-color: var(--np-color-surface-container-highest);
233
- height: var(--np-tonal-icon-button-container-height, 2.5rem);
234
- width: var(--np-tonal-icon-button-container-width, 2.5rem);
235
- --_icon-size: var(--np-tonal-icon-button-icon-size);
303
+ background-color: var(--np-color-surface-container);
236
304
  }
237
- .tonal.selected {
238
- --np-ripple-hover-color: var(--np-tonal-icon-button-icon-color, var(--np-color-primary));
239
- --np-ripple-pressed-color: var(--np-tonal-icon-button-icon-color, var(--np-color-primary));
305
+ .filled.selected {
306
+ --np-ripple-hover-color: var(--np-color-on-primary);
307
+ --np-ripple-pressed-color: var(--np-color-on-primary);
308
+ color: var(--np-color-on-primary);
309
+ background-color: var(--np-color-primary);
310
+ }
311
+
312
+ .tonal {
313
+ --np-ripple-hover-color: var(
314
+ --np-tonal-icon-button-icon-color,
315
+ var(--np-color-on-secondary-container)
316
+ );
317
+ --np-ripple-pressed-color: var(
318
+ --np-tonal-icon-button-icon-color,
319
+ var(--np-color-on-secondary-container)
320
+ );
240
321
  color: var(--np-tonal-icon-button-icon-color, var(--np-color-on-secondary-container));
241
322
  background-color: var(
242
323
  --np-tonal-icon-button-container-color,
243
324
  var(--np-color-secondary-container)
244
325
  );
245
326
  }
327
+ .tonal.toggle {
328
+ --np-ripple-hover-color: var(--np-color-on-secondary-container);
329
+ --np-ripple-pressed-color: var(--np-color-on-secondary-container);
330
+ color: var(--np-color-on-secondary-container);
331
+ background-color: var(--np-color-secondary-container);
332
+ }
333
+ .tonal.selected {
334
+ --np-ripple-hover-color: var(--np-color-on-secondary);
335
+ --np-ripple-pressed-color: var(--np-color-on-secondary);
336
+ color: var(--np-color-on-secondary);
337
+ background-color: var(--np-color-secondary);
338
+ }
246
339
 
247
340
  .outlined {
248
- border: 1px solid;
249
- border-style: solid;
250
- border-width: var(--np-outlined-icon-button-outline-width, 1px);
341
+ outline-style: solid;
342
+ outline-color: var(--np-outlined-icon-button-outline-color, var(--np-color-outline-variant));
343
+ outline-width: 1px;
344
+ outline-offset: -1px;
251
345
  --np-ripple-hover-color: var(--np-color-on-surface-variant);
252
346
  --np-ripple-pressed-color: var(--np-color-on-surface-variant);
253
347
  color: var(--np-color-on-surface-variant);
254
- border-color: var(--np-outlined-icon-button-outline-color, var(--np-color-outline));
255
- border-radius: var(--np-outlined-icon-button-container-shape, var(--np-shape-corner-full));
256
- height: var(--np-outlined-icon-button-container-height, 2.5rem);
257
- width: var(--np-outlined-icon-button-container-width, 2.5rem);
258
- --_icon-size: var(--np-outlined-icon-button-icon-size);
259
348
  }
260
349
  .outlined.selected {
261
- border: none;
350
+ outline-style: none;
262
351
  --np-ripple-hover-color: var(--np-color-on-surface-variant);
263
352
  --np-ripple-pressed-color: var(--np-color-on-surface-variant);
264
353
  color: var(--np-color-inverse-on-surface);
@@ -271,7 +360,6 @@
271
360
  }
272
361
 
273
362
  .circular-progress {
274
- --np-circular-progress-size: calc(var(--button-height) * 0.75);
275
363
  --np-circular-progress-color: color-mix(in srgb, var(--np-color-on-surface) 38%, transparent);
276
364
  position: absolute;
277
365
  }
@@ -37,6 +37,9 @@ interface IconButtonButtonProps extends HTMLButtonAttributes {
37
37
  loadingAriaLabel?: string;
38
38
  keepTooltipOnClick?: boolean;
39
39
  selectedIcon?: Snippet;
40
+ shape?: 'round' | 'square';
41
+ size?: 'xs' | 's' | 'm' | 'l' | 'xl';
42
+ width?: 'narrow' | 'wide' | 'default';
40
43
  }
41
44
  interface IconButtonAnchorProps extends HTMLAnchorAttributes {
42
45
  variant?: 'text' | 'filled' | 'outlined' | 'tonal';
@@ -48,6 +51,9 @@ interface IconButtonAnchorProps extends HTMLAnchorAttributes {
48
51
  selected?: boolean;
49
52
  keepTooltipOnClick?: boolean;
50
53
  selectedIcon?: Snippet;
54
+ shape?: 'round' | 'square';
55
+ size?: 'xs' | 's' | 'm' | 'l' | 'xl';
56
+ width?: 'narrow' | 'wide' | 'default';
51
57
  }
52
58
  export type IconButtonProps = IconButtonButtonProps | IconButtonAnchorProps;
53
59
  export type ButtonProps = ButtonButtonProps | ButtonAnchorProps;
@@ -15,7 +15,7 @@
15
15
  font-family: 'Material Symbols Outlined';
16
16
  font-weight: normal;
17
17
  font-style: normal;
18
- font-size: var(--np-icon-size, 1.5rem);
18
+ font-size: var(--np-icon-size, var(--_icon-size, 1.5rem));
19
19
  line-height: 1;
20
20
  letter-spacing: normal;
21
21
  text-transform: none;
@@ -37,7 +37,6 @@
37
37
  display: inline-flex;
38
38
  fill: currentColor;
39
39
  color: var(--_icon-color);
40
- font-size: var(--np-icon-size, var(--_icon-size));
41
40
  inline-size: var(--np-icon-size, var(--_icon-size));
42
41
  block-size: var(--np-icon-size, var(--_icon-size));
43
42
  flex-shrink: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noph-ui",
3
- "version": "0.20.1",
3
+ "version": "0.21.1",
4
4
  "license": "MIT",
5
5
  "homepage": "https://noph.dev",
6
6
  "repository": {