@adea-ai/ui 0.100.2 → 0.101.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.
- package/dist/components/composites/about-dialog/about-dialog.d.ts.map +1 -1
- package/dist/components/composites/about-dialog/about-dialog.js +2 -1
- package/dist/components/composites/about-dialog/about-dialog.js.map +1 -1
- package/dist/components/composites/account-menu/account-menu.d.ts +7 -0
- package/dist/components/composites/account-menu/account-menu.d.ts.map +1 -1
- package/dist/components/composites/account-menu/account-menu.js +116 -89
- package/dist/components/composites/account-menu/account-menu.js.map +1 -1
- package/dist/components/composites/help-center/help-center.d.ts.map +1 -1
- package/dist/components/composites/help-center/help-center.js +26 -21
- package/dist/components/composites/help-center/help-center.js.map +1 -1
- package/dist/components/composites/settings/settings.d.ts.map +1 -1
- package/dist/components/composites/settings/settings.js +43 -36
- package/dist/components/composites/settings/settings.js.map +1 -1
- package/dist/components/composites/stat/stat.d.ts.map +1 -1
- package/dist/components/composites/stat/stat.js +46 -35
- package/dist/components/composites/stat/stat.js.map +1 -1
- package/dist/components/composites/update-dialog/update-dialog.d.ts.map +1 -1
- package/dist/components/composites/update-dialog/update-dialog.js +73 -58
- package/dist/components/composites/update-dialog/update-dialog.js.map +1 -1
- package/dist/components/layout/page/page.d.ts.map +1 -1
- package/dist/components/layout/page/page.js +19 -13
- package/dist/components/layout/page/page.js.map +1 -1
- package/dist/components/theme/appearance-panel.d.ts.map +1 -1
- package/dist/components/theme/appearance-panel.js +37 -18
- package/dist/components/theme/appearance-panel.js.map +1 -1
- package/dist/components/ui/alert-dialog/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/alert-dialog/alert-dialog.js +5 -1
- package/dist/components/ui/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/ui/card/card.d.ts.map +1 -1
- package/dist/components/ui/card/card.js +5 -1
- package/dist/components/ui/card/card.js.map +1 -1
- package/dist/components/ui/chart/chart-options.d.ts +3 -2
- package/dist/components/ui/chart/chart-options.d.ts.map +1 -1
- package/dist/components/ui/chart/chart-options.js +30 -9
- package/dist/components/ui/chart/chart-options.js.map +1 -1
- package/dist/components/ui/chart/chart.d.ts +4 -9
- package/dist/components/ui/chart/chart.d.ts.map +1 -1
- package/dist/components/ui/chart/chart.js +65 -10
- package/dist/components/ui/chart/chart.js.map +1 -1
- package/dist/components/ui/dialog/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog/dialog.js +5 -1
- package/dist/components/ui/dialog/dialog.js.map +1 -1
- package/dist/components/ui/drawer/drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer/drawer.js +5 -1
- package/dist/components/ui/drawer/drawer.js.map +1 -1
- package/dist/components/ui/field/field.d.ts.map +1 -1
- package/dist/components/ui/field/field.js +2 -1
- package/dist/components/ui/field/field.js.map +1 -1
- package/dist/components/ui/item/item.d.ts +1 -1
- package/dist/components/ui/navigation-menu/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu/navigation-menu.js +8 -7
- package/dist/components/ui/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/ui/sheet/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet/sheet.js +5 -1
- package/dist/components/ui/sheet/sheet.js.map +1 -1
- package/dist/components/ui/tabs/tabs.d.ts +13 -0
- package/dist/components/ui/tabs/tabs.d.ts.map +1 -1
- package/dist/components/ui/tabs/tabs.js +15 -1
- package/dist/components/ui/tabs/tabs.js.map +1 -1
- package/dist/components/ui/toast/toast.d.ts.map +1 -1
- package/dist/components/ui/toast/toast.js +6 -2
- package/dist/components/ui/toast/toast.js.map +1 -1
- package/dist/components/ui/typography/index.d.ts +3 -0
- package/dist/components/ui/typography/index.d.ts.map +1 -0
- package/dist/components/ui/typography/index.js +2 -0
- package/dist/components/ui/typography/typography.d.ts +84 -0
- package/dist/components/ui/typography/typography.d.ts.map +1 -0
- package/dist/components/ui/typography/typography.js +179 -0
- package/dist/components/ui/typography/typography.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/r/account-menu.json +1 -0
- package/dist/r/alert-dialog.json +1 -0
- package/dist/r/card.json +1 -0
- package/dist/r/dialog.json +1 -0
- package/dist/r/drawer.json +1 -0
- package/dist/r/field.json +1 -0
- package/dist/r/help-center.json +1 -0
- package/dist/r/page.json +1 -0
- package/dist/r/registry.json +37 -0
- package/dist/r/settings.json +1 -0
- package/dist/r/sheet.json +1 -0
- package/dist/r/src/components/composites/about-dialog/about-dialog.tsx +3 -2
- package/dist/r/src/components/composites/account-menu/account-menu.tsx +105 -66
- package/dist/r/src/components/composites/help-center/help-center.tsx +2 -1
- package/dist/r/src/components/composites/settings/settings.tsx +4 -1
- package/dist/r/src/components/composites/stat/stat.tsx +7 -2
- package/dist/r/src/components/composites/update-dialog/update-dialog.tsx +36 -24
- package/dist/r/src/components/layout/page/page.tsx +3 -2
- package/dist/r/src/components/theme/appearance-panel.tsx +13 -4
- package/dist/r/src/components/ui/alert-dialog/alert-dialog.tsx +2 -1
- package/dist/r/src/components/ui/card/card.tsx +2 -1
- package/dist/r/src/components/ui/chart/chart-options.ts +35 -7
- package/dist/r/src/components/ui/chart/chart.tsx +65 -12
- package/dist/r/src/components/ui/dialog/dialog.tsx +2 -1
- package/dist/r/src/components/ui/drawer/drawer.tsx +2 -1
- package/dist/r/src/components/ui/field/field.tsx +2 -3
- package/dist/r/src/components/ui/navigation-menu/navigation-menu.tsx +27 -20
- package/dist/r/src/components/ui/sheet/sheet.tsx +5 -1
- package/dist/r/src/components/ui/tabs/tabs.tsx +18 -1
- package/dist/r/src/components/ui/toast/toast.tsx +7 -6
- package/dist/r/src/components/ui/typography/index.ts +9 -0
- package/dist/r/src/components/ui/typography/typography.tsx +205 -0
- package/dist/r/stat.json +1 -0
- package/dist/r/theming.json +1 -0
- package/dist/r/typography.json +24 -0
- package/dist/r/update-dialog.json +1 -0
- package/package.json +1 -1
- package/registry.json +37 -0
- package/src/components/composites/about-dialog/about-dialog.tsx +3 -2
- package/src/components/composites/account-menu/account-menu.tsx +105 -66
- package/src/components/composites/help-center/help-center.tsx +2 -1
- package/src/components/composites/settings/settings.tsx +4 -1
- package/src/components/composites/stat/stat.tsx +7 -2
- package/src/components/composites/update-dialog/update-dialog.tsx +36 -24
- package/src/components/layout/page/page.tsx +3 -2
- package/src/components/theme/appearance-panel.tsx +13 -4
- package/src/components/ui/alert-dialog/alert-dialog.tsx +2 -1
- package/src/components/ui/card/card.tsx +2 -1
- package/src/components/ui/chart/chart-options.ts +35 -7
- package/src/components/ui/chart/chart.tsx +65 -12
- package/src/components/ui/dialog/dialog.tsx +2 -1
- package/src/components/ui/drawer/drawer.tsx +2 -1
- package/src/components/ui/field/field.tsx +2 -3
- package/src/components/ui/navigation-menu/navigation-menu.tsx +27 -20
- package/src/components/ui/sheet/sheet.tsx +5 -1
- package/src/components/ui/tabs/tabs.tsx +18 -1
- package/src/components/ui/toast/toast.tsx +7 -6
- package/src/components/ui/typography/index.ts +9 -0
- package/src/components/ui/typography/typography.tsx +205 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { Polymorphic, type PolymorphicProps } from '@kobalte/core/polymorphic'
|
|
2
|
+
import { type ComponentProps, splitProps, type ValidComponent } from 'solid-js'
|
|
3
|
+
import { cva, type VariantProps } from '#lib/variants'
|
|
4
|
+
import { cn } from '#lib/utils'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Typography.
|
|
8
|
+
*
|
|
9
|
+
* The type ladder in `theme.css` has eight rungs, each with its own leading. These
|
|
10
|
+
* two components are where a rung is paired with its weight and tracking, so a call
|
|
11
|
+
* site names a *role* — a page title, a section heading, a caption — and never
|
|
12
|
+
* re-decides `text-xl font-semibold tracking-tight` for itself. Twenty call sites
|
|
13
|
+
* that each choose a size and a weight drift; twenty that name a role cannot.
|
|
14
|
+
*
|
|
15
|
+
* **Size is visual; the element is the document outline.** They are separate
|
|
16
|
+
* decisions and the API keeps them separate. Each size has a conventional default
|
|
17
|
+
* element (`display`, `title` and `page` render an `h1`, `section` an `h2`, `card`
|
|
18
|
+
* an `h3`, `subsection` an `h4`) so the common case needs no prop, but the default
|
|
19
|
+
* is a convenience, not a coupling: a card-sized title that is the first heading
|
|
20
|
+
* in a settings section is an `h2`, so it says `as="h2"`. Never pick a `size` to get
|
|
21
|
+
* a heading level, and never pick an element to get a size.
|
|
22
|
+
*
|
|
23
|
+
* Headings are 600, and weights stop at 600 — on a dark surface a bold word blooms.
|
|
24
|
+
* Leading comes from the rung; `leading="none"` is for a title whose surrounding
|
|
25
|
+
* stack already sets the rhythm (a card or dialog header), and is the only other
|
|
26
|
+
* option.
|
|
27
|
+
*/
|
|
28
|
+
export const headingVariants = cva('font-semibold', {
|
|
29
|
+
variants: {
|
|
30
|
+
size: {
|
|
31
|
+
/** 30px. An app-level headline — a first-run or empty-app screen. Once per app. */
|
|
32
|
+
display: 'text-3xl tracking-tight',
|
|
33
|
+
/** 24px. A landing title or a headline figure larger than a stat's. */
|
|
34
|
+
title: 'text-2xl tracking-tight',
|
|
35
|
+
/** 20px. The title of a page (`PageHeaderTitle`). */
|
|
36
|
+
page: 'text-xl tracking-tight',
|
|
37
|
+
/** 18px. A section heading inside a page (`PageSection`). */
|
|
38
|
+
section: 'text-lg tracking-tight',
|
|
39
|
+
/** 16px. A card, dialog, drawer or settings-section title. */
|
|
40
|
+
card: 'text-base tracking-tight',
|
|
41
|
+
/** 14px. A heading inside a compact surface: a sheet, a chart, a column. */
|
|
42
|
+
subsection: 'text-sm',
|
|
43
|
+
},
|
|
44
|
+
leading: {
|
|
45
|
+
/** The rung's own line-height from `theme.css`. */
|
|
46
|
+
rung: '',
|
|
47
|
+
/** Line-height 1, for a title whose container's gap sets the rhythm. */
|
|
48
|
+
none: 'leading-none',
|
|
49
|
+
},
|
|
50
|
+
/** Tabular figures, so a row of numbers can be compared without digits shifting. */
|
|
51
|
+
numeric: {
|
|
52
|
+
true: 'tabular-nums',
|
|
53
|
+
},
|
|
54
|
+
tone: {
|
|
55
|
+
/** Inherit the surrounding colour — right on every surface by construction. */
|
|
56
|
+
inherit: '',
|
|
57
|
+
foreground: 'text-foreground',
|
|
58
|
+
muted: 'text-muted-foreground',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
defaultVariants: {
|
|
62
|
+
size: 'section',
|
|
63
|
+
leading: 'rung',
|
|
64
|
+
tone: 'inherit',
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The conventional element for each heading size. Exported so a test (and a
|
|
70
|
+
* reader) can see the whole mapping in one place; pass `as` to depart from it.
|
|
71
|
+
*/
|
|
72
|
+
export const headingElement = {
|
|
73
|
+
display: 'h1',
|
|
74
|
+
title: 'h1',
|
|
75
|
+
page: 'h1',
|
|
76
|
+
section: 'h2',
|
|
77
|
+
card: 'h3',
|
|
78
|
+
subsection: 'h4',
|
|
79
|
+
} as const
|
|
80
|
+
|
|
81
|
+
type HeadingVariantProps = VariantProps<typeof headingVariants>
|
|
82
|
+
type HeadingSize = keyof typeof headingElement
|
|
83
|
+
|
|
84
|
+
export type HeadingProps<T extends ValidComponent = 'h2'> = PolymorphicProps<
|
|
85
|
+
T,
|
|
86
|
+
HeadingVariantProps & {
|
|
87
|
+
class?: string
|
|
88
|
+
}
|
|
89
|
+
>
|
|
90
|
+
|
|
91
|
+
export function Heading<T extends ValidComponent = 'h2'>(props: HeadingProps<T>) {
|
|
92
|
+
const [local, rest] = splitProps(props as HeadingProps & { as?: ValidComponent }, [
|
|
93
|
+
'as',
|
|
94
|
+
'size',
|
|
95
|
+
'leading',
|
|
96
|
+
'numeric',
|
|
97
|
+
'tone',
|
|
98
|
+
'class',
|
|
99
|
+
])
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<Polymorphic
|
|
103
|
+
as={local.as ?? headingElement[(local.size ?? 'section') as HeadingSize]}
|
|
104
|
+
data-slot="heading"
|
|
105
|
+
class={cn(
|
|
106
|
+
headingVariants({
|
|
107
|
+
size: local.size,
|
|
108
|
+
leading: local.leading,
|
|
109
|
+
numeric: local.numeric,
|
|
110
|
+
tone: local.tone,
|
|
111
|
+
}),
|
|
112
|
+
local.class
|
|
113
|
+
)}
|
|
114
|
+
{...(rest as ComponentProps<'h2'>)}
|
|
115
|
+
/>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Text.
|
|
121
|
+
*
|
|
122
|
+
* Everything that is not a heading. `text-sm` is the interface default, not 16px,
|
|
123
|
+
* and it carries three weights by role: 400 for body copy, 500 for a label or
|
|
124
|
+
* control text, 600 for emphasis. Below it, `caption` (12px) is metadata and
|
|
125
|
+
* `micro` (11px, 500) is the floor — keyboard keys and the status bar. `code` is
|
|
126
|
+
* the mono face at 12px, for anything a user compares character by character.
|
|
127
|
+
*
|
|
128
|
+
* `tone` is a separate axis from `variant` because "secondary" is a colour
|
|
129
|
+
* decision, not a size: a muted caption and a muted body line are both common.
|
|
130
|
+
* The default inherits, so text on a filled surface picks up that surface's
|
|
131
|
+
* foreground without the caller restating it.
|
|
132
|
+
*
|
|
133
|
+
* Defaults: `body` renders a `p`, `code` a `code`, every other variant a `span`.
|
|
134
|
+
*/
|
|
135
|
+
export const textVariants = cva('', {
|
|
136
|
+
variants: {
|
|
137
|
+
variant: {
|
|
138
|
+
/** 14px / 400. Body copy and descriptions. */
|
|
139
|
+
body: 'text-sm',
|
|
140
|
+
/** 14px / 500. Labels, control text, list-row titles. */
|
|
141
|
+
label: 'text-sm font-medium',
|
|
142
|
+
/** 14px / 600. Emphasis inside body copy. */
|
|
143
|
+
strong: 'text-sm font-semibold',
|
|
144
|
+
/** 12px / 400. Metadata, secondary rows, units. */
|
|
145
|
+
caption: 'text-xs',
|
|
146
|
+
/** 11px / 500. The floor: keyboard keys, the status bar. */
|
|
147
|
+
micro: 'text-2xs font-medium',
|
|
148
|
+
/** 12px mono. Ids, paths, hashes, inline code. */
|
|
149
|
+
code: 'font-mono text-xs',
|
|
150
|
+
},
|
|
151
|
+
tone: {
|
|
152
|
+
inherit: '',
|
|
153
|
+
foreground: 'text-foreground',
|
|
154
|
+
muted: 'text-muted-foreground',
|
|
155
|
+
},
|
|
156
|
+
numeric: {
|
|
157
|
+
true: 'tabular-nums',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
defaultVariants: {
|
|
161
|
+
variant: 'body',
|
|
162
|
+
tone: 'inherit',
|
|
163
|
+
},
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
export const textElement = {
|
|
167
|
+
body: 'p',
|
|
168
|
+
label: 'span',
|
|
169
|
+
strong: 'span',
|
|
170
|
+
caption: 'span',
|
|
171
|
+
micro: 'span',
|
|
172
|
+
code: 'code',
|
|
173
|
+
} as const
|
|
174
|
+
|
|
175
|
+
type TextVariantProps = VariantProps<typeof textVariants>
|
|
176
|
+
type TextVariant = keyof typeof textElement
|
|
177
|
+
|
|
178
|
+
export type TextProps<T extends ValidComponent = 'p'> = PolymorphicProps<
|
|
179
|
+
T,
|
|
180
|
+
TextVariantProps & {
|
|
181
|
+
class?: string
|
|
182
|
+
}
|
|
183
|
+
>
|
|
184
|
+
|
|
185
|
+
export function Text<T extends ValidComponent = 'p'>(props: TextProps<T>) {
|
|
186
|
+
const [local, rest] = splitProps(props as TextProps & { as?: ValidComponent }, [
|
|
187
|
+
'as',
|
|
188
|
+
'variant',
|
|
189
|
+
'tone',
|
|
190
|
+
'numeric',
|
|
191
|
+
'class',
|
|
192
|
+
])
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<Polymorphic
|
|
196
|
+
as={local.as ?? textElement[(local.variant ?? 'body') as TextVariant]}
|
|
197
|
+
data-slot="text"
|
|
198
|
+
class={cn(
|
|
199
|
+
textVariants({ variant: local.variant, tone: local.tone, numeric: local.numeric }),
|
|
200
|
+
local.class
|
|
201
|
+
)}
|
|
202
|
+
{...(rest as ComponentProps<'p'>)}
|
|
203
|
+
/>
|
|
204
|
+
)
|
|
205
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -74,6 +74,7 @@ export * from './components/ui/toast'
|
|
|
74
74
|
export * from './components/ui/toggle'
|
|
75
75
|
export * from './components/ui/toggle-group'
|
|
76
76
|
export * from './components/ui/tooltip'
|
|
77
|
+
export * from './components/ui/typography'
|
|
77
78
|
|
|
78
79
|
/* --- Motion -------------------------------------------------------------- */
|
|
79
80
|
export * from './components/motion'
|