@lunar-js/lunar 0.0.3 → 0.1.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.
- package/CHANGELOG.md +8 -0
- package/dist/components/primitives/Input/input.css.js +1 -1
- package/dist/components/primitives/Input/input.css.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/themes/styles/utilities.d.ts +47 -15
- package/dist/themes/styles/utilities.d.ts.map +1 -1
- package/dist/themes/styles/utilities.js +57 -15
- package/dist/themes/styles/utilities.js.map +1 -1
- package/package.json +1 -1
- package/src/components/primitives/Input/input.css.ts +1 -1
- package/src/index.ts +6 -1
- package/src/themes/styles/utilities.ts +59 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @lunar-js/lunar
|
|
2
2
|
|
|
3
|
+
## 0.1.0 (2026-01-07)
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- add visually hidden style utility -
|
|
8
|
+
[`b072927`](https://github.com/lunar-js/lunar/commit/b0729275b5ddf45aff1b151c16e1ea287c189689) Thanks astronaut
|
|
9
|
+
[@prests](https://github.com/prests)!
|
|
10
|
+
|
|
3
11
|
## 0.0.3 (2025-11-30)
|
|
4
12
|
|
|
5
13
|
### Changed
|
|
@@ -26,7 +26,7 @@ const input = style([
|
|
|
26
26
|
color: themeContract.colors.text.primary,
|
|
27
27
|
selectors: {
|
|
28
28
|
"&[aria-invalid=\"true\"]": { borderColor: themeContract.colors.border.error },
|
|
29
|
-
...withCustomOutline(themeContract.colors.shadow.destructive, "&[aria-invalid=\"true\"]")
|
|
29
|
+
...withCustomOutline(themeContract.colors.shadow.destructive, "&[aria-invalid=\"true\"]:focus-visible")
|
|
30
30
|
},
|
|
31
31
|
"::file-selector-button": {
|
|
32
32
|
display: "inline-flex",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.css.js","names":[],"sources":["../../../../src/components/primitives/Input/input.css.ts"],"sourcesContent":["import { style } from '@vanilla-extract/css';\n\nimport { themeContract } from '../../../themes/tokens/tokens.css.js';\nimport { withBreakpoint, withCustomOutline, withSafeTransition } from '../../../themes/styles/utilities.js';\nimport { BREAKPOINT__MD } from '../../../constants/theming.js';\nimport { COLORS__PURE } from '../../../themes/tokens/primitives/colors.js';\n\nconst input = style([\n withBreakpoint(BREAKPOINT__MD, {\n fontSize: themeContract.typography.body.sm.medium.fontSize,\n }),\n withCustomOutline(themeContract.colors.shadow.focus),\n withSafeTransition({\n transition: 'color 150ms ease-in-out, box-shadow 150ms ease-in-out',\n }),\n {\n width: '100%',\n minWidth: 0,\n boxSizing: 'border-box',\n borderRadius: themeContract.borderRadius.md,\n border: `${themeContract.borderWidth[1]} solid ${themeContract.colors.input.border.default}`,\n backgroundColor: COLORS__PURE.transparent,\n paddingLeft: themeContract.spacing[3],\n paddingRight: themeContract.spacing[3],\n paddingTop: themeContract.spacing[1],\n paddingBottom: themeContract.spacing[1],\n fontSize: themeContract.typography.body.md.medium.fontSize,\n lineHeight: themeContract.typography.body.md.medium.lineHeight,\n boxShadow: themeContract.boxShadow.sm,\n color: themeContract.colors.text.primary,\n selectors: {\n '&[aria-invalid=\"true\"]': {\n borderColor: themeContract.colors.border.error,\n },\n ...withCustomOutline(themeContract.colors.shadow.destructive, '&[aria-invalid=\"true\"]'),\n },\n\n '::file-selector-button': {\n display: 'inline-flex',\n border: 0,\n backgroundColor: COLORS__PURE.transparent,\n fontSize: themeContract.typography.body.md.medium.fontSize,\n fontWeight: themeContract.typography.body.md.medium.fontWeight,\n color: themeContract.colors.text.primary,\n },\n\n '::placeholder': {\n color: themeContract.colors.input.text.placeholder,\n },\n\n '::selection': {\n backgroundColor: themeContract.colors.action.bg.primary.default,\n color: themeContract.colors.action.color.primary,\n },\n\n ':disabled': {\n pointerEvents: 'none',\n cursor: 'not-allowed',\n opacity: '0.5',\n },\n },\n]);\n\nexport { input };\n"],"mappings":";;;;;;;AAOA,MAAM,QAAQ,MAAM;CAClB,eAAe,gBAAgB,EAC7B,UAAU,cAAc,WAAW,KAAK,GAAG,OAAO,UACnD,CAAC;CACF,kBAAkB,cAAc,OAAO,OAAO,MAAM;CACpD,mBAAmB,EACjB,YAAY,yDACb,CAAC;CACF;EACE,OAAO;EACP,UAAU;EACV,WAAW;EACX,cAAc,cAAc,aAAa;EACzC,QAAQ,GAAG,cAAc,YAAY,GAAG,SAAS,cAAc,OAAO,MAAM,OAAO;EACnF,iBAAiB,aAAa;EAC9B,aAAa,cAAc,QAAQ;EACnC,cAAc,cAAc,QAAQ;EACpC,YAAY,cAAc,QAAQ;EAClC,eAAe,cAAc,QAAQ;EACrC,UAAU,cAAc,WAAW,KAAK,GAAG,OAAO;EAClD,YAAY,cAAc,WAAW,KAAK,GAAG,OAAO;EACpD,WAAW,cAAc,UAAU;EACnC,OAAO,cAAc,OAAO,KAAK;EACjC,WAAW;GACT,4BAA0B,EACxB,aAAa,cAAc,OAAO,OAAO,OAC1C;GACD,GAAG,kBAAkB,cAAc,OAAO,OAAO,aAAa,
|
|
1
|
+
{"version":3,"file":"input.css.js","names":[],"sources":["../../../../src/components/primitives/Input/input.css.ts"],"sourcesContent":["import { style } from '@vanilla-extract/css';\n\nimport { themeContract } from '../../../themes/tokens/tokens.css.js';\nimport { withBreakpoint, withCustomOutline, withSafeTransition } from '../../../themes/styles/utilities.js';\nimport { BREAKPOINT__MD } from '../../../constants/theming.js';\nimport { COLORS__PURE } from '../../../themes/tokens/primitives/colors.js';\n\nconst input = style([\n withBreakpoint(BREAKPOINT__MD, {\n fontSize: themeContract.typography.body.sm.medium.fontSize,\n }),\n withCustomOutline(themeContract.colors.shadow.focus),\n withSafeTransition({\n transition: 'color 150ms ease-in-out, box-shadow 150ms ease-in-out',\n }),\n {\n width: '100%',\n minWidth: 0,\n boxSizing: 'border-box',\n borderRadius: themeContract.borderRadius.md,\n border: `${themeContract.borderWidth[1]} solid ${themeContract.colors.input.border.default}`,\n backgroundColor: COLORS__PURE.transparent,\n paddingLeft: themeContract.spacing[3],\n paddingRight: themeContract.spacing[3],\n paddingTop: themeContract.spacing[1],\n paddingBottom: themeContract.spacing[1],\n fontSize: themeContract.typography.body.md.medium.fontSize,\n lineHeight: themeContract.typography.body.md.medium.lineHeight,\n boxShadow: themeContract.boxShadow.sm,\n color: themeContract.colors.text.primary,\n selectors: {\n '&[aria-invalid=\"true\"]': {\n borderColor: themeContract.colors.border.error,\n },\n ...withCustomOutline(themeContract.colors.shadow.destructive, '&[aria-invalid=\"true\"]:focus-visible'),\n },\n\n '::file-selector-button': {\n display: 'inline-flex',\n border: 0,\n backgroundColor: COLORS__PURE.transparent,\n fontSize: themeContract.typography.body.md.medium.fontSize,\n fontWeight: themeContract.typography.body.md.medium.fontWeight,\n color: themeContract.colors.text.primary,\n },\n\n '::placeholder': {\n color: themeContract.colors.input.text.placeholder,\n },\n\n '::selection': {\n backgroundColor: themeContract.colors.action.bg.primary.default,\n color: themeContract.colors.action.color.primary,\n },\n\n ':disabled': {\n pointerEvents: 'none',\n cursor: 'not-allowed',\n opacity: '0.5',\n },\n },\n]);\n\nexport { input };\n"],"mappings":";;;;;;;AAOA,MAAM,QAAQ,MAAM;CAClB,eAAe,gBAAgB,EAC7B,UAAU,cAAc,WAAW,KAAK,GAAG,OAAO,UACnD,CAAC;CACF,kBAAkB,cAAc,OAAO,OAAO,MAAM;CACpD,mBAAmB,EACjB,YAAY,yDACb,CAAC;CACF;EACE,OAAO;EACP,UAAU;EACV,WAAW;EACX,cAAc,cAAc,aAAa;EACzC,QAAQ,GAAG,cAAc,YAAY,GAAG,SAAS,cAAc,OAAO,MAAM,OAAO;EACnF,iBAAiB,aAAa;EAC9B,aAAa,cAAc,QAAQ;EACnC,cAAc,cAAc,QAAQ;EACpC,YAAY,cAAc,QAAQ;EAClC,eAAe,cAAc,QAAQ;EACrC,UAAU,cAAc,WAAW,KAAK,GAAG,OAAO;EAClD,YAAY,cAAc,WAAW,KAAK,GAAG,OAAO;EACpD,WAAW,cAAc,UAAU;EACnC,OAAO,cAAc,OAAO,KAAK;EACjC,WAAW;GACT,4BAA0B,EACxB,aAAa,cAAc,OAAO,OAAO,OAC1C;GACD,GAAG,kBAAkB,cAAc,OAAO,OAAO,aAAa,yCAAuC;GACtG;EAED,0BAA0B;GACxB,SAAS;GACT,QAAQ;GACR,iBAAiB,aAAa;GAC9B,UAAU,cAAc,WAAW,KAAK,GAAG,OAAO;GAClD,YAAY,cAAc,WAAW,KAAK,GAAG,OAAO;GACpD,OAAO,cAAc,OAAO,KAAK;GAClC;EAED,iBAAiB,EACf,OAAO,cAAc,OAAO,MAAM,KAAK,aACxC;EAED,eAAe;GACb,iBAAiB,cAAc,OAAO,OAAO,GAAG,QAAQ;GACxD,OAAO,cAAc,OAAO,OAAO,MAAM;GAC1C;EAED,aAAa;GACX,eAAe;GACf,QAAQ;GACR,SAAS;GACV;EACF;CACF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,10 +11,10 @@ import { Text, TextProps } from "./components/primitives/Typography/Text.js";
|
|
|
11
11
|
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./components/composite/Card/Card.js";
|
|
12
12
|
import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogTrigger } from "./components/composite/Dialog/Dialog.js";
|
|
13
13
|
import { useDialog } from "./hooks/dialog.js";
|
|
14
|
-
import { withBreakpoint, withCustomOutline, withSafeTransition } from "./themes/styles/utilities.js";
|
|
14
|
+
import { withBreakpoint, withCustomOutline, withSafeTransition, withVisuallyHidden } from "./themes/styles/utilities.js";
|
|
15
15
|
import { COLORS__BLUE, COLORS__GOLD, COLORS__GREEN, COLORS__PEARL, COLORS__PURE, COLORS__RED, COLORS__STONE, COLORS__YELLOW } from "./themes/tokens/primitives/colors.js";
|
|
16
16
|
import { SPACING } from "./themes/tokens/primitives/spacing.js";
|
|
17
17
|
import { BORDER_RADIUS, BORDER_WIDTH } from "./themes/tokens/primitives/borders.js";
|
|
18
18
|
import { BOX_SHADOW } from "./themes/tokens/primitives/shadows.js";
|
|
19
19
|
import { FONT_FAMILY, FONT_SIZE, FONT_WEIGHT, LETTER_SPACING, LINE_HEIGHT__RELAXED, LINE_HEIGHT__TIGHT } from "./themes/tokens/primitives/typography.js";
|
|
20
|
-
export { BORDER_RADIUS, BORDER_WIDTH, BOX_SHADOW, BREAKPOINT__LG, BREAKPOINT__MD, BREAKPOINT__SM, BUTTON_SIZE__LARGE, BUTTON_SIZE__MEDIUM, BUTTON_SIZE__SMALL, BUTTON_VARIANT__DESTRUCTIVE, BUTTON_VARIANT__GHOST, BUTTON_VARIANT__LINK, BUTTON_VARIANT__OUTLINE, BUTTON_VARIANT__PRIMARY, BUTTON_VARIANT__SECONDARY, Button, type ButtonProps, COLORS__BLUE, COLORS__GOLD, COLORS__GREEN, COLORS__PEARL, COLORS__PURE, COLORS__RED, COLORS__STONE, COLORS__YELLOW, COLOR_SCHEME__DARK, COLOR_SCHEME__LIGHT, COLOR_SCHEME__SYSTEM, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ColorScheme, Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogTrigger, FONT_FAMILY, FONT_SIZE, FONT_WEIGHT, Input, LETTER_SPACING, LINE_HEIGHT__RELAXED, LINE_HEIGHT__TIGHT, Label, SPACING, TEXT_COLOR__ACCENT, TEXT_COLOR__BRAND, TEXT_COLOR__DANGER, TEXT_COLOR__DISABLED, TEXT_COLOR__INFO, TEXT_COLOR__INTERACTIVE, TEXT_COLOR__INVERSE, TEXT_COLOR__MUTED, TEXT_COLOR__PRIMARY, TEXT_COLOR__SECONDARY, TEXT_COLOR__SUCCESS, TEXT_COLOR__WARNING, TEXT_SIZE__LG, TEXT_SIZE__MD, TEXT_SIZE__SM, TEXT_SIZE__XL, TEXT_VARIANT__BODY, TEXT_VARIANT__CAPTION, TEXT_VARIANT__DISPLAY, TEXT_VARIANT__HEADING, TEXT_VARIANT__LABEL, TEXT_VARIANT__SUBHEADING, TEXT_WEIGHT__BOLD, TEXT_WEIGHT__LIGHT, TEXT_WEIGHT__MEDIUM, Text, type TextProps, ThemeProvider, useDialog, useTheme, withBreakpoint, withCustomOutline, withSafeTransition };
|
|
20
|
+
export { BORDER_RADIUS, BORDER_WIDTH, BOX_SHADOW, BREAKPOINT__LG, BREAKPOINT__MD, BREAKPOINT__SM, BUTTON_SIZE__LARGE, BUTTON_SIZE__MEDIUM, BUTTON_SIZE__SMALL, BUTTON_VARIANT__DESTRUCTIVE, BUTTON_VARIANT__GHOST, BUTTON_VARIANT__LINK, BUTTON_VARIANT__OUTLINE, BUTTON_VARIANT__PRIMARY, BUTTON_VARIANT__SECONDARY, Button, type ButtonProps, COLORS__BLUE, COLORS__GOLD, COLORS__GREEN, COLORS__PEARL, COLORS__PURE, COLORS__RED, COLORS__STONE, COLORS__YELLOW, COLOR_SCHEME__DARK, COLOR_SCHEME__LIGHT, COLOR_SCHEME__SYSTEM, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ColorScheme, Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogTrigger, FONT_FAMILY, FONT_SIZE, FONT_WEIGHT, Input, LETTER_SPACING, LINE_HEIGHT__RELAXED, LINE_HEIGHT__TIGHT, Label, SPACING, TEXT_COLOR__ACCENT, TEXT_COLOR__BRAND, TEXT_COLOR__DANGER, TEXT_COLOR__DISABLED, TEXT_COLOR__INFO, TEXT_COLOR__INTERACTIVE, TEXT_COLOR__INVERSE, TEXT_COLOR__MUTED, TEXT_COLOR__PRIMARY, TEXT_COLOR__SECONDARY, TEXT_COLOR__SUCCESS, TEXT_COLOR__WARNING, TEXT_SIZE__LG, TEXT_SIZE__MD, TEXT_SIZE__SM, TEXT_SIZE__XL, TEXT_VARIANT__BODY, TEXT_VARIANT__CAPTION, TEXT_VARIANT__DISPLAY, TEXT_VARIANT__HEADING, TEXT_VARIANT__LABEL, TEXT_VARIANT__SUBHEADING, TEXT_WEIGHT__BOLD, TEXT_WEIGHT__LIGHT, TEXT_WEIGHT__MEDIUM, Text, type TextProps, ThemeProvider, useDialog, useTheme, withBreakpoint, withCustomOutline, withSafeTransition, withVisuallyHidden };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import ThemeProvider_default from "./themes/ThemeProvider/ThemeProvider.js";
|
|
|
3
3
|
import { useTheme } from "./hooks/theme.js";
|
|
4
4
|
import { SPACING } from "./themes/tokens/primitives/spacing.js";
|
|
5
5
|
import { COLORS__BLUE, COLORS__GOLD, COLORS__GREEN, COLORS__PEARL, COLORS__PURE, COLORS__RED, COLORS__STONE, COLORS__YELLOW } from "./themes/tokens/primitives/colors.js";
|
|
6
|
-
import { withBreakpoint, withCustomOutline, withSafeTransition } from "./themes/styles/utilities.js";
|
|
6
|
+
import { withBreakpoint, withCustomOutline, withSafeTransition, withVisuallyHidden } from "./themes/styles/utilities.js";
|
|
7
7
|
import { BUTTON_SIZE__LARGE, BUTTON_SIZE__MEDIUM, BUTTON_SIZE__SMALL, BUTTON_VARIANT__DESTRUCTIVE, BUTTON_VARIANT__GHOST, BUTTON_VARIANT__LINK, BUTTON_VARIANT__OUTLINE, BUTTON_VARIANT__PRIMARY, BUTTON_VARIANT__SECONDARY } from "./components/primitives/Button/button.css.js";
|
|
8
8
|
import Button_default from "./components/primitives/Button/Button.js";
|
|
9
9
|
import Input_default from "./components/primitives/Input/Input.js";
|
|
@@ -17,4 +17,4 @@ import { BORDER_RADIUS, BORDER_WIDTH } from "./themes/tokens/primitives/borders.
|
|
|
17
17
|
import { BOX_SHADOW } from "./themes/tokens/primitives/shadows.js";
|
|
18
18
|
import { FONT_FAMILY, FONT_SIZE, FONT_WEIGHT, LETTER_SPACING, LINE_HEIGHT__RELAXED, LINE_HEIGHT__TIGHT } from "./themes/tokens/primitives/typography.js";
|
|
19
19
|
|
|
20
|
-
export { BORDER_RADIUS, BORDER_WIDTH, BOX_SHADOW, BREAKPOINT__LG, BREAKPOINT__MD, BREAKPOINT__SM, BUTTON_SIZE__LARGE, BUTTON_SIZE__MEDIUM, BUTTON_SIZE__SMALL, BUTTON_VARIANT__DESTRUCTIVE, BUTTON_VARIANT__GHOST, BUTTON_VARIANT__LINK, BUTTON_VARIANT__OUTLINE, BUTTON_VARIANT__PRIMARY, BUTTON_VARIANT__SECONDARY, Button_default as Button, COLORS__BLUE, COLORS__GOLD, COLORS__GREEN, COLORS__PEARL, COLORS__PURE, COLORS__RED, COLORS__STONE, COLORS__YELLOW, COLOR_SCHEME__DARK, COLOR_SCHEME__LIGHT, COLOR_SCHEME__SYSTEM, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogTrigger, FONT_FAMILY, FONT_SIZE, FONT_WEIGHT, Input_default as Input, LETTER_SPACING, LINE_HEIGHT__RELAXED, LINE_HEIGHT__TIGHT, Label_default as Label, SPACING, TEXT_COLOR__ACCENT, TEXT_COLOR__BRAND, TEXT_COLOR__DANGER, TEXT_COLOR__DISABLED, TEXT_COLOR__INFO, TEXT_COLOR__INTERACTIVE, TEXT_COLOR__INVERSE, TEXT_COLOR__MUTED, TEXT_COLOR__PRIMARY, TEXT_COLOR__SECONDARY, TEXT_COLOR__SUCCESS, TEXT_COLOR__WARNING, TEXT_SIZE__LG, TEXT_SIZE__MD, TEXT_SIZE__SM, TEXT_SIZE__XL, TEXT_VARIANT__BODY, TEXT_VARIANT__CAPTION, TEXT_VARIANT__DISPLAY, TEXT_VARIANT__HEADING, TEXT_VARIANT__LABEL, TEXT_VARIANT__SUBHEADING, TEXT_WEIGHT__BOLD, TEXT_WEIGHT__LIGHT, TEXT_WEIGHT__MEDIUM, Text_default as Text, ThemeProvider_default as ThemeProvider, useDialog, useTheme, withBreakpoint, withCustomOutline, withSafeTransition };
|
|
20
|
+
export { BORDER_RADIUS, BORDER_WIDTH, BOX_SHADOW, BREAKPOINT__LG, BREAKPOINT__MD, BREAKPOINT__SM, BUTTON_SIZE__LARGE, BUTTON_SIZE__MEDIUM, BUTTON_SIZE__SMALL, BUTTON_VARIANT__DESTRUCTIVE, BUTTON_VARIANT__GHOST, BUTTON_VARIANT__LINK, BUTTON_VARIANT__OUTLINE, BUTTON_VARIANT__PRIMARY, BUTTON_VARIANT__SECONDARY, Button_default as Button, COLORS__BLUE, COLORS__GOLD, COLORS__GREEN, COLORS__PEARL, COLORS__PURE, COLORS__RED, COLORS__STONE, COLORS__YELLOW, COLOR_SCHEME__DARK, COLOR_SCHEME__LIGHT, COLOR_SCHEME__SYSTEM, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogTrigger, FONT_FAMILY, FONT_SIZE, FONT_WEIGHT, Input_default as Input, LETTER_SPACING, LINE_HEIGHT__RELAXED, LINE_HEIGHT__TIGHT, Label_default as Label, SPACING, TEXT_COLOR__ACCENT, TEXT_COLOR__BRAND, TEXT_COLOR__DANGER, TEXT_COLOR__DISABLED, TEXT_COLOR__INFO, TEXT_COLOR__INTERACTIVE, TEXT_COLOR__INVERSE, TEXT_COLOR__MUTED, TEXT_COLOR__PRIMARY, TEXT_COLOR__SECONDARY, TEXT_COLOR__SUCCESS, TEXT_COLOR__WARNING, TEXT_SIZE__LG, TEXT_SIZE__MD, TEXT_SIZE__SM, TEXT_SIZE__XL, TEXT_VARIANT__BODY, TEXT_VARIANT__CAPTION, TEXT_VARIANT__DISPLAY, TEXT_VARIANT__HEADING, TEXT_VARIANT__LABEL, TEXT_VARIANT__SUBHEADING, TEXT_WEIGHT__BOLD, TEXT_WEIGHT__LIGHT, TEXT_WEIGHT__MEDIUM, Text_default as Text, ThemeProvider_default as ThemeProvider, useDialog, useTheme, withBreakpoint, withCustomOutline, withSafeTransition, withVisuallyHidden };
|
|
@@ -30,14 +30,10 @@ import { CSSProperties, StyleRule } from "@vanilla-extract/css";
|
|
|
30
30
|
declare const withSafeTransition: (styles: StyleRule) => StyleRule;
|
|
31
31
|
/**
|
|
32
32
|
* Helper function to create a custom focus outline style object.
|
|
33
|
-
* Returns a style object with focus-visible outline that follows the design system's outline pattern.
|
|
34
|
-
* Supports an optional selector parameter for targeting specific pseudo-selectors or child elements.
|
|
35
|
-
*
|
|
36
|
-
* This function returns a style object that must be used with vanilla-extract's `style()` function or `recipe()` function.
|
|
37
33
|
*
|
|
38
34
|
* @param outlineColor - The color for the focus outline (e.g., '#0066cc', 'rgb(255, 0, 0)', CSS custom properties)
|
|
39
|
-
* @param selector - Optional selector
|
|
40
|
-
* @returns A style object with custom focus outline styling that uses
|
|
35
|
+
* @param selector - Optional CSS selector for the outline state (e.g., ':focus-visible', '&:hover', '& > button:focus-visible', defaults to ':focus-visible')
|
|
36
|
+
* @returns A style object with custom focus outline styling that uses the provided selector
|
|
41
37
|
*
|
|
42
38
|
* @example
|
|
43
39
|
* import { style } from '@vanilla-extract/css';
|
|
@@ -53,10 +49,11 @@ declare const withSafeTransition: (styles: StyleRule) => StyleRule;
|
|
|
53
49
|
* ]);
|
|
54
50
|
*
|
|
55
51
|
* // Example with custom selector
|
|
56
|
-
* const
|
|
57
|
-
* withCustomOutline('#
|
|
52
|
+
* const hoverOutlineButton = style([
|
|
53
|
+
* withCustomOutline('#00cc66', ':hover'),
|
|
58
54
|
* {
|
|
59
|
-
* padding: '
|
|
55
|
+
* padding: '8px 16px',
|
|
56
|
+
* background: 'white'
|
|
60
57
|
* }
|
|
61
58
|
* ]);
|
|
62
59
|
*
|
|
@@ -73,13 +70,9 @@ declare const withSafeTransition: (styles: StyleRule) => StyleRule;
|
|
|
73
70
|
* }
|
|
74
71
|
* });
|
|
75
72
|
*/
|
|
76
|
-
declare const withCustomOutline: (outlineColor: string, selector?: string) => Record
|
|
73
|
+
declare const withCustomOutline: (outlineColor: string, selector?: string) => Record<string, CSSProperties>;
|
|
77
74
|
/**
|
|
78
75
|
* Helper function to create a responsive style object with breakpoint media queries.
|
|
79
|
-
* Returns a style object that applies the provided styles only when the viewport width
|
|
80
|
-
* meets or exceeds the specified breakpoint value.
|
|
81
|
-
*
|
|
82
|
-
* This function returns a style object that must be used with vanilla-extract's `style()` function or `recipe()` function.
|
|
83
76
|
*
|
|
84
77
|
* @param breakpoint - The minimum viewport width for the media query (e.g., '768px', '1024px', '48rem')
|
|
85
78
|
* @param styles - CSS properties object to apply at the breakpoint (e.g., { fontSize: '1.5rem', padding: '24px' })
|
|
@@ -120,6 +113,45 @@ declare const withCustomOutline: (outlineColor: string, selector?: string) => Re
|
|
|
120
113
|
* });
|
|
121
114
|
*/
|
|
122
115
|
declare const withBreakpoint: (breakpoint: string, styles: CSSProperties) => StyleRule;
|
|
116
|
+
/**
|
|
117
|
+
* Helper function to create a visually hidden style object for screen reader accessibility.
|
|
118
|
+
* Returns a style object that hides content visually while keeping it accessible to screen readers.
|
|
119
|
+
* This is useful for providing descriptive text, skip links, or other content that should only
|
|
120
|
+
* be available to assistive technologies.
|
|
121
|
+
*
|
|
122
|
+
* @returns A style object that visually hides content while maintaining screen reader accessibility
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* import { style } from '@vanilla-extract/css';
|
|
126
|
+
* import { recipe } from '@vanilla-extract/recipes';
|
|
127
|
+
* import { withVisuallyHidden } from './utilities.css.ts';
|
|
128
|
+
*
|
|
129
|
+
* const skipLink = style([
|
|
130
|
+
* withVisuallyHidden(),
|
|
131
|
+
* {
|
|
132
|
+
* // Additional styles can be added here
|
|
133
|
+
* zIndex: 1000
|
|
134
|
+
* }
|
|
135
|
+
* ]);
|
|
136
|
+
*
|
|
137
|
+
* const srOnly = style([
|
|
138
|
+
* withVisuallyHidden()
|
|
139
|
+
* ]);
|
|
140
|
+
*
|
|
141
|
+
* const buttonWithHiddenText = recipe({
|
|
142
|
+
* base: [
|
|
143
|
+
* withVisuallyHidden(),
|
|
144
|
+
* {
|
|
145
|
+
* padding: '8px 12px',
|
|
146
|
+
* background: 'blue'
|
|
147
|
+
* }
|
|
148
|
+
* ],
|
|
149
|
+
* variants: {
|
|
150
|
+
* // variant styles
|
|
151
|
+
* }
|
|
152
|
+
* });
|
|
153
|
+
*/
|
|
154
|
+
declare const withVisuallyHidden: () => StyleRule;
|
|
123
155
|
//#endregion
|
|
124
|
-
export { withBreakpoint, withCustomOutline, withSafeTransition };
|
|
156
|
+
export { withBreakpoint, withCustomOutline, withSafeTransition, withVisuallyHidden };
|
|
125
157
|
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","names":[],"sources":["../../../src/themes/styles/utilities.ts"],"sourcesContent":[],"mappings":";;;;;;AAA0E;;;;;AAiCxE;;;;;
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","names":[],"sources":["../../../src/themes/styles/utilities.ts"],"sourcesContent":[],"mappings":";;;;;;AAA0E;;;;;AAiCxE;;;;;AA4CmF;;;;;AAqDnF;;;;;;;;cArGI,6BAA8B,cAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgD1C,gEAAyE,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiDxF,6CAA8C,kBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4C9D,0BAAyB"}
|
|
@@ -29,14 +29,10 @@ import { COLORS__PURE } from "../tokens/primitives/colors.js";
|
|
|
29
29
|
const withSafeTransition = (styles) => ({ "@media": { "(prefers-reduced-motion: no-preference)": styles } });
|
|
30
30
|
/**
|
|
31
31
|
* Helper function to create a custom focus outline style object.
|
|
32
|
-
* Returns a style object with focus-visible outline that follows the design system's outline pattern.
|
|
33
|
-
* Supports an optional selector parameter for targeting specific pseudo-selectors or child elements.
|
|
34
|
-
*
|
|
35
|
-
* This function returns a style object that must be used with vanilla-extract's `style()` function or `recipe()` function.
|
|
36
32
|
*
|
|
37
33
|
* @param outlineColor - The color for the focus outline (e.g., '#0066cc', 'rgb(255, 0, 0)', CSS custom properties)
|
|
38
|
-
* @param selector - Optional selector
|
|
39
|
-
* @returns A style object with custom focus outline styling that uses
|
|
34
|
+
* @param selector - Optional CSS selector for the outline state (e.g., ':focus-visible', '&:hover', '& > button:focus-visible', defaults to ':focus-visible')
|
|
35
|
+
* @returns A style object with custom focus outline styling that uses the provided selector
|
|
40
36
|
*
|
|
41
37
|
* @example
|
|
42
38
|
* import { style } from '@vanilla-extract/css';
|
|
@@ -52,10 +48,11 @@ const withSafeTransition = (styles) => ({ "@media": { "(prefers-reduced-motion:
|
|
|
52
48
|
* ]);
|
|
53
49
|
*
|
|
54
50
|
* // Example with custom selector
|
|
55
|
-
* const
|
|
56
|
-
* withCustomOutline('#
|
|
51
|
+
* const hoverOutlineButton = style([
|
|
52
|
+
* withCustomOutline('#00cc66', ':hover'),
|
|
57
53
|
* {
|
|
58
|
-
* padding: '
|
|
54
|
+
* padding: '8px 16px',
|
|
55
|
+
* background: 'white'
|
|
59
56
|
* }
|
|
60
57
|
* ]);
|
|
61
58
|
*
|
|
@@ -72,17 +69,13 @@ const withSafeTransition = (styles) => ({ "@media": { "(prefers-reduced-motion:
|
|
|
72
69
|
* }
|
|
73
70
|
* });
|
|
74
71
|
*/
|
|
75
|
-
const withCustomOutline = (outlineColor, selector = "") => ({ [
|
|
72
|
+
const withCustomOutline = (outlineColor, selector = ":focus-visible") => ({ [selector]: {
|
|
76
73
|
boxShadow: `0px 0px 0px 0px, ${COLORS__PURE.transparent} 0px 0px 0px 0px, ${COLORS__PURE.transparent} 0px 0px 0px 0px, ${outlineColor} 0px 0px 0px 3px, ${outlineColor} 0px 1px 2px 0px`,
|
|
77
74
|
outline: "2px solid transparent",
|
|
78
75
|
outlineOffset: "2px"
|
|
79
76
|
} });
|
|
80
77
|
/**
|
|
81
78
|
* Helper function to create a responsive style object with breakpoint media queries.
|
|
82
|
-
* Returns a style object that applies the provided styles only when the viewport width
|
|
83
|
-
* meets or exceeds the specified breakpoint value.
|
|
84
|
-
*
|
|
85
|
-
* This function returns a style object that must be used with vanilla-extract's `style()` function or `recipe()` function.
|
|
86
79
|
*
|
|
87
80
|
* @param breakpoint - The minimum viewport width for the media query (e.g., '768px', '1024px', '48rem')
|
|
88
81
|
* @param styles - CSS properties object to apply at the breakpoint (e.g., { fontSize: '1.5rem', padding: '24px' })
|
|
@@ -123,7 +116,56 @@ const withCustomOutline = (outlineColor, selector = "") => ({ [`${selector}:focu
|
|
|
123
116
|
* });
|
|
124
117
|
*/
|
|
125
118
|
const withBreakpoint = (breakpoint, styles) => ({ "@media": { [`(min-width: ${breakpoint})`]: styles } });
|
|
119
|
+
/**
|
|
120
|
+
* Helper function to create a visually hidden style object for screen reader accessibility.
|
|
121
|
+
* Returns a style object that hides content visually while keeping it accessible to screen readers.
|
|
122
|
+
* This is useful for providing descriptive text, skip links, or other content that should only
|
|
123
|
+
* be available to assistive technologies.
|
|
124
|
+
*
|
|
125
|
+
* @returns A style object that visually hides content while maintaining screen reader accessibility
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* import { style } from '@vanilla-extract/css';
|
|
129
|
+
* import { recipe } from '@vanilla-extract/recipes';
|
|
130
|
+
* import { withVisuallyHidden } from './utilities.css.ts';
|
|
131
|
+
*
|
|
132
|
+
* const skipLink = style([
|
|
133
|
+
* withVisuallyHidden(),
|
|
134
|
+
* {
|
|
135
|
+
* // Additional styles can be added here
|
|
136
|
+
* zIndex: 1000
|
|
137
|
+
* }
|
|
138
|
+
* ]);
|
|
139
|
+
*
|
|
140
|
+
* const srOnly = style([
|
|
141
|
+
* withVisuallyHidden()
|
|
142
|
+
* ]);
|
|
143
|
+
*
|
|
144
|
+
* const buttonWithHiddenText = recipe({
|
|
145
|
+
* base: [
|
|
146
|
+
* withVisuallyHidden(),
|
|
147
|
+
* {
|
|
148
|
+
* padding: '8px 12px',
|
|
149
|
+
* background: 'blue'
|
|
150
|
+
* }
|
|
151
|
+
* ],
|
|
152
|
+
* variants: {
|
|
153
|
+
* // variant styles
|
|
154
|
+
* }
|
|
155
|
+
* });
|
|
156
|
+
*/
|
|
157
|
+
const withVisuallyHidden = () => ({
|
|
158
|
+
position: "absolute",
|
|
159
|
+
width: "1px",
|
|
160
|
+
height: "1px",
|
|
161
|
+
padding: "0",
|
|
162
|
+
margin: "-1px",
|
|
163
|
+
overflow: "hidden",
|
|
164
|
+
clip: "rect(0, 0, 0, 0)",
|
|
165
|
+
whiteSpace: "nowrap",
|
|
166
|
+
borderWidth: "0"
|
|
167
|
+
});
|
|
126
168
|
|
|
127
169
|
//#endregion
|
|
128
|
-
export { withBreakpoint, withCustomOutline, withSafeTransition };
|
|
170
|
+
export { withBreakpoint, withCustomOutline, withSafeTransition, withVisuallyHidden };
|
|
129
171
|
//# sourceMappingURL=utilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.js","names":[],"sources":["../../../src/themes/styles/utilities.ts"],"sourcesContent":["import { type CSSProperties, type StyleRule } from '@vanilla-extract/css';\n\nimport { COLORS__PURE } from '../tokens/primitives/colors.js';\n\n/**\n * Helper function to create a motion-safe style object with custom CSS properties.\n * Returns a style object that wraps the provided styles in a `prefers-reduced-motion: no-preference` media query,\n * ensuring animations only run when users haven't requested reduced motion.\n *\n * This function returns a style object that must be used with vanilla-extract's `style()` function or `recipe()` function.\n *\n * @param styles - CSS properties object (e.g., { transition: 'opacity 0.3s ease', transform: 'scale(1.1)' })\n * @returns A style object that applies the CSS properties only when motion is preferred\n *\n * @example\n * import { style } from '@vanilla-extract/css';\n * import { withSafeTransition } from './utilities.css.ts';\n *\n * const fadeTransition = style([\n * withSafeTransition({\n * transition: 'transform 0.2s ease-out, opacity 0.2s ease-out',\n * transform: 'translateY(0)'\n * }),\n * {\n * // Additional styles can be added here\n * padding: '16px'\n * }\n * ]);\n */\nconst withSafeTransition = (styles: StyleRule): StyleRule => ({\n '@media': {\n '(prefers-reduced-motion: no-preference)': styles,\n },\n});\n\n/**\n * Helper function to create a custom focus outline style object.\n
|
|
1
|
+
{"version":3,"file":"utilities.js","names":[],"sources":["../../../src/themes/styles/utilities.ts"],"sourcesContent":["import { type CSSProperties, type StyleRule } from '@vanilla-extract/css';\n\nimport { COLORS__PURE } from '../tokens/primitives/colors.js';\n\n/**\n * Helper function to create a motion-safe style object with custom CSS properties.\n * Returns a style object that wraps the provided styles in a `prefers-reduced-motion: no-preference` media query,\n * ensuring animations only run when users haven't requested reduced motion.\n *\n * This function returns a style object that must be used with vanilla-extract's `style()` function or `recipe()` function.\n *\n * @param styles - CSS properties object (e.g., { transition: 'opacity 0.3s ease', transform: 'scale(1.1)' })\n * @returns A style object that applies the CSS properties only when motion is preferred\n *\n * @example\n * import { style } from '@vanilla-extract/css';\n * import { withSafeTransition } from './utilities.css.ts';\n *\n * const fadeTransition = style([\n * withSafeTransition({\n * transition: 'transform 0.2s ease-out, opacity 0.2s ease-out',\n * transform: 'translateY(0)'\n * }),\n * {\n * // Additional styles can be added here\n * padding: '16px'\n * }\n * ]);\n */\nconst withSafeTransition = (styles: StyleRule): StyleRule => ({\n '@media': {\n '(prefers-reduced-motion: no-preference)': styles,\n },\n});\n\n/**\n * Helper function to create a custom focus outline style object.\n *\n * @param outlineColor - The color for the focus outline (e.g., '#0066cc', 'rgb(255, 0, 0)', CSS custom properties)\n * @param selector - Optional CSS selector for the outline state (e.g., ':focus-visible', '&:hover', '& > button:focus-visible', defaults to ':focus-visible')\n * @returns A style object with custom focus outline styling that uses the provided selector\n *\n * @example\n * import { style } from '@vanilla-extract/css';\n * import { recipe } from '@vanilla-extract/recipes';\n * import { withCustomOutline } from './utilities.css.ts';\n *\n * const redOutlineButton = style([\n * withCustomOutline('#ff0000'),\n * {\n * padding: '8px 16px',\n * background: 'white'\n * }\n * ]);\n *\n * // Example with custom selector\n * const hoverOutlineButton = style([\n * withCustomOutline('#00cc66', ':hover'),\n * {\n * padding: '8px 16px',\n * background: 'white'\n * }\n * ]);\n *\n * const buttonVariants = recipe({\n * base: [\n * withCustomOutline(themeContract.colors.shadow.interactive),\n * {\n * // other base styles\n * padding: '12px 24px'\n * }\n * ],\n * variants: {\n * // variant styles\n * }\n * });\n */\nconst withCustomOutline = (outlineColor: string, selector = ':focus-visible'): Record<string, CSSProperties> => ({\n [selector]: {\n boxShadow: `0px 0px 0px 0px, ${COLORS__PURE.transparent} 0px 0px 0px 0px, ${COLORS__PURE.transparent} 0px 0px 0px 0px, ${outlineColor} 0px 0px 0px 3px, ${outlineColor} 0px 1px 2px 0px`,\n outline: '2px solid transparent',\n outlineOffset: '2px',\n },\n});\n\n/**\n * Helper function to create a responsive style object with breakpoint media queries.\n *\n * @param breakpoint - The minimum viewport width for the media query (e.g., '768px', '1024px', '48rem')\n * @param styles - CSS properties object to apply at the breakpoint (e.g., { fontSize: '1.5rem', padding: '24px' })\n * @returns A style object that applies the CSS properties only when the viewport width meets the breakpoint\n *\n * @example\n * import { style } from '@vanilla-extract/css';\n * import { recipe } from '@vanilla-extract/recipes';\n * import { withBreakpoint } from './utilities.css.ts';\n *\n * const responsiveText = style([\n * withBreakpoint('768px', {\n * fontSize: '1.5rem',\n * lineHeight: '1.4'\n * }),\n * {\n * // Base styles\n * fontSize: '1rem',\n * lineHeight: '1.6'\n * }\n * ]);\n *\n * const cardVariants = recipe({\n * base: [\n * withBreakpoint('1024px', {\n * padding: '32px',\n * maxWidth: '800px'\n * }),\n * {\n * // base styles\n * padding: '16px',\n * maxWidth: '100%'\n * }\n * ],\n * variants: {\n * // variant styles\n * }\n * });\n */\nconst withBreakpoint = (breakpoint: string, styles: CSSProperties): StyleRule => ({\n '@media': {\n [`(min-width: ${breakpoint})`]: styles,\n },\n});\n\n/**\n * Helper function to create a visually hidden style object for screen reader accessibility.\n * Returns a style object that hides content visually while keeping it accessible to screen readers.\n * This is useful for providing descriptive text, skip links, or other content that should only\n * be available to assistive technologies.\n *\n * @returns A style object that visually hides content while maintaining screen reader accessibility\n *\n * @example\n * import { style } from '@vanilla-extract/css';\n * import { recipe } from '@vanilla-extract/recipes';\n * import { withVisuallyHidden } from './utilities.css.ts';\n *\n * const skipLink = style([\n * withVisuallyHidden(),\n * {\n * // Additional styles can be added here\n * zIndex: 1000\n * }\n * ]);\n *\n * const srOnly = style([\n * withVisuallyHidden()\n * ]);\n *\n * const buttonWithHiddenText = recipe({\n * base: [\n * withVisuallyHidden(),\n * {\n * padding: '8px 12px',\n * background: 'blue'\n * }\n * ],\n * variants: {\n * // variant styles\n * }\n * });\n */\nconst withVisuallyHidden = (): StyleRule => ({\n position: 'absolute',\n width: '1px',\n height: '1px',\n padding: '0',\n margin: '-1px',\n overflow: 'hidden',\n clip: 'rect(0, 0, 0, 0)',\n whiteSpace: 'nowrap',\n borderWidth: '0',\n});\n\nexport { withSafeTransition, withCustomOutline, withBreakpoint, withVisuallyHidden };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,sBAAsB,YAAkC,EAC5D,UAAU,EACR,2CAA2C,QAC5C,EACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CD,MAAM,qBAAqB,cAAsB,WAAW,sBAAqD,GAC9G,WAAW;CACV,WAAW,oBAAoB,aAAa,YAAY,oBAAoB,aAAa,YAAY,oBAAoB,aAAa,oBAAoB,aAAa;CACvK,SAAS;CACT,eAAe;CAChB,EACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CD,MAAM,kBAAkB,YAAoB,YAAsC,EAChF,UAAU,GACP,eAAe,WAAW,KAAK,QACjC,EACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCD,MAAM,4BAAuC;CAC3C,UAAU;CACV,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,UAAU;CACV,MAAM;CACN,YAAY;CACZ,aAAa;CACd"}
|
package/package.json
CHANGED
|
@@ -32,7 +32,7 @@ const input = style([
|
|
|
32
32
|
'&[aria-invalid="true"]': {
|
|
33
33
|
borderColor: themeContract.colors.border.error,
|
|
34
34
|
},
|
|
35
|
-
...withCustomOutline(themeContract.colors.shadow.destructive, '&[aria-invalid="true"]'),
|
|
35
|
+
...withCustomOutline(themeContract.colors.shadow.destructive, '&[aria-invalid="true"]:focus-visible'),
|
|
36
36
|
},
|
|
37
37
|
|
|
38
38
|
'::file-selector-button': {
|
package/src/index.ts
CHANGED
|
@@ -83,7 +83,12 @@ export { useDialog } from './hooks/dialog.js';
|
|
|
83
83
|
/**
|
|
84
84
|
* Styling Utility Exports
|
|
85
85
|
*/
|
|
86
|
-
export {
|
|
86
|
+
export {
|
|
87
|
+
withCustomOutline,
|
|
88
|
+
withSafeTransition,
|
|
89
|
+
withBreakpoint,
|
|
90
|
+
withVisuallyHidden,
|
|
91
|
+
} from './themes/styles/utilities.js';
|
|
87
92
|
|
|
88
93
|
export { BREAKPOINT__SM, BREAKPOINT__MD, BREAKPOINT__LG } from './constants/theming.js';
|
|
89
94
|
export {
|
|
@@ -35,14 +35,10 @@ const withSafeTransition = (styles: StyleRule): StyleRule => ({
|
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Helper function to create a custom focus outline style object.
|
|
38
|
-
* Returns a style object with focus-visible outline that follows the design system's outline pattern.
|
|
39
|
-
* Supports an optional selector parameter for targeting specific pseudo-selectors or child elements.
|
|
40
|
-
*
|
|
41
|
-
* This function returns a style object that must be used with vanilla-extract's `style()` function or `recipe()` function.
|
|
42
38
|
*
|
|
43
39
|
* @param outlineColor - The color for the focus outline (e.g., '#0066cc', 'rgb(255, 0, 0)', CSS custom properties)
|
|
44
|
-
* @param selector - Optional selector
|
|
45
|
-
* @returns A style object with custom focus outline styling that uses
|
|
40
|
+
* @param selector - Optional CSS selector for the outline state (e.g., ':focus-visible', '&:hover', '& > button:focus-visible', defaults to ':focus-visible')
|
|
41
|
+
* @returns A style object with custom focus outline styling that uses the provided selector
|
|
46
42
|
*
|
|
47
43
|
* @example
|
|
48
44
|
* import { style } from '@vanilla-extract/css';
|
|
@@ -58,10 +54,11 @@ const withSafeTransition = (styles: StyleRule): StyleRule => ({
|
|
|
58
54
|
* ]);
|
|
59
55
|
*
|
|
60
56
|
* // Example with custom selector
|
|
61
|
-
* const
|
|
62
|
-
* withCustomOutline('#
|
|
57
|
+
* const hoverOutlineButton = style([
|
|
58
|
+
* withCustomOutline('#00cc66', ':hover'),
|
|
63
59
|
* {
|
|
64
|
-
* padding: '
|
|
60
|
+
* padding: '8px 16px',
|
|
61
|
+
* background: 'white'
|
|
65
62
|
* }
|
|
66
63
|
* ]);
|
|
67
64
|
*
|
|
@@ -78,8 +75,8 @@ const withSafeTransition = (styles: StyleRule): StyleRule => ({
|
|
|
78
75
|
* }
|
|
79
76
|
* });
|
|
80
77
|
*/
|
|
81
|
-
const withCustomOutline = (outlineColor: string, selector = ''): Record
|
|
82
|
-
[
|
|
78
|
+
const withCustomOutline = (outlineColor: string, selector = ':focus-visible'): Record<string, CSSProperties> => ({
|
|
79
|
+
[selector]: {
|
|
83
80
|
boxShadow: `0px 0px 0px 0px, ${COLORS__PURE.transparent} 0px 0px 0px 0px, ${COLORS__PURE.transparent} 0px 0px 0px 0px, ${outlineColor} 0px 0px 0px 3px, ${outlineColor} 0px 1px 2px 0px`,
|
|
84
81
|
outline: '2px solid transparent',
|
|
85
82
|
outlineOffset: '2px',
|
|
@@ -88,10 +85,6 @@ const withCustomOutline = (outlineColor: string, selector = ''): Record<`${strin
|
|
|
88
85
|
|
|
89
86
|
/**
|
|
90
87
|
* Helper function to create a responsive style object with breakpoint media queries.
|
|
91
|
-
* Returns a style object that applies the provided styles only when the viewport width
|
|
92
|
-
* meets or exceeds the specified breakpoint value.
|
|
93
|
-
*
|
|
94
|
-
* This function returns a style object that must be used with vanilla-extract's `style()` function or `recipe()` function.
|
|
95
88
|
*
|
|
96
89
|
* @param breakpoint - The minimum viewport width for the media query (e.g., '768px', '1024px', '48rem')
|
|
97
90
|
* @param styles - CSS properties object to apply at the breakpoint (e.g., { fontSize: '1.5rem', padding: '24px' })
|
|
@@ -137,4 +130,54 @@ const withBreakpoint = (breakpoint: string, styles: CSSProperties): StyleRule =>
|
|
|
137
130
|
},
|
|
138
131
|
});
|
|
139
132
|
|
|
140
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Helper function to create a visually hidden style object for screen reader accessibility.
|
|
135
|
+
* Returns a style object that hides content visually while keeping it accessible to screen readers.
|
|
136
|
+
* This is useful for providing descriptive text, skip links, or other content that should only
|
|
137
|
+
* be available to assistive technologies.
|
|
138
|
+
*
|
|
139
|
+
* @returns A style object that visually hides content while maintaining screen reader accessibility
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* import { style } from '@vanilla-extract/css';
|
|
143
|
+
* import { recipe } from '@vanilla-extract/recipes';
|
|
144
|
+
* import { withVisuallyHidden } from './utilities.css.ts';
|
|
145
|
+
*
|
|
146
|
+
* const skipLink = style([
|
|
147
|
+
* withVisuallyHidden(),
|
|
148
|
+
* {
|
|
149
|
+
* // Additional styles can be added here
|
|
150
|
+
* zIndex: 1000
|
|
151
|
+
* }
|
|
152
|
+
* ]);
|
|
153
|
+
*
|
|
154
|
+
* const srOnly = style([
|
|
155
|
+
* withVisuallyHidden()
|
|
156
|
+
* ]);
|
|
157
|
+
*
|
|
158
|
+
* const buttonWithHiddenText = recipe({
|
|
159
|
+
* base: [
|
|
160
|
+
* withVisuallyHidden(),
|
|
161
|
+
* {
|
|
162
|
+
* padding: '8px 12px',
|
|
163
|
+
* background: 'blue'
|
|
164
|
+
* }
|
|
165
|
+
* ],
|
|
166
|
+
* variants: {
|
|
167
|
+
* // variant styles
|
|
168
|
+
* }
|
|
169
|
+
* });
|
|
170
|
+
*/
|
|
171
|
+
const withVisuallyHidden = (): StyleRule => ({
|
|
172
|
+
position: 'absolute',
|
|
173
|
+
width: '1px',
|
|
174
|
+
height: '1px',
|
|
175
|
+
padding: '0',
|
|
176
|
+
margin: '-1px',
|
|
177
|
+
overflow: 'hidden',
|
|
178
|
+
clip: 'rect(0, 0, 0, 0)',
|
|
179
|
+
whiteSpace: 'nowrap',
|
|
180
|
+
borderWidth: '0',
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
export { withSafeTransition, withCustomOutline, withBreakpoint, withVisuallyHidden };
|