@idealyst/theme 1.2.38 → 1.2.40

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/builder.ts +195 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idealyst/theme",
3
- "version": "1.2.38",
3
+ "version": "1.2.40",
4
4
  "description": "Theming system for Idealyst Framework",
5
5
  "readme": "README.md",
6
6
  "main": "src/index.ts",
package/src/builder.ts CHANGED
@@ -173,6 +173,25 @@ export class ThemeBuilder<
173
173
  return newBuilder;
174
174
  }
175
175
 
176
+ /**
177
+ * Set (replace) an existing intent in the theme.
178
+ * Use this to override an intent inherited from a base theme.
179
+ */
180
+ setIntent<K extends TIntents>(
181
+ name: K,
182
+ value: IntentValue
183
+ ): ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface, TText, TBorder, TSize, TBreakpoints> {
184
+ const newBuilder = new ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface, TText, TBorder, TSize, TBreakpoints>();
185
+ newBuilder.config = {
186
+ ...this.config,
187
+ intents: {
188
+ ...this.config.intents,
189
+ [name]: value,
190
+ } as any,
191
+ };
192
+ return newBuilder;
193
+ }
194
+
176
195
  /**
177
196
  * Add a custom border radius value.
178
197
  */
@@ -245,6 +264,182 @@ export class ThemeBuilder<
245
264
  return newBuilder;
246
265
  }
247
266
 
267
+ /**
268
+ * Add a new pallet color to the theme.
269
+ * Expands the available pallet colors.
270
+ */
271
+ addPalletColor<K extends string>(
272
+ name: K,
273
+ shades: Record<Shade, ColorValue>
274
+ ): ThemeBuilder<TIntents, TRadii, TShadows, TPallet | K, TSurface, TText, TBorder, TSize, TBreakpoints> {
275
+ const newBuilder = new ThemeBuilder<TIntents, TRadii, TShadows, TPallet | K, TSurface, TText, TBorder, TSize, TBreakpoints>();
276
+ newBuilder.config = {
277
+ ...this.config,
278
+ colors: {
279
+ ...this.config.colors,
280
+ pallet: {
281
+ ...this.config.colors.pallet,
282
+ [name]: shades,
283
+ } as any,
284
+ },
285
+ };
286
+ return newBuilder;
287
+ }
288
+
289
+ /**
290
+ * Set (replace) an existing pallet color in the theme.
291
+ * Use this to override a pallet color inherited from a base theme.
292
+ */
293
+ setPalletColor<K extends TPallet>(
294
+ name: K,
295
+ shades: Record<Shade, ColorValue>
296
+ ): ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface, TText, TBorder, TSize, TBreakpoints> {
297
+ const newBuilder = new ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface, TText, TBorder, TSize, TBreakpoints>();
298
+ newBuilder.config = {
299
+ ...this.config,
300
+ colors: {
301
+ ...this.config.colors,
302
+ pallet: {
303
+ ...this.config.colors.pallet,
304
+ [name]: shades,
305
+ } as any,
306
+ },
307
+ };
308
+ return newBuilder;
309
+ }
310
+
311
+ /**
312
+ * Add a new surface color to the theme.
313
+ * Expands the available surface colors.
314
+ */
315
+ addSurfaceColor<K extends string>(
316
+ name: K,
317
+ value: ColorValue
318
+ ): ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface | K, TText, TBorder, TSize, TBreakpoints> {
319
+ const newBuilder = new ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface | K, TText, TBorder, TSize, TBreakpoints>();
320
+ newBuilder.config = {
321
+ ...this.config,
322
+ colors: {
323
+ ...this.config.colors,
324
+ surface: {
325
+ ...this.config.colors.surface,
326
+ [name]: value,
327
+ } as any,
328
+ },
329
+ };
330
+ return newBuilder;
331
+ }
332
+
333
+ /**
334
+ * Set (replace) an existing surface color in the theme.
335
+ * Use this to override a surface color inherited from a base theme.
336
+ */
337
+ setSurfaceColor<K extends TSurface>(
338
+ name: K,
339
+ value: ColorValue
340
+ ): ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface, TText, TBorder, TSize, TBreakpoints> {
341
+ const newBuilder = new ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface, TText, TBorder, TSize, TBreakpoints>();
342
+ newBuilder.config = {
343
+ ...this.config,
344
+ colors: {
345
+ ...this.config.colors,
346
+ surface: {
347
+ ...this.config.colors.surface,
348
+ [name]: value,
349
+ } as any,
350
+ },
351
+ };
352
+ return newBuilder;
353
+ }
354
+
355
+ /**
356
+ * Add a new text color to the theme.
357
+ * Expands the available text colors.
358
+ */
359
+ addTextColor<K extends string>(
360
+ name: K,
361
+ value: ColorValue
362
+ ): ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface, TText | K, TBorder, TSize, TBreakpoints> {
363
+ const newBuilder = new ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface, TText | K, TBorder, TSize, TBreakpoints>();
364
+ newBuilder.config = {
365
+ ...this.config,
366
+ colors: {
367
+ ...this.config.colors,
368
+ text: {
369
+ ...this.config.colors.text,
370
+ [name]: value,
371
+ } as any,
372
+ },
373
+ };
374
+ return newBuilder;
375
+ }
376
+
377
+ /**
378
+ * Set (replace) an existing text color in the theme.
379
+ * Use this to override a text color inherited from a base theme.
380
+ */
381
+ setTextColor<K extends TText>(
382
+ name: K,
383
+ value: ColorValue
384
+ ): ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface, TText, TBorder, TSize, TBreakpoints> {
385
+ const newBuilder = new ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface, TText, TBorder, TSize, TBreakpoints>();
386
+ newBuilder.config = {
387
+ ...this.config,
388
+ colors: {
389
+ ...this.config.colors,
390
+ text: {
391
+ ...this.config.colors.text,
392
+ [name]: value,
393
+ } as any,
394
+ },
395
+ };
396
+ return newBuilder;
397
+ }
398
+
399
+ /**
400
+ * Add a new border color to the theme.
401
+ * Expands the available border colors.
402
+ */
403
+ addBorderColor<K extends string>(
404
+ name: K,
405
+ value: ColorValue
406
+ ): ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface, TText, TBorder | K, TSize, TBreakpoints> {
407
+ const newBuilder = new ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface, TText, TBorder | K, TSize, TBreakpoints>();
408
+ newBuilder.config = {
409
+ ...this.config,
410
+ colors: {
411
+ ...this.config.colors,
412
+ border: {
413
+ ...this.config.colors.border,
414
+ [name]: value,
415
+ } as any,
416
+ },
417
+ };
418
+ return newBuilder;
419
+ }
420
+
421
+ /**
422
+ * Set (replace) an existing border color in the theme.
423
+ * Use this to override a border color inherited from a base theme.
424
+ */
425
+ setBorderColor<K extends TBorder>(
426
+ name: K,
427
+ value: ColorValue
428
+ ): ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface, TText, TBorder, TSize, TBreakpoints> {
429
+ const newBuilder = new ThemeBuilder<TIntents, TRadii, TShadows, TPallet, TSurface, TText, TBorder, TSize, TBreakpoints>();
430
+ newBuilder.config = {
431
+ ...this.config,
432
+ colors: {
433
+ ...this.config.colors,
434
+ border: {
435
+ ...this.config.colors.border,
436
+ [name]: value,
437
+ } as any,
438
+ },
439
+ };
440
+ return newBuilder;
441
+ }
442
+
248
443
  /**
249
444
  * Set the sizes configuration.
250
445
  */