@atom63/widgets 0.1.0-beta.0

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,136 @@
1
+ /*
2
+ * Widget runtime: the loading and error shells a host shows while a widget
3
+ * module loads or after it fails, and the layers the hosted shell crossfades
4
+ * when a widget changes size.
5
+ */
6
+
7
+ /* Shared centered spinner inside an existing shell. */
8
+ .a63-WidgetContentFallback {
9
+ display: flex;
10
+ flex: 1 1 0%;
11
+ align-items: center;
12
+ justify-content: center;
13
+ inline-size: 100%;
14
+ block-size: 100%;
15
+ min-block-size: 0;
16
+ }
17
+
18
+ .a63-WidgetContentFallback-icon {
19
+ inline-size: var(--a63-space-5);
20
+ block-size: var(--a63-space-5);
21
+ color: var(--a63-text-secondary);
22
+ }
23
+
24
+ .a63-WidgetHostFallback {
25
+ inline-size: 100%;
26
+ block-size: 100%;
27
+ min-block-size: 0;
28
+ }
29
+
30
+ .a63-WidgetHostLoadingShell-content {
31
+ flex: 1 1 0%;
32
+ min-block-size: 0;
33
+ }
34
+
35
+ .a63-WidgetHostErrorFallback-content {
36
+ flex: 1 1 0%;
37
+ align-items: center;
38
+ justify-content: center;
39
+ gap: var(--a63-space-3);
40
+ min-block-size: 0;
41
+ text-align: center;
42
+ }
43
+
44
+ .a63-WidgetHostErrorFallback-icon {
45
+ color: var(--a63-text-danger);
46
+ }
47
+
48
+ .a63-WidgetHostErrorFallback-message {
49
+ max-inline-size: 100%;
50
+ margin: 0;
51
+ color: var(--a63-text-secondary);
52
+ }
53
+
54
+ /*
55
+ * The crossfade slot clips its layers; each layer is pinned to the slot so
56
+ * the outgoing and incoming content overlap instead of stacking.
57
+ */
58
+ .a63-WidgetHostContentTransition {
59
+ position: relative;
60
+ flex: 1 1 0%;
61
+ isolation: isolate;
62
+ inline-size: 100%;
63
+ min-inline-size: 0;
64
+ min-block-size: 0;
65
+ overflow: hidden;
66
+ }
67
+
68
+ .a63-WidgetHostContentTransition-layer {
69
+ position: absolute;
70
+ inset-block: 0;
71
+ inset-inline-start: 0;
72
+ display: flex;
73
+ flex-direction: column;
74
+ min-inline-size: 0;
75
+ max-inline-size: 100%;
76
+ min-block-size: 0;
77
+ overflow: hidden;
78
+ transform-origin: top left;
79
+ }
80
+
81
+ .a63-WidgetHostTitleTransition {
82
+ position: relative;
83
+ isolation: isolate;
84
+ min-inline-size: 0;
85
+ overflow: hidden;
86
+ }
87
+
88
+ /* Crossfade keeps both layers in flow on one grid cell, at the taller height. */
89
+ .a63-WidgetHostTitleTransition[data-variant='crossfade'] {
90
+ display: grid;
91
+ }
92
+
93
+ .a63-WidgetHostTitleTransition[data-variant='crossfade'] > * {
94
+ grid-row-start: 1;
95
+ grid-column-start: 1;
96
+ }
97
+
98
+ /* Slide never lets its layers size the box: they pin to the reserved box. */
99
+ .a63-WidgetHostTitleTransition[data-variant='slide'] {
100
+ contain: layout size;
101
+ }
102
+
103
+ .a63-WidgetHostTitleTransition-layer {
104
+ display: flex;
105
+ align-items: flex-start;
106
+ inline-size: 100%;
107
+ min-inline-size: 0;
108
+ overflow: hidden;
109
+ }
110
+
111
+ .a63-WidgetHostTitleTransition[data-variant='slide'] > .a63-WidgetHostTitleTransition-layer {
112
+ position: absolute;
113
+ inset: 0;
114
+ }
115
+
116
+ .a63-WidgetHostOptionalHeader {
117
+ flex-shrink: 0;
118
+ overflow: hidden;
119
+ }
120
+
121
+ /* ── Shared spin ───────────────────────────────────────────────────────── */
122
+ @keyframes a63-widget-spin {
123
+ to {
124
+ transform: rotate(360deg);
125
+ }
126
+ }
127
+
128
+ .a63-Widget-spin {
129
+ animation: a63-widget-spin var(--duration-slower) linear infinite;
130
+ }
131
+
132
+ @media (prefers-reduced-motion: reduce) {
133
+ .a63-Widget-spin {
134
+ animation: none;
135
+ }
136
+ }
@@ -0,0 +1,149 @@
1
+ /*
2
+ * Widget state feedback: loading, empty and error. It pads itself and draws no
3
+ * border or fill, so it renders the same wherever it is mounted. The one-row
4
+ * footprints share the compact density; the 2x2 footprint gets the large one.
5
+ */
6
+ .a63-WidgetStateFeedback {
7
+ display: flex;
8
+ box-sizing: border-box;
9
+ flex-direction: column;
10
+ align-items: center;
11
+ justify-content: center;
12
+ gap: var(--a63-space-2);
13
+ inline-size: 100%;
14
+ block-size: 100%;
15
+ min-block-size: 0;
16
+ padding-block: var(--a63-space-2);
17
+ padding-inline: var(--a63-space-3);
18
+ text-align: center;
19
+ }
20
+
21
+ .a63-WidgetStateFeedback[data-density='large'] {
22
+ gap: var(--a63-space-3);
23
+ min-block-size: calc(var(--a63-space-1) * 32);
24
+ padding-block: var(--a63-space-6);
25
+ padding-inline: var(--a63-space-5);
26
+ }
27
+
28
+ .a63-WidgetStateFeedback-badge {
29
+ display: flex;
30
+ flex-shrink: 0;
31
+ box-sizing: border-box;
32
+ align-items: center;
33
+ justify-content: center;
34
+ inline-size: calc(var(--a63-space-1) * 8);
35
+ block-size: calc(var(--a63-space-1) * 8);
36
+ border: var(--a63-control-border-width) solid var(--a63-border-subtle);
37
+ border-radius: var(--radius-full);
38
+ background-color: color-mix(in oklab, var(--a63-surface-page) 70%, transparent);
39
+ box-shadow: var(--shadow-sm);
40
+ color: var(--a63-text-secondary);
41
+ }
42
+
43
+ .a63-WidgetStateFeedback[data-density='large'] .a63-WidgetStateFeedback-badge {
44
+ inline-size: calc(var(--a63-space-1) * 10);
45
+ block-size: calc(var(--a63-space-1) * 10);
46
+ }
47
+
48
+ .a63-WidgetStateFeedback[data-state='error'] .a63-WidgetStateFeedback-badge {
49
+ border-color: color-mix(in oklab, var(--a63-action-danger) 35%, transparent);
50
+ background-color: color-mix(in oklab, var(--a63-action-danger) 10%, transparent);
51
+ color: var(--a63-text-danger);
52
+ }
53
+
54
+ .a63-WidgetStateFeedback-icon {
55
+ inline-size: var(--a63-space-4);
56
+ block-size: var(--a63-space-4);
57
+ }
58
+
59
+ .a63-WidgetStateFeedback[data-density='large'] .a63-WidgetStateFeedback-icon {
60
+ inline-size: var(--a63-space-5);
61
+ block-size: var(--a63-space-5);
62
+ }
63
+
64
+ .a63-WidgetStateFeedback-text {
65
+ display: flex;
66
+ flex-direction: column;
67
+ gap: var(--a63-space-1);
68
+ max-inline-size: calc(var(--a63-space-1) * 64);
69
+ }
70
+
71
+ .a63-WidgetStateFeedback[data-density='large'] .a63-WidgetStateFeedback-text {
72
+ gap: var(--a63-space-1_5);
73
+ }
74
+
75
+ .a63-WidgetStateFeedback-title,
76
+ .a63-WidgetStateFeedback-description {
77
+ margin: 0;
78
+ }
79
+
80
+ .a63-WidgetStateFeedback[data-density='compact'] .a63-WidgetStateFeedback-title {
81
+ line-height: 1.25;
82
+ }
83
+
84
+ .a63-WidgetStateFeedback-description {
85
+ color: var(--a63-text-secondary);
86
+ }
87
+
88
+ .a63-WidgetStateFeedback[data-density='compact'] .a63-WidgetStateFeedback-description {
89
+ display: -webkit-box;
90
+ overflow: hidden;
91
+ line-height: 1.375;
92
+ -webkit-box-orient: vertical;
93
+ -webkit-line-clamp: 2;
94
+ }
95
+
96
+ /* ── Error actions ─────────────────────────────────────────────────────── */
97
+ .a63-WidgetStateFeedback-actions {
98
+ display: flex;
99
+ flex-shrink: 0;
100
+ align-items: center;
101
+ justify-content: center;
102
+ gap: var(--a63-space-2);
103
+ min-block-size: calc(var(--a63-space-1) * 8);
104
+ }
105
+
106
+ .a63-WidgetStateFeedback-action {
107
+ flex-shrink: 0;
108
+ }
109
+
110
+ .a63-WidgetStateFeedback-retryIcon {
111
+ inline-size: var(--a63-space-3);
112
+ block-size: var(--a63-space-3);
113
+ }
114
+
115
+ .a63-WidgetStateFeedback-detailsIcon {
116
+ inline-size: var(--a63-space-3_5);
117
+ block-size: var(--a63-space-3_5);
118
+ }
119
+
120
+ /* The error details popover renders in a portal, outside the widget. */
121
+ .a63-WidgetErrorDetails {
122
+ gap: var(--a63-space-3);
123
+ inline-size: calc(var(--a63-space-1) * 72);
124
+ max-inline-size: calc(100vw - var(--a63-space-4) * 2);
125
+ padding: var(--a63-space-3);
126
+ }
127
+
128
+ .a63-WidgetErrorDetails-header {
129
+ display: flex;
130
+ flex-direction: column;
131
+ gap: var(--a63-space-1);
132
+ text-align: start;
133
+ }
134
+
135
+ .a63-WidgetErrorDetails-message {
136
+ max-block-size: calc(var(--a63-space-1) * 32);
137
+ margin: 0;
138
+ padding: var(--a63-space-2);
139
+ overflow: auto;
140
+ border-radius: var(--radius-md);
141
+ background-color: var(--a63-surface-muted);
142
+ color: var(--a63-text-secondary);
143
+ font-family: var(--font-mono);
144
+ font-size: var(--typography-xs-font-size);
145
+ line-height: 1.625;
146
+ text-align: start;
147
+ overflow-wrap: break-word;
148
+ user-select: text;
149
+ }
package/src/styles.css ADDED
@@ -0,0 +1,20 @@
1
+ /*
2
+ * @atom63/widgets styles: the `.a63-Widget*` classes the foundation renders.
3
+ *
4
+ * Load it after @atom63/styles and the @atom63/ui-react recipes (the states and
5
+ * fallbacks use ui-react buttons, the popover and the avatar):
6
+ *
7
+ * @import '@atom63/styles';
8
+ * @import '@atom63/ui-react/recipes.css';
9
+ * @import '@atom63/widgets/styles.css';
10
+ *
11
+ * It needs no Tailwind: every value reads an --a63-* token, and the surface
12
+ * reads the widget contract (--a63-widget-*). The classes sit in the
13
+ * `components` layer, so a consumer's utility classes override them.
14
+ */
15
+ @import './layout/widget-layout.css' layer(components);
16
+ @import './primitives/widget-surface.css' layer(components);
17
+ @import './primitives/widget-card.css' layer(components);
18
+ @import './primitives/widget-avatar.css' layer(components);
19
+ @import './state/widget-state-feedback.css' layer(components);
20
+ @import './runtime/widget-runtime.css' layer(components);