@antadesign/anta 0.1.1-dev.8 → 0.2.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/README.md +42 -3
- package/dist/components/Button.js +4 -3
- package/dist/components/Progress.module.css +0 -5
- package/dist/components/Tag.d.ts +55 -0
- package/dist/components/Tag.js +40 -0
- package/dist/components/Text.d.ts +4 -2
- package/dist/components/Text.module.css +0 -6
- package/dist/components/Tooltip.d.ts +4 -2
- package/dist/elements/a-button.css +1 -733
- package/dist/elements/a-icon.css +1 -43
- package/dist/elements/a-icon.shapes.css +1 -373
- package/dist/elements/a-icon.shapes.d.ts +2 -1
- package/dist/elements/a-icon.shapes.js +3 -1
- package/dist/elements/a-progress.css +1 -68
- package/dist/elements/a-tag.css +1 -0
- package/dist/elements/a-text.css +1 -86
- package/dist/elements/a-title.css +1 -64
- package/dist/elements/a-tooltip.css +1 -42
- package/dist/elements/a-tooltip.d.ts +7 -0
- package/dist/elements/a-tooltip.js +96 -19
- package/dist/elements/index.d.ts +2 -4
- package/dist/elements/index.js +1 -6
- package/dist/general_types.d.ts +15 -35
- package/dist/index.d.ts +3 -4
- package/dist/index.js +2 -4
- package/dist/jsx-runtime.d.ts +19 -16
- package/dist/reset.css +1 -205
- package/dist/tokens.css +1 -285
- package/package.json +15 -15
- package/dist/components/Button.module.css +0 -2
- package/dist/components/Sticker.d.ts +0 -31
- package/dist/components/Sticker.js +0 -17
- package/dist/components/StickerAnimated.d.ts +0 -23
- package/dist/components/StickerAnimated.js +0 -28
- package/dist/components/__generated__/stickers/angry-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/angry-animated.js +0 -7
- package/dist/components/__generated__/stickers/angry.d.ts +0 -3
- package/dist/components/__generated__/stickers/angry.js +0 -7
- package/dist/components/__generated__/stickers/ask-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/ask-animated.js +0 -7
- package/dist/components/__generated__/stickers/ask.d.ts +0 -3
- package/dist/components/__generated__/stickers/ask.js +0 -7
- package/dist/components/__generated__/stickers/balance-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/balance-animated.js +0 -7
- package/dist/components/__generated__/stickers/balance.d.ts +0 -3
- package/dist/components/__generated__/stickers/balance.js +0 -7
- package/dist/components/__generated__/stickers/butterfly-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/butterfly-animated.js +0 -7
- package/dist/components/__generated__/stickers/butterfly-snake-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/butterfly-snake-animated.js +0 -7
- package/dist/components/__generated__/stickers/butterfly-snake.d.ts +0 -3
- package/dist/components/__generated__/stickers/butterfly-snake.js +0 -7
- package/dist/components/__generated__/stickers/butterfly.d.ts +0 -3
- package/dist/components/__generated__/stickers/butterfly.js +0 -7
- package/dist/components/__generated__/stickers/catch-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/catch-animated.js +0 -7
- package/dist/components/__generated__/stickers/catch.d.ts +0 -3
- package/dist/components/__generated__/stickers/catch.js +0 -7
- package/dist/components/__generated__/stickers/clap-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/clap-animated.js +0 -7
- package/dist/components/__generated__/stickers/clap.d.ts +0 -3
- package/dist/components/__generated__/stickers/clap.js +0 -7
- package/dist/components/__generated__/stickers/coding-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/coding-animated.js +0 -7
- package/dist/components/__generated__/stickers/coding.d.ts +0 -3
- package/dist/components/__generated__/stickers/coding.js +0 -7
- package/dist/components/__generated__/stickers/cowboy-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/cowboy-animated.js +0 -7
- package/dist/components/__generated__/stickers/cowboy.d.ts +0 -3
- package/dist/components/__generated__/stickers/cowboy.js +0 -7
- package/dist/components/__generated__/stickers/dance-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/dance-animated.js +0 -7
- package/dist/components/__generated__/stickers/dance.d.ts +0 -3
- package/dist/components/__generated__/stickers/dance.js +0 -7
- package/dist/components/__generated__/stickers/detective-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/detective-animated.js +0 -7
- package/dist/components/__generated__/stickers/detective.d.ts +0 -3
- package/dist/components/__generated__/stickers/detective.js +0 -7
- package/dist/components/__generated__/stickers/disapprove-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/disapprove-animated.js +0 -7
- package/dist/components/__generated__/stickers/disapprove.d.ts +0 -3
- package/dist/components/__generated__/stickers/disapprove.js +0 -7
- package/dist/components/__generated__/stickers/distracted-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/distracted-animated.js +0 -7
- package/dist/components/__generated__/stickers/distracted.d.ts +0 -3
- package/dist/components/__generated__/stickers/distracted.js +0 -7
- package/dist/components/__generated__/stickers/dive-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/dive-animated.js +0 -7
- package/dist/components/__generated__/stickers/dive.d.ts +0 -3
- package/dist/components/__generated__/stickers/dive.js +0 -7
- package/dist/components/__generated__/stickers/eat-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/eat-animated.js +0 -7
- package/dist/components/__generated__/stickers/eat.d.ts +0 -3
- package/dist/components/__generated__/stickers/eat.js +0 -7
- package/dist/components/__generated__/stickers/facepalm-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/facepalm-animated.js +0 -7
- package/dist/components/__generated__/stickers/facepalm.d.ts +0 -3
- package/dist/components/__generated__/stickers/facepalm.js +0 -7
- package/dist/components/__generated__/stickers/failed-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/failed-animated.js +0 -7
- package/dist/components/__generated__/stickers/failed.d.ts +0 -3
- package/dist/components/__generated__/stickers/failed.js +0 -7
- package/dist/components/__generated__/stickers/found-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/found-animated.js +0 -7
- package/dist/components/__generated__/stickers/found.d.ts +0 -3
- package/dist/components/__generated__/stickers/found.js +0 -7
- package/dist/components/__generated__/stickers/grow-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/grow-animated.js +0 -7
- package/dist/components/__generated__/stickers/grow.d.ts +0 -3
- package/dist/components/__generated__/stickers/grow.js +0 -7
- package/dist/components/__generated__/stickers/handstand-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/handstand-animated.js +0 -7
- package/dist/components/__generated__/stickers/handstand.d.ts +0 -3
- package/dist/components/__generated__/stickers/handstand.js +0 -7
- package/dist/components/__generated__/stickers/heart-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/heart-animated.js +0 -7
- package/dist/components/__generated__/stickers/heart.d.ts +0 -3
- package/dist/components/__generated__/stickers/heart.js +0 -7
- package/dist/components/__generated__/stickers/hello-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/hello-animated.js +0 -7
- package/dist/components/__generated__/stickers/hello.d.ts +0 -3
- package/dist/components/__generated__/stickers/hello.js +0 -7
- package/dist/components/__generated__/stickers/idea-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/idea-animated.js +0 -7
- package/dist/components/__generated__/stickers/idea.d.ts +0 -3
- package/dist/components/__generated__/stickers/idea.js +0 -7
- package/dist/components/__generated__/stickers/index.d.ts +0 -99
- package/dist/components/__generated__/stickers/index.js +0 -198
- package/dist/components/__generated__/stickers/laugh-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/laugh-animated.js +0 -7
- package/dist/components/__generated__/stickers/laugh.d.ts +0 -3
- package/dist/components/__generated__/stickers/laugh.js +0 -7
- package/dist/components/__generated__/stickers/love-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/love-animated.js +0 -7
- package/dist/components/__generated__/stickers/love.d.ts +0 -3
- package/dist/components/__generated__/stickers/love.js +0 -7
- package/dist/components/__generated__/stickers/nap-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/nap-animated.js +0 -7
- package/dist/components/__generated__/stickers/nap.d.ts +0 -3
- package/dist/components/__generated__/stickers/nap.js +0 -7
- package/dist/components/__generated__/stickers/party-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/party-animated.js +0 -7
- package/dist/components/__generated__/stickers/party.d.ts +0 -3
- package/dist/components/__generated__/stickers/party.js +0 -7
- package/dist/components/__generated__/stickers/passed-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/passed-animated.js +0 -7
- package/dist/components/__generated__/stickers/passed.d.ts +0 -3
- package/dist/components/__generated__/stickers/passed.js +0 -7
- package/dist/components/__generated__/stickers/peekaboo-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/peekaboo-animated.js +0 -7
- package/dist/components/__generated__/stickers/peekaboo.d.ts +0 -3
- package/dist/components/__generated__/stickers/peekaboo.js +0 -7
- package/dist/components/__generated__/stickers/pizza-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/pizza-animated.js +0 -7
- package/dist/components/__generated__/stickers/pizza.d.ts +0 -3
- package/dist/components/__generated__/stickers/pizza.js +0 -7
- package/dist/components/__generated__/stickers/puzzle-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/puzzle-animated.js +0 -7
- package/dist/components/__generated__/stickers/puzzle.d.ts +0 -3
- package/dist/components/__generated__/stickers/puzzle.js +0 -7
- package/dist/components/__generated__/stickers/sad-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/sad-animated.js +0 -7
- package/dist/components/__generated__/stickers/sad.d.ts +0 -3
- package/dist/components/__generated__/stickers/sad.js +0 -7
- package/dist/components/__generated__/stickers/scared-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/scared-animated.js +0 -7
- package/dist/components/__generated__/stickers/scared.d.ts +0 -3
- package/dist/components/__generated__/stickers/scared.js +0 -7
- package/dist/components/__generated__/stickers/scroll-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/scroll-animated.js +0 -7
- package/dist/components/__generated__/stickers/scroll.d.ts +0 -3
- package/dist/components/__generated__/stickers/scroll.js +0 -7
- package/dist/components/__generated__/stickers/search-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/search-animated.js +0 -7
- package/dist/components/__generated__/stickers/search.d.ts +0 -3
- package/dist/components/__generated__/stickers/search.js +0 -7
- package/dist/components/__generated__/stickers/shield-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/shield-animated.js +0 -7
- package/dist/components/__generated__/stickers/shield.d.ts +0 -3
- package/dist/components/__generated__/stickers/shield.js +0 -7
- package/dist/components/__generated__/stickers/shocked-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/shocked-animated.js +0 -7
- package/dist/components/__generated__/stickers/shocked.d.ts +0 -3
- package/dist/components/__generated__/stickers/shocked.js +0 -7
- package/dist/components/__generated__/stickers/sleep-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/sleep-animated.js +0 -7
- package/dist/components/__generated__/stickers/sleep.d.ts +0 -3
- package/dist/components/__generated__/stickers/sleep.js +0 -7
- package/dist/components/__generated__/stickers/stressed-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/stressed-animated.js +0 -7
- package/dist/components/__generated__/stickers/stressed.d.ts +0 -3
- package/dist/components/__generated__/stickers/stressed.js +0 -7
- package/dist/components/__generated__/stickers/suspicious-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/suspicious-animated.js +0 -7
- package/dist/components/__generated__/stickers/suspicious.d.ts +0 -3
- package/dist/components/__generated__/stickers/suspicious.js +0 -7
- package/dist/components/__generated__/stickers/thanks-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/thanks-animated.js +0 -7
- package/dist/components/__generated__/stickers/thanks.d.ts +0 -3
- package/dist/components/__generated__/stickers/thanks.js +0 -7
- package/dist/components/__generated__/stickers/think-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/think-animated.js +0 -7
- package/dist/components/__generated__/stickers/think-of-you-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/think-of-you-animated.js +0 -7
- package/dist/components/__generated__/stickers/think-of-you.d.ts +0 -3
- package/dist/components/__generated__/stickers/think-of-you.js +0 -7
- package/dist/components/__generated__/stickers/think.d.ts +0 -3
- package/dist/components/__generated__/stickers/think.js +0 -7
- package/dist/components/__generated__/stickers/thumbs-up-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/thumbs-up-animated.js +0 -7
- package/dist/components/__generated__/stickers/thumbs-up.d.ts +0 -3
- package/dist/components/__generated__/stickers/thumbs-up.js +0 -7
- package/dist/components/__generated__/stickers/vacation-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/vacation-animated.js +0 -7
- package/dist/components/__generated__/stickers/vacation.d.ts +0 -3
- package/dist/components/__generated__/stickers/vacation.js +0 -7
- package/dist/components/__generated__/stickers/wait-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/wait-animated.js +0 -7
- package/dist/components/__generated__/stickers/wait.d.ts +0 -3
- package/dist/components/__generated__/stickers/wait.js +0 -7
- package/dist/components/__generated__/stickers/wink-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/wink-animated.js +0 -7
- package/dist/components/__generated__/stickers/wink.d.ts +0 -3
- package/dist/components/__generated__/stickers/wink.js +0 -7
- package/dist/components/__generated__/stickers/work-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/work-animated.js +0 -7
- package/dist/components/__generated__/stickers/work.d.ts +0 -3
- package/dist/components/__generated__/stickers/work.js +0 -7
- package/dist/components/__generated__/stickers/zen-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/zen-animated.js +0 -7
- package/dist/components/__generated__/stickers/zen.d.ts +0 -3
- package/dist/components/__generated__/stickers/zen.js +0 -7
- package/dist/elements/a-sticker-animated.css +0 -9
- package/dist/elements/a-sticker-animated.d.ts +0 -39
- package/dist/elements/a-sticker-animated.js +0 -81
- package/dist/elements/a-sticker.css +0 -9
- package/dist/elements/a-sticker.d.ts +0 -19
- package/dist/elements/a-sticker.js +0 -32
- package/dist/generate-stickers.mjs +0 -293
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ This constraint shapes the architecture: the web components carry the core styli
|
|
|
10
10
|
|
|
11
11
|
`@antadesign/anta` is an NPM package, so you can `npm install @antadesign/anta` or do that with `pnpm` / `bun`.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Use the latest version from npm, but **always pin an exact version** — `"@antadesign/anta": "0.2.0"` in your `package.json` — rather than a floating tag like `"latest"` or `"dev"`, which can change between installs.
|
|
14
14
|
|
|
15
15
|
### Usage
|
|
16
16
|
|
|
@@ -36,7 +36,7 @@ Anta exposes four independent imports. Tokens + elements + the JSX layer are the
|
|
|
36
36
|
|
|
37
37
|
The chain matters: the per-element CSS that ships with `/elements` references variables like `var(--text-1)` and `var(--bg-2)`. Those variables are *only defined* by `tokens.css`. Skip the tokens import and the components render with whatever the surrounding cascade provides — usually nothing styled at all.
|
|
38
38
|
|
|
39
|
-
`@antadesign/anta/elements` registers **all** elements — convenient, but it includes every element's code (and deps). To keep your bundle lean, import only the elements you use from their per-element entry points instead: `import '@antadesign/anta/elements/a-tooltip'` registers just `<a-tooltip>` **and loads just its CSS**. Unused elements — and
|
|
39
|
+
`@antadesign/anta/elements` registers **all** elements — convenient, but it includes every element's code (and deps). To keep your bundle lean, import only the elements you use from their per-element entry points instead: `import '@antadesign/anta/elements/a-tooltip'` registers just `<a-tooltip>` **and loads just its CSS**. Unused elements — and any dependencies they pull in — then never enter your bundle. See [Registering elements](#registering-elements).
|
|
40
40
|
|
|
41
41
|
### Cascade layers
|
|
42
42
|
|
|
@@ -79,7 +79,7 @@ import '@antadesign/anta/elements/a-tooltip' // only <a-tooltip> + its CSS
|
|
|
79
79
|
import '@antadesign/anta/elements/a-button' // only <a-button> + its CSS
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
Both styles are side-effect imports (the act of importing registers the element), and both are idempotent and SSR-safe. The granular form keeps unused elements — and
|
|
82
|
+
Both styles are side-effect imports (the act of importing registers the element), and both are idempotent and SSR-safe. The granular form keeps unused elements — and any dependencies they pull in — out of your bundle.
|
|
83
83
|
|
|
84
84
|
The cleanest pattern is a **static, synchronous import at your app's entry file** — outside any component, outside any hook:
|
|
85
85
|
|
|
@@ -125,6 +125,45 @@ import { h, Fragment } from 'preact'
|
|
|
125
125
|
configure(h, Fragment)
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
+
### TypeScript: typing raw `<a-*>` tags in JSX
|
|
129
|
+
|
|
130
|
+
If you only use the JSX wrappers (`<Button>`, `<Progress>`, …) you need no setup — they're typed like any React component. This section is only for writing the raw `<a-*>` tags directly in JSX.
|
|
131
|
+
|
|
132
|
+
**Option A (preferred)** — point your JSX types at anta in `tsconfig.json`:
|
|
133
|
+
|
|
134
|
+
```jsonc
|
|
135
|
+
{ "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "@antadesign/anta" } }
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Every `a-*` tag type-checks, all standard HTML tags keep working, and importing anything from `@antadesign/stickers` adds the sticker tags automatically.
|
|
139
|
+
|
|
140
|
+
**Option B** — if you can't change `jsxImportSource` (a shared tsconfig, Emotion's `@emotion/react` source, an older `@types/react` without the `React.JSX` namespace), merge anta's tag map into your JSX namespace yourself. Anta exports it as a standalone interface, `AntaIntrinsicElements` — and `@antadesign/stickers` exports the matching `StickerIntrinsicElements` — so it's a single `extends` in any `.d.ts` covered by your tsconfig:
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import type { AntaIntrinsicElements } from '@antadesign/anta'
|
|
144
|
+
import type { StickerIntrinsicElements } from '@antadesign/stickers' // only if you use stickers
|
|
145
|
+
|
|
146
|
+
declare global {
|
|
147
|
+
namespace JSX {
|
|
148
|
+
interface IntrinsicElements extends AntaIntrinsicElements, StickerIntrinsicElements {}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
On modern `@types/react` (≥18) with `jsx: "react-jsx"`, the JSX namespace is module-scoped and the global declaration above is silently ignored — target the `react` module instead:
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import type { AntaIntrinsicElements } from '@antadesign/anta'
|
|
157
|
+
|
|
158
|
+
declare module 'react' {
|
|
159
|
+
namespace JSX {
|
|
160
|
+
interface IntrinsicElements extends AntaIntrinsicElements {}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Either way the tags stay fully typed — unknown `a-*` tags and wrong prop types are still errors. New tags arrive automatically when you upgrade anta; there's no per-tag list to maintain.
|
|
166
|
+
|
|
128
167
|
### Raw web components (no JSX)
|
|
129
168
|
|
|
130
169
|
```html
|
|
@@ -38,12 +38,13 @@ const Button = ({
|
|
|
38
38
|
children,
|
|
39
39
|
...rest
|
|
40
40
|
}) => {
|
|
41
|
-
const
|
|
42
|
-
const
|
|
41
|
+
const toneAttr = tone || void 0;
|
|
42
|
+
const isCustomTone = toneAttr != null && !NAMED_TONES.has(toneAttr);
|
|
43
|
+
const computedStyle = isCustomTone ? { ...style, ["--button-tone-source"]: toneAttr } : style;
|
|
43
44
|
const isIconOnly = icon != null && label == null && children == null && iconTrailing == null;
|
|
44
45
|
const sharedAttrs = {
|
|
45
46
|
priority,
|
|
46
|
-
tone,
|
|
47
|
+
tone: toneAttr,
|
|
47
48
|
underline,
|
|
48
49
|
// 'medium' (and unset) is the implicit default — emit no DOM attr.
|
|
49
50
|
size: size && size !== "medium" ? size : void 0,
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { BaseProps } from "../general_types";
|
|
2
|
+
import type { IconShape } from '../elements/a-icon.shapes';
|
|
3
|
+
export interface TagProps extends BaseProps {
|
|
4
|
+
/** A short "key" shown before the value. When paired with `value` it
|
|
5
|
+
* renders bold (weight 600), same color. On its own (no `value`) it's
|
|
6
|
+
* treated as the tag's primary text and keeps the default styling. */
|
|
7
|
+
label?: string;
|
|
8
|
+
/** The tag's primary text — a status, count, version, duration, etc.
|
|
9
|
+
* Rendered in the default color and weight, with no divider from the
|
|
10
|
+
* label; the color + weight contrast does the separating. */
|
|
11
|
+
value?: string;
|
|
12
|
+
/** Semantic tone, or any literal CSS color (`'#ff1493'`, `'rebeccapurple'`)
|
|
13
|
+
* for a one-off custom tone. Named tones map to the `--text-2-{tone}` /
|
|
14
|
+
* `--bg-4-{tone}` palette; a custom color keeps its hue while lightness
|
|
15
|
+
* and chroma are pinned. `'neutral'` (the default) is the gray tag —
|
|
16
|
+
* the same as omitting `tone`.
|
|
17
|
+
* @defaultValue neutral */
|
|
18
|
+
tone?: 'neutral' | 'brand' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
|
|
19
|
+
/** Size variant. `small` = 16px tall, `medium` = 20px, `large` = 24px
|
|
20
|
+
* (matching `Button`). Omit the attribute or pass `'medium'` for the
|
|
21
|
+
* default — both render identically and emit no DOM attribute.
|
|
22
|
+
* @defaultValue medium */
|
|
23
|
+
size?: 'small' | 'medium' | 'large';
|
|
24
|
+
/** Render in normal (mixed) case instead of the default uppercase
|
|
25
|
+
* (keeps Anta's small body-text letter-spacing; uppercase tracks wider). */
|
|
26
|
+
nocaps?: boolean;
|
|
27
|
+
/** Leading icon shape. Sits flush before the label, scaled to the pill. */
|
|
28
|
+
icon?: IconShape;
|
|
29
|
+
/** Trailing icon shape. Renders last, after the value. */
|
|
30
|
+
iconTrailing?: IconShape;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Compact pill / chip for status, labels, and metadata.
|
|
34
|
+
*
|
|
35
|
+
* Renders an `<a-tag>` styled tag (no JS, no shadow DOM) — color and size
|
|
36
|
+
* come entirely from attributes. Content is composed from `icon`, `label`,
|
|
37
|
+
* `value`, and `iconTrailing` (like `<Button>`): `value` is the primary
|
|
38
|
+
* text (default styling) and `label`, when paired with a value, renders as
|
|
39
|
+
* a bold "key" before it (same color, no divider). Tabular figures are
|
|
40
|
+
* always on, so counts / versions / timers don't reflow. For an arbitrary
|
|
41
|
+
* multi-part tag, pass `children` instead — each segment after the first
|
|
42
|
+
* gets a hairline divider (the `label` + `value` pair is the no-divider
|
|
43
|
+
* exception).
|
|
44
|
+
*
|
|
45
|
+
* Requires `@antadesign/anta/elements` to be imported (client-side only)
|
|
46
|
+
* so the CSS ships with the page.
|
|
47
|
+
*
|
|
48
|
+
* @example Basic usage
|
|
49
|
+
* ```tsx
|
|
50
|
+
* <Tag tone="success" label="Running" />
|
|
51
|
+
* <Tag tone="info" icon="hourglass" label="Build" value="2m 14s" />
|
|
52
|
+
* <Tag tone="brand" size="small" nocaps value="v2.1.0" />
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare const Tag: ({ icon, iconTrailing, label, value, tone, size, nocaps, className, style, children, ...rest }: TagProps) => any;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
|
|
2
|
+
const NAMED_TONES = /* @__PURE__ */ new Set(["neutral", "brand", "info", "success", "warning", "critical"]);
|
|
3
|
+
const Tag = ({
|
|
4
|
+
icon,
|
|
5
|
+
iconTrailing,
|
|
6
|
+
label,
|
|
7
|
+
value,
|
|
8
|
+
tone,
|
|
9
|
+
size,
|
|
10
|
+
nocaps,
|
|
11
|
+
className,
|
|
12
|
+
style,
|
|
13
|
+
children,
|
|
14
|
+
...rest
|
|
15
|
+
}) => {
|
|
16
|
+
const isCustomTone = tone != null && !NAMED_TONES.has(tone);
|
|
17
|
+
const computedStyle = isCustomTone ? { ...style, ["--tag-tone-source"]: tone } : style;
|
|
18
|
+
const hasValue = value != null;
|
|
19
|
+
return /* @__PURE__ */ jsxs(
|
|
20
|
+
"a-tag",
|
|
21
|
+
{
|
|
22
|
+
tone,
|
|
23
|
+
size: size && size !== "medium" ? size : void 0,
|
|
24
|
+
nocaps: nocaps ? "" : void 0,
|
|
25
|
+
class: className,
|
|
26
|
+
style: computedStyle,
|
|
27
|
+
...rest,
|
|
28
|
+
children: [
|
|
29
|
+
icon && /* @__PURE__ */ jsx("a-icon", { shape: icon, "aria-hidden": "true" }),
|
|
30
|
+
label != null && (hasValue ? /* @__PURE__ */ jsx("a-tag-label", { children: label }) : /* @__PURE__ */ jsx("a-tag-value", { children: label })),
|
|
31
|
+
hasValue && /* @__PURE__ */ jsx("a-tag-value", { children: value }),
|
|
32
|
+
children,
|
|
33
|
+
iconTrailing && /* @__PURE__ */ jsx("a-icon", { shape: iconTrailing, "aria-hidden": "true" })
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
Tag
|
|
40
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { BaseProps } from "../general_types";
|
|
2
2
|
export interface TextProps extends BaseProps {
|
|
3
|
-
/** Visual priority. Maps to text-1..text-5 (`primary` = text-1
|
|
4
|
-
*
|
|
3
|
+
/** Visual priority. Maps to text-1..text-5 (`primary` = text-1, the
|
|
4
|
+
* strongest). The default is `secondary` (text-2) — body text reads a
|
|
5
|
+
* step softer than the strongest foreground; pass `primary` for emphasis.
|
|
6
|
+
* @defaultValue secondary */
|
|
5
7
|
priority?: 'primary' | 'secondary' | 'tertiary' | 'quaternary' | 'quinary';
|
|
6
8
|
/** Color tint. Applies the matching `--text-{N}-{tone}` palette. */
|
|
7
9
|
tone?: 'brand' | 'success' | 'critical' | 'warning' | 'info';
|
|
@@ -25,8 +25,10 @@ export interface TooltipProps extends BaseProps {
|
|
|
25
25
|
* doesn't affect that element's layout.
|
|
26
26
|
*
|
|
27
27
|
* Shows on hover (after `delay`) and on keyboard focus; dismisses on mouse
|
|
28
|
-
* leave, blur, Escape, or when the anchor scrolls away.
|
|
29
|
-
*
|
|
28
|
+
* leave, blur, Escape, or when the anchor scrolls away. On touch devices it
|
|
29
|
+
* opens on press-and-hold (a tap never surfaces it) and lingers briefly after
|
|
30
|
+
* release. Follows the cursor by default — pass `static` to pin it under the
|
|
31
|
+
* anchor instead.
|
|
30
32
|
*
|
|
31
33
|
* Requires `@antadesign/anta/elements` to be imported (client-side only)
|
|
32
34
|
* to register the underlying custom element.
|