@astl/tokens 0.1.2 → 0.1.4
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/CHANGELOG.md +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/select.d.ts +9 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/select.js +30 -0
- package/dist/select.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/select.ts +33 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @astl/tokens
|
|
2
2
|
|
|
3
|
+
## 0.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8d3dc51: Selects keep their arrow off the border: the editor's selects (in the card and in a help box on the page) and the lists of the match fallback draw a chevron of their own, inset from the inline end with room for the text, mirrored in right-to-left text; under forced colours the platform's arrow stays. `nativeSelectCss(selector)` from `@astl/tokens` gives a host's own native selects the same chevron.
|
|
8
|
+
|
|
9
|
+
## 0.1.3
|
|
10
|
+
|
|
11
|
+
No changes in this release.
|
|
12
|
+
|
|
3
13
|
## 0.1.2
|
|
4
14
|
|
|
5
15
|
No changes in this release.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { builtInStyleTemplates } from './built-in-templates.js';
|
|
2
2
|
export { tokensCss } from './css.js';
|
|
3
|
+
export { nativeSelectCss } from './select.js';
|
|
3
4
|
export type { CheckStyleTemplateOptions, StyleTemplateProblem, StyleTemplateShape, TemplateCatalog, TemplateScope, TemplateTheme, } from './templates.js';
|
|
4
5
|
export { checkStyleTemplate, contrastRatio, isSafeStyleValue, PART_PROPERTIES, TEMPLATE_NAME, templateColors, } from './templates.js';
|
|
5
6
|
export type { ColorScheme, ColorToken, PaletteColor, PaletteSlot, PaletteToken, ScaleToken, Theme, ThemeScaleToken, ThemeSetting, TokenName, Tokens, } from './tokens.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,YAAY,EACV,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,KAAK,EACL,eAAe,EACf,YAAY,EACZ,SAAS,EACT,MAAM,GACP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EACV,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,KAAK,EACL,eAAe,EACf,YAAY,EACZ,SAAS,EACT,MAAM,GACP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { builtInStyleTemplates } from './built-in-templates.js';
|
|
2
2
|
export { tokensCss } from './css.js';
|
|
3
|
+
export { nativeSelectCss } from './select.js';
|
|
3
4
|
export { checkStyleTemplate, contrastRatio, isSafeStyleValue, PART_PROPERTIES, TEMPLATE_NAME, templateColors, } from './templates.js';
|
|
4
5
|
export { PALETTE, TEXT_PAIRS, THEMES, tokens, UI_PAIRS } from './tokens.js';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAS9C,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,cAAc,GACf,MAAM,gBAAgB,CAAC;AAcxB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/select.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native selects with a chevron of their own, inset from the inline end: the platform's arrow keeps a few pixels from
|
|
3
|
+
* the border whatever the padding (Chromium), so `appearance: none` drops it and two gradients draw a chevron in the
|
|
4
|
+
* text colour, with end padding that keeps the text clear of it. Mirrored in right-to-left text. Forced colours drop
|
|
5
|
+
* gradients, so the platform's own arrow comes back there. `selector` is one selector, not a list (the right-to-left
|
|
6
|
+
* rule appends `:dir(rtl)` to it). Goes after the rules that give the select its padding and background.
|
|
7
|
+
*/
|
|
8
|
+
export declare function nativeSelectCss(selector: string): string;
|
|
9
|
+
//# sourceMappingURL=select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../src/select.ts"],"names":[],"mappings":"AAiBA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQxD"}
|
package/dist/select.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A native select's chevron. A module of its own: the player's first load takes `tokensCss`, and a bundler keeps all
|
|
3
|
+
* of a module's exports in one chunk, so this goes only where a select needs it (the kit, a component's chunk).
|
|
4
|
+
*/
|
|
5
|
+
/** Half the chevron's width (its height), its distance from the inner edge, and the room between it and the text. */
|
|
6
|
+
const ARM = '0.3125em';
|
|
7
|
+
const INSET = '0.75rem';
|
|
8
|
+
const ROOM = '0.375rem';
|
|
9
|
+
/**
|
|
10
|
+
* One arm in the chevron's box, which is twice as wide as high: a stroke 0.1em thick, its edges softened by half a
|
|
11
|
+
* pixel, along the diagonal from a top corner to the middle of the bottom edge (a third of the way along a 45-degree
|
|
12
|
+
* gradient line in such a box). Both arms in one box, so no seam parts them; its bottom edge cuts their tip flat.
|
|
13
|
+
*/
|
|
14
|
+
const arm = (angle) => `linear-gradient(${angle},transparent calc(100% / 3 - .05em - .5px),currentColor calc(100% / 3 - .05em) ` +
|
|
15
|
+
'calc(100% / 3 + .05em),transparent calc(100% / 3 + .05em + .5px))';
|
|
16
|
+
/**
|
|
17
|
+
* Native selects with a chevron of their own, inset from the inline end: the platform's arrow keeps a few pixels from
|
|
18
|
+
* the border whatever the padding (Chromium), so `appearance: none` drops it and two gradients draw a chevron in the
|
|
19
|
+
* text colour, with end padding that keeps the text clear of it. Mirrored in right-to-left text. Forced colours drop
|
|
20
|
+
* gradients, so the platform's own arrow comes back there. `selector` is one selector, not a list (the right-to-left
|
|
21
|
+
* rule appends `:dir(rtl)` to it). Goes after the rules that give the select its padding and background.
|
|
22
|
+
*/
|
|
23
|
+
export function nativeSelectCss(selector) {
|
|
24
|
+
return (`${selector}{appearance:none;padding-inline-end:calc(${INSET} + 2 * ${ARM} + ${ROOM});` +
|
|
25
|
+
`background-image:${arm('45deg')},${arm('-45deg')};background-size:calc(2 * ${ARM}) ${ARM};` +
|
|
26
|
+
`background-repeat:no-repeat;background-position:right ${INSET} center}` +
|
|
27
|
+
`${selector}:dir(rtl){background-position:left ${INSET} center}` +
|
|
28
|
+
`@media (forced-colors:active){${selector}{appearance:auto;background-image:none}}`);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../src/select.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qHAAqH;AACrH,MAAM,GAAG,GAAG,UAAU,CAAC;AACvB,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,IAAI,GAAG,UAAU,CAAC;AACxB;;;;GAIG;AACH,MAAM,GAAG,GAAG,CAAC,KAAa,EAAU,EAAE,CACpC,mBAAmB,KAAK,iFAAiF;IACzG,mEAAmE,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,CACL,GAAG,QAAQ,4CAA4C,KAAK,UAAU,GAAG,MAAM,IAAI,IAAI;QACvF,oBAAoB,GAAG,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,6BAA6B,GAAG,KAAK,GAAG,GAAG;QAC5F,yDAAyD,KAAK,UAAU;QACxE,GAAG,QAAQ,sCAAsC,KAAK,UAAU;QAChE,iCAAiC,QAAQ,0CAA0C,CACpF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/select.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A native select's chevron. A module of its own: the player's first load takes `tokensCss`, and a bundler keeps all
|
|
3
|
+
* of a module's exports in one chunk, so this goes only where a select needs it (the kit, a component's chunk).
|
|
4
|
+
*/
|
|
5
|
+
/** Half the chevron's width (its height), its distance from the inner edge, and the room between it and the text. */
|
|
6
|
+
const ARM = '0.3125em';
|
|
7
|
+
const INSET = '0.75rem';
|
|
8
|
+
const ROOM = '0.375rem';
|
|
9
|
+
/**
|
|
10
|
+
* One arm in the chevron's box, which is twice as wide as high: a stroke 0.1em thick, its edges softened by half a
|
|
11
|
+
* pixel, along the diagonal from a top corner to the middle of the bottom edge (a third of the way along a 45-degree
|
|
12
|
+
* gradient line in such a box). Both arms in one box, so no seam parts them; its bottom edge cuts their tip flat.
|
|
13
|
+
*/
|
|
14
|
+
const arm = (angle: string): string =>
|
|
15
|
+
`linear-gradient(${angle},transparent calc(100% / 3 - .05em - .5px),currentColor calc(100% / 3 - .05em) ` +
|
|
16
|
+
'calc(100% / 3 + .05em),transparent calc(100% / 3 + .05em + .5px))';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Native selects with a chevron of their own, inset from the inline end: the platform's arrow keeps a few pixels from
|
|
20
|
+
* the border whatever the padding (Chromium), so `appearance: none` drops it and two gradients draw a chevron in the
|
|
21
|
+
* text colour, with end padding that keeps the text clear of it. Mirrored in right-to-left text. Forced colours drop
|
|
22
|
+
* gradients, so the platform's own arrow comes back there. `selector` is one selector, not a list (the right-to-left
|
|
23
|
+
* rule appends `:dir(rtl)` to it). Goes after the rules that give the select its padding and background.
|
|
24
|
+
*/
|
|
25
|
+
export function nativeSelectCss(selector: string): string {
|
|
26
|
+
return (
|
|
27
|
+
`${selector}{appearance:none;padding-inline-end:calc(${INSET} + 2 * ${ARM} + ${ROOM});` +
|
|
28
|
+
`background-image:${arm('45deg')},${arm('-45deg')};background-size:calc(2 * ${ARM}) ${ARM};` +
|
|
29
|
+
`background-repeat:no-repeat;background-position:right ${INSET} center}` +
|
|
30
|
+
`${selector}:dir(rtl){background-position:left ${INSET} center}` +
|
|
31
|
+
`@media (forced-colors:active){${selector}{appearance:auto;background-image:none}}`
|
|
32
|
+
);
|
|
33
|
+
}
|