@mhmo91/schmancy 0.9.22 → 0.9.23

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/dist/teleport.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./src-C9DpHCWF.cjs`);exports.HereMorty=e.r,Object.defineProperty(exports,`SchmancyTeleportation`,{enumerable:!0,get:function(){return e.n}}),exports.WhereAreYouRicky=e.i,exports.teleport=e.a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./src-Ci10_Iwf.cjs`);exports.HereMorty=e.r,Object.defineProperty(exports,`SchmancyTeleportation`,{enumerable:!0,get:function(){return e.n}}),exports.WhereAreYouRicky=e.i,exports.teleport=e.a;
package/dist/teleport.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as e, i as t, n, r } from "./src-B0jLOpqn.js";
1
+ import { a as e, i as t, n, r } from "./src-DNuhxDig.js";
2
2
  export { r as HereMorty, n as SchmancyTeleportation, t as WhereAreYouRicky, e as teleport };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mhmo91/schmancy",
3
- "version": "0.9.22",
3
+ "version": "0.9.23",
4
4
  "description": "UI library build with web components",
5
5
  "main": "./dist/index.js",
6
6
  "customElements": "custom-elements.json",
package/src/index.ts CHANGED
@@ -37,6 +37,7 @@ export * from './list';
37
37
  export * from './mailbox';
38
38
  export * from './map';
39
39
  export * from './menu';
40
+ export * from './metric';
40
41
  export * from './nav-drawer';
41
42
  export * from './navigation-bar';
42
43
  export * from './navigation-rail';
@@ -0,0 +1 @@
1
+ export * from './metric';
@@ -0,0 +1,127 @@
1
+ import { TailwindElement } from '@mixins/index'
2
+ import { css, html, nothing } from 'lit'
3
+ import { customElement, property } from 'lit/decorators.js'
4
+
5
+ export type MetricTrend = 'up' | 'down' | 'neutral'
6
+ export type MetricSize = 'sm' | 'md' | 'lg'
7
+
8
+ /**
9
+ * KPI metric — a label + value pair for dashboards, with optional trend + delta indicators.
10
+ *
11
+ * @element schmancy-metric
12
+ * @summary The building block of dashboards and meta bars. Pass `label` + `value` for a basic stat; add `trend` / `delta` for the delta-from-last-period pattern. Use multiple metrics side-by-side with Tailwind flex/grid utilities.
13
+ * @example
14
+ * <schmancy-metric label="In flight" value="4"></schmancy-metric>
15
+ * <schmancy-metric label="Open value" value="€165,900" trend="up" delta="+12%"></schmancy-metric>
16
+ * <schmancy-metric label="Error rate" value="0.3%" trend="down" delta="-0.1%"></schmancy-metric>
17
+ * @platform div - Styled `<div>` with two text lines + optional trend arrow. Degrades to a plain div+spans if the tag never registers.
18
+ * @slot - Optional custom value rendering (overrides the `value` attribute if present).
19
+ * @slot label - Optional custom label rendering (overrides the `label` attribute if present).
20
+ * @csspart label - The label line.
21
+ * @csspart value - The value line.
22
+ * @csspart delta - The delta pill (only when `delta` is set).
23
+ */
24
+ @customElement('schmancy-metric')
25
+ export class SchmancyMetric extends TailwindElement(css`
26
+ :host {
27
+ display: inline-flex;
28
+ flex-direction: column;
29
+ gap: 0.25rem;
30
+ min-width: 0;
31
+ }
32
+ :host([size='sm']) .label { font-size: 0.6875rem; }
33
+ :host([size='sm']) .value { font-size: 1.25rem; }
34
+ :host([size='md']) .label { font-size: 0.75rem; }
35
+ :host([size='md']) .value { font-size: 1.75rem; }
36
+ :host([size='lg']) .label { font-size: 0.8125rem; }
37
+ :host([size='lg']) .value { font-size: 2.5rem; }
38
+ .label {
39
+ font-weight: 500;
40
+ letter-spacing: 0.08em;
41
+ text-transform: uppercase;
42
+ color: var(--schmancy-sys-color-surface-onVariant);
43
+ }
44
+ .value {
45
+ font-weight: 600;
46
+ line-height: 1.1;
47
+ color: var(--schmancy-sys-color-surface-on);
48
+ font-variant-numeric: tabular-nums;
49
+ }
50
+ .delta {
51
+ display: inline-flex;
52
+ align-items: center;
53
+ gap: 0.125rem;
54
+ font-size: 0.75rem;
55
+ font-weight: 600;
56
+ padding: 0.125rem 0.375rem;
57
+ border-radius: 999px;
58
+ font-variant-numeric: tabular-nums;
59
+ }
60
+ .delta[data-trend='up'] {
61
+ color: var(--schmancy-sys-color-success-on);
62
+ background: var(--schmancy-sys-color-success-default);
63
+ }
64
+ .delta[data-trend='down'] {
65
+ color: var(--schmancy-sys-color-error-on);
66
+ background: var(--schmancy-sys-color-error-default);
67
+ }
68
+ .delta[data-trend='neutral'] {
69
+ color: var(--schmancy-sys-color-surface-on);
70
+ background: var(--schmancy-sys-color-surface-containerHigh);
71
+ }
72
+ .arrow {
73
+ font-size: 0.625rem;
74
+ line-height: 1;
75
+ }
76
+ .row {
77
+ display: inline-flex;
78
+ align-items: baseline;
79
+ gap: 0.5rem;
80
+ flex-wrap: wrap;
81
+ }
82
+ `) {
83
+ /** Upper-case caption shown above the value. */
84
+ @property({ type: String }) label = ''
85
+
86
+ /** Primary metric value, rendered large. Pre-format numbers/currency yourself. */
87
+ @property({ type: String }) value = ''
88
+
89
+ /** Optional trend direction. Controls the color + arrow on the delta pill. */
90
+ @property({ type: String, reflect: true }) trend?: MetricTrend
91
+
92
+ /** Optional delta copy displayed in a pill next to the value (e.g. `+12%`). */
93
+ @property({ type: String }) delta?: string
94
+
95
+ /** Size scale affecting label + value typography. */
96
+ @property({ type: String, reflect: true }) size: MetricSize = 'md'
97
+
98
+ private _arrowFor(trend: MetricTrend | undefined): string {
99
+ if (trend === 'up') return '↑'
100
+ if (trend === 'down') return '↓'
101
+ return '→'
102
+ }
103
+
104
+ protected render(): unknown {
105
+ const trend = this.trend ?? 'neutral'
106
+ return html`
107
+ <span class="label" part="label"><slot name="label">${this.label}</slot></span>
108
+ <span class="row">
109
+ <span class="value" part="value"><slot>${this.value}</slot></span>
110
+ ${this.delta
111
+ ? html`
112
+ <span class="delta" part="delta" data-trend=${trend}>
113
+ ${this.trend ? html`<span class="arrow" aria-hidden="true">${this._arrowFor(this.trend)}</span>` : nothing}
114
+ ${this.delta}
115
+ </span>
116
+ `
117
+ : nothing}
118
+ </span>
119
+ `
120
+ }
121
+ }
122
+
123
+ declare global {
124
+ interface HTMLElementTagNameMap {
125
+ 'schmancy-metric': SchmancyMetric
126
+ }
127
+ }
@@ -37,6 +37,7 @@ export * from './list';
37
37
  export * from './mailbox';
38
38
  export * from './map';
39
39
  export * from './menu';
40
+ export * from './metric';
40
41
  export * from './nav-drawer';
41
42
  export * from './navigation-bar';
42
43
  export * from './navigation-rail';
@@ -0,0 +1 @@
1
+ export * from './metric';
@@ -0,0 +1,39 @@
1
+ export type MetricTrend = 'up' | 'down' | 'neutral';
2
+ export type MetricSize = 'sm' | 'md' | 'lg';
3
+ declare const SchmancyMetric_base: import("@mixins/index").Constructor<CustomElementConstructor> & import("@mixins/index").Constructor<import("@mixins/index").ITailwindElementMixin> & import("@mixins/index").Constructor<import("lit").LitElement> & import("@mixins/index").Constructor<import("@mixins/index").IBaseMixin>;
4
+ /**
5
+ * KPI metric — a label + value pair for dashboards, with optional trend + delta indicators.
6
+ *
7
+ * @element schmancy-metric
8
+ * @summary The building block of dashboards and meta bars. Pass `label` + `value` for a basic stat; add `trend` / `delta` for the delta-from-last-period pattern. Use multiple metrics side-by-side with Tailwind flex/grid utilities.
9
+ * @example
10
+ * <schmancy-metric label="In flight" value="4"></schmancy-metric>
11
+ * <schmancy-metric label="Open value" value="€165,900" trend="up" delta="+12%"></schmancy-metric>
12
+ * <schmancy-metric label="Error rate" value="0.3%" trend="down" delta="-0.1%"></schmancy-metric>
13
+ * @platform div - Styled `<div>` with two text lines + optional trend arrow. Degrades to a plain div+spans if the tag never registers.
14
+ * @slot - Optional custom value rendering (overrides the `value` attribute if present).
15
+ * @slot label - Optional custom label rendering (overrides the `label` attribute if present).
16
+ * @csspart label - The label line.
17
+ * @csspart value - The value line.
18
+ * @csspart delta - The delta pill (only when `delta` is set).
19
+ */
20
+ export declare class SchmancyMetric extends SchmancyMetric_base {
21
+ /** Upper-case caption shown above the value. */
22
+ label: string;
23
+ /** Primary metric value, rendered large. Pre-format numbers/currency yourself. */
24
+ value: string;
25
+ /** Optional trend direction. Controls the color + arrow on the delta pill. */
26
+ trend?: MetricTrend;
27
+ /** Optional delta copy displayed in a pill next to the value (e.g. `+12%`). */
28
+ delta?: string;
29
+ /** Size scale affecting label + value typography. */
30
+ size: MetricSize;
31
+ private _arrowFor;
32
+ protected render(): unknown;
33
+ }
34
+ declare global {
35
+ interface HTMLElementTagNameMap {
36
+ 'schmancy-metric': SchmancyMetric;
37
+ }
38
+ }
39
+ export {};