@lundal/zed-solid 0.0.9 → 0.0.11

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.
@@ -0,0 +1,10 @@
1
+ import { JSX } from 'solid-js';
2
+
3
+ export type MessageProps = {
4
+ class?: string;
5
+ style?: JSX.CSSProperties;
6
+ type: "error" | "warning" | "info" | "success";
7
+ icon?: JSX.Element;
8
+ text: JSX.Element;
9
+ };
10
+ export declare function Message(props: MessageProps): JSX.Element;
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export * from './Headings.tsx';
12
12
  export * from './Icon.tsx';
13
13
  export * from './IconButton.tsx';
14
14
  export * from './Link.tsx';
15
+ export * from './Message.tsx';
15
16
  export * from './Nav.tsx';
16
17
  export * from './NavHeader.tsx';
17
18
  export * from './NavLink.tsx';
package/dist/index.js CHANGED
@@ -323,10 +323,10 @@ function mergeClasses(a, b) {
323
323
  return b;
324
324
  return void 0;
325
325
  }
326
- var _tmpl$$k = /* @__PURE__ */ template(`<button>`);
326
+ var _tmpl$$l = /* @__PURE__ */ template(`<button>`);
327
327
  function Button(props) {
328
328
  return (() => {
329
- var _el$ = _tmpl$$k();
329
+ var _el$ = _tmpl$$l();
330
330
  _el$.$$click = () => props.onClick !== "submit" && !props.busy && props.onClick();
331
331
  insert(_el$, () => props.label);
332
332
  createRenderEffect((_p$) => {
@@ -346,10 +346,10 @@ function Button(props) {
346
346
  })();
347
347
  }
348
348
  delegateEvents(["click"]);
349
- var _tmpl$$j = /* @__PURE__ */ template(`<div>`);
349
+ var _tmpl$$k = /* @__PURE__ */ template(`<div>`);
350
350
  function Card(props) {
351
351
  return (() => {
352
- var _el$ = _tmpl$$j();
352
+ var _el$ = _tmpl$$k();
353
353
  insert(_el$, () => props.children);
354
354
  createRenderEffect((_p$) => {
355
355
  var _v$ = mergeClasses("z-card", props.class), _v$2 = props.style;
@@ -363,10 +363,10 @@ function Card(props) {
363
363
  return _el$;
364
364
  })();
365
365
  }
366
- var _tmpl$$i = /* @__PURE__ */ template(`<div><input type=checkbox><label>`);
366
+ var _tmpl$$j = /* @__PURE__ */ template(`<div><input type=checkbox><label>`);
367
367
  function CheckBox(props) {
368
368
  return (() => {
369
- var _el$ = _tmpl$$i(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
369
+ var _el$ = _tmpl$$j(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
370
370
  _el$2.addEventListener("change", () => props.onChange(!props.value));
371
371
  insert(_el$3, () => props.label);
372
372
  createRenderEffect((_p$) => {
@@ -390,10 +390,10 @@ function CheckBox(props) {
390
390
  return _el$;
391
391
  })();
392
392
  }
393
- var _tmpl$$h = /* @__PURE__ */ template(`<fieldset><legend>`), _tmpl$2$5 = /* @__PURE__ */ template(`<div class=z-checkbox><input type=checkbox><label>`), _tmpl$3$3 = /* @__PURE__ */ template(`<div class=z-error>`), _tmpl$4$2 = /* @__PURE__ */ template(`<div class=z-error-placeholder>`);
393
+ var _tmpl$$i = /* @__PURE__ */ template(`<fieldset><legend>`), _tmpl$2$5 = /* @__PURE__ */ template(`<div class=z-checkbox><input type=checkbox><label>`), _tmpl$3$3 = /* @__PURE__ */ template(`<div class=z-error>`), _tmpl$4$2 = /* @__PURE__ */ template(`<div class=z-error-placeholder>`);
394
394
  function CheckBoxes(props) {
395
395
  return (() => {
396
- var _el$ = _tmpl$$h(), _el$2 = _el$.firstChild;
396
+ var _el$ = _tmpl$$i(), _el$2 = _el$.firstChild;
397
397
  insert(_el$2, () => props.label);
398
398
  insert(_el$, createComponent(For, {
399
399
  get each() {
@@ -445,10 +445,10 @@ function CheckBoxes(props) {
445
445
  return _el$;
446
446
  })();
447
447
  }
448
- var _tmpl$$g = /* @__PURE__ */ template(`<div>`);
448
+ var _tmpl$$h = /* @__PURE__ */ template(`<div>`);
449
449
  function Column(props) {
450
450
  return (() => {
451
- var _el$ = _tmpl$$g();
451
+ var _el$ = _tmpl$$h();
452
452
  insert(_el$, () => props.children);
453
453
  createRenderEffect((_p$) => {
454
454
  var _v$ = mergeClasses("z-column", props.class), _v$2 = props.style;
@@ -462,7 +462,7 @@ function Column(props) {
462
462
  return _el$;
463
463
  })();
464
464
  }
465
- var _tmpl$$f = /* @__PURE__ */ template(`<dialog>`);
465
+ var _tmpl$$g = /* @__PURE__ */ template(`<dialog>`);
466
466
  function Dialog(props) {
467
467
  const [wasOutside, setWasOutside] = createSignal(false);
468
468
  function isOutside(e) {
@@ -482,7 +482,7 @@ function Dialog(props) {
482
482
  }, 100);
483
483
  }
484
484
  return (() => {
485
- var _el$ = _tmpl$$f();
485
+ var _el$ = _tmpl$$g();
486
486
  _el$.$$click = (e) => {
487
487
  if (wasOutside() && isOutside(e)) {
488
488
  e.preventDefault();
@@ -512,10 +512,10 @@ function Dialog(props) {
512
512
  })();
513
513
  }
514
514
  delegateEvents(["mousedown", "click"]);
515
- var _tmpl$$e = /* @__PURE__ */ template(`<div>`), _tmpl$2$4 = /* @__PURE__ */ template(`<label>`), _tmpl$3$2 = /* @__PURE__ */ template(`<div class=z-error>`), _tmpl$4$1 = /* @__PURE__ */ template(`<div class=z-error-placeholder>`);
515
+ var _tmpl$$f = /* @__PURE__ */ template(`<div>`), _tmpl$2$4 = /* @__PURE__ */ template(`<label>`), _tmpl$3$2 = /* @__PURE__ */ template(`<div class=z-error>`), _tmpl$4$1 = /* @__PURE__ */ template(`<div class=z-error-placeholder>`);
516
516
  function Field(props) {
517
517
  return (() => {
518
- var _el$ = _tmpl$$e();
518
+ var _el$ = _tmpl$$f();
519
519
  insert(_el$, (() => {
520
520
  var _c$ = createMemo(() => !!props.label);
521
521
  return () => _c$() && (() => {
@@ -555,10 +555,10 @@ function Field(props) {
555
555
  return _el$;
556
556
  })();
557
557
  }
558
- var _tmpl$$d = /* @__PURE__ */ template(`<form>`);
558
+ var _tmpl$$e = /* @__PURE__ */ template(`<form>`);
559
559
  function Form(props) {
560
560
  return (() => {
561
- var _el$ = _tmpl$$d();
561
+ var _el$ = _tmpl$$e();
562
562
  _el$.addEventListener("submit", (event) => {
563
563
  event.preventDefault();
564
564
  props.onSubmit();
@@ -576,10 +576,10 @@ function Form(props) {
576
576
  return _el$;
577
577
  })();
578
578
  }
579
- var _tmpl$$c = /* @__PURE__ */ template(`<header><a class=z-header--app href=/><span></span></a><div class=z-header--buttons>`);
579
+ var _tmpl$$d = /* @__PURE__ */ template(`<header><a class=z-header--app href=/><span></span></a><div class=z-header--buttons>`);
580
580
  function Header(props) {
581
581
  return (() => {
582
- var _el$ = _tmpl$$c(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$2.nextSibling;
582
+ var _el$ = _tmpl$$d(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$2.nextSibling;
583
583
  insert(_el$2, () => props.appIcon, _el$3);
584
584
  insert(_el$3, () => props.appName);
585
585
  insert(_el$4, () => props.children);
@@ -595,10 +595,10 @@ function Header(props) {
595
595
  return _el$;
596
596
  })();
597
597
  }
598
- var _tmpl$$b = /* @__PURE__ */ template(`<h1>`), _tmpl$2$3 = /* @__PURE__ */ template(`<h2>`), _tmpl$3$1 = /* @__PURE__ */ template(`<h3>`);
598
+ var _tmpl$$c = /* @__PURE__ */ template(`<h1>`), _tmpl$2$3 = /* @__PURE__ */ template(`<h2>`), _tmpl$3$1 = /* @__PURE__ */ template(`<h3>`);
599
599
  function H1(props) {
600
600
  return (() => {
601
- var _el$ = _tmpl$$b();
601
+ var _el$ = _tmpl$$c();
602
602
  insert(_el$, () => props.children);
603
603
  createRenderEffect((_p$) => {
604
604
  var _v$ = mergeClasses("z-" + (props.lookLike ?? "h1"), props.class), _v$2 = props.style;
@@ -644,7 +644,7 @@ function H3(props) {
644
644
  return _el$3;
645
645
  })();
646
646
  }
647
- var _tmpl$$a = /* @__PURE__ */ template(`<svg>`), _tmpl$2$2 = /* @__PURE__ */ template(`<svg><path fill=currentColor></svg>`, false, true);
647
+ var _tmpl$$b = /* @__PURE__ */ template(`<svg>`), _tmpl$2$2 = /* @__PURE__ */ template(`<svg><path fill=currentColor></svg>`, false, true);
648
648
  function Icon(props) {
649
649
  const data = createMemo(() => {
650
650
  const [width, height, , , paths] = props.definition.icon;
@@ -655,7 +655,7 @@ function Icon(props) {
655
655
  };
656
656
  });
657
657
  return (() => {
658
- var _el$ = _tmpl$$a();
658
+ var _el$ = _tmpl$$b();
659
659
  insert(_el$, createComponent(For, {
660
660
  get each() {
661
661
  return data().paths;
@@ -680,10 +680,10 @@ function Icon(props) {
680
680
  return _el$;
681
681
  })();
682
682
  }
683
- var _tmpl$$9 = /* @__PURE__ */ template(`<button>`);
683
+ var _tmpl$$a = /* @__PURE__ */ template(`<button>`);
684
684
  function IconButton(props) {
685
685
  return (() => {
686
- var _el$ = _tmpl$$9();
686
+ var _el$ = _tmpl$$a();
687
687
  _el$.$$click = () => !props.busy && props.onClick();
688
688
  insert(_el$, () => props.icon);
689
689
  createRenderEffect((_p$) => {
@@ -724,6 +724,64 @@ function Link(props) {
724
724
  }
725
725
  });
726
726
  }
727
+ var faCircleCheck = {
728
+ prefix: "fas",
729
+ iconName: "circle-check",
730
+ icon: [512, 512, [61533, "check-circle"], "f058", "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"]
731
+ };
732
+ var faCircleInfo = {
733
+ prefix: "fas",
734
+ iconName: "circle-info",
735
+ icon: [512, 512, ["info-circle"], "f05a", "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"]
736
+ };
737
+ var faTriangleExclamation = {
738
+ prefix: "fas",
739
+ iconName: "triangle-exclamation",
740
+ icon: [512, 512, [9888, "exclamation-triangle", "warning"], "f071", "M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"]
741
+ };
742
+ var faCircleXmark = {
743
+ prefix: "fas",
744
+ iconName: "circle-xmark",
745
+ icon: [512, 512, [61532, "times-circle", "xmark-circle"], "f057", "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"]
746
+ };
747
+ var _tmpl$$9 = /* @__PURE__ */ template(`<div><div class=z-message--icon></div><div class=z-message--text>`);
748
+ function Message(props) {
749
+ function defaultIcon() {
750
+ switch (props.type) {
751
+ case "error":
752
+ return createComponent(Icon, {
753
+ definition: faCircleXmark
754
+ });
755
+ case "warning":
756
+ return createComponent(Icon, {
757
+ definition: faTriangleExclamation
758
+ });
759
+ case "info":
760
+ return createComponent(Icon, {
761
+ definition: faCircleInfo
762
+ });
763
+ case "success":
764
+ return createComponent(Icon, {
765
+ definition: faCircleCheck
766
+ });
767
+ }
768
+ }
769
+ return (() => {
770
+ var _el$ = _tmpl$$9(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
771
+ insert(_el$2, () => props.icon ?? defaultIcon());
772
+ insert(_el$3, () => props.text);
773
+ createRenderEffect((_p$) => {
774
+ var _v$ = mergeClasses(`z-message z-message--${props.type}`, props.class), _v$2 = props.style;
775
+ _v$ !== _p$.e && className(_el$, _p$.e = _v$);
776
+ _p$.t = style(_el$, _v$2, _p$.t);
777
+ return _p$;
778
+ }, {
779
+ e: void 0,
780
+ t: void 0
781
+ });
782
+ return _el$;
783
+ })();
784
+ }
727
785
  var _tmpl$$8 = /* @__PURE__ */ template(`<nav>`);
728
786
  function Nav(props) {
729
787
  return (() => {
@@ -972,6 +1030,7 @@ export {
972
1030
  Icon,
973
1031
  IconButton,
974
1032
  Link,
1033
+ Message,
975
1034
  Nav,
976
1035
  NavHeader,
977
1036
  NavLink,
package/dist/style.css CHANGED
@@ -295,6 +295,43 @@ dialog:focus-visible {
295
295
  .z-link:focus-visible {
296
296
  outline-color: var(--z-focus);
297
297
  }
298
+ .z-message {
299
+ width: 100%;
300
+ display: flex;
301
+ align-items: center;
302
+ gap: 12px;
303
+ padding: 12px;
304
+ border-radius: 6px;
305
+ background: var(--background);
306
+ border: 2px solid var(--border);
307
+ }
308
+
309
+ .z-message--icon {
310
+ flex-shrink: 0;
311
+ width: 24px;
312
+ height: 24px;
313
+ color: var(--border);
314
+ }
315
+
316
+ .z-message--error {
317
+ --background: var(--z-message-error-background);
318
+ --border: var(--z-message-error-border);
319
+ }
320
+
321
+ .z-message--warning {
322
+ --background: var(--z-message-warning-background);
323
+ --border: var(--z-message-warning-border);
324
+ }
325
+
326
+ .z-message--info {
327
+ --background: var(--z-message-info-background);
328
+ --border: var(--z-message-info-border);
329
+ }
330
+
331
+ .z-message--success {
332
+ --background: var(--z-message-success-background);
333
+ --border: var(--z-message-success-border);
334
+ }
298
335
  .z-nav {
299
336
  min-width: 200px;
300
337
  padding-bottom: 12px;
@@ -580,6 +617,16 @@ dialog:focus-visible {
580
617
  --z-input-active-fill: #5252ff; /* Lc 75 */
581
618
  --z-input-error-border: #ff5252; /* Lc 60 */
582
619
  --z-input-error-fill: #cf1b1b; /* Lc 75 */
620
+
621
+ /* TODO: Tweak colors */
622
+ --z-message-error-border: #db3a32;
623
+ --z-message-error-background: #db3a3220;
624
+ --z-message-warning-border: #c47f2c;
625
+ --z-message-warning-background: #c47f2c20;
626
+ --z-message-info-border: #3276db;
627
+ --z-message-info-background: #3276db20;
628
+ --z-message-success-border: #21a341;
629
+ --z-message-success-background: #21a34120;
583
630
  }
584
631
 
585
632
  .z-theme--dark {
@@ -602,4 +649,14 @@ dialog:focus-visible {
602
649
  --z-input-active-fill: #7882ff; /* Lc 40 */
603
650
  --z-input-error-border: #db3a32; /* Lc 30 */
604
651
  --z-input-error-fill: #ff483f; /* Lc 40 */
652
+
653
+ /* TODO: Tweak colors */
654
+ --z-message-error-border: #db3a32;
655
+ --z-message-error-background: #db3a3220;
656
+ --z-message-warning-border: #c47f2c;
657
+ --z-message-warning-background: #c47f2c20;
658
+ --z-message-info-border: #3276db;
659
+ --z-message-info-background: #3276db20;
660
+ --z-message-success-border: #21a341;
661
+ --z-message-success-background: #21a34120;
605
662
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lundal/zed-solid",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
@@ -31,6 +31,9 @@
31
31
  "@solidjs/router": "0.13",
32
32
  "solid-js": "1"
33
33
  },
34
+ "optionalDependencies": {
35
+ "@fortawesome/free-solid-svg-icons": "6"
36
+ },
34
37
  "dependencies": {
35
38
  "@fontsource/inter": "5"
36
39
  }