@spark-web/box 0.0.0-snapshot-release-20260409001813
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 +696 -0
- package/CLAUDE.md +87 -0
- package/README.md +143 -0
- package/dist/declarations/src/background-provider.d.ts +7 -0
- package/dist/declarations/src/box.d.ts +48 -0
- package/dist/declarations/src/context.d.ts +7 -0
- package/dist/declarations/src/index.d.ts +5 -0
- package/dist/declarations/src/use-box-styles.d.ts +227 -0
- package/dist/spark-web-box.cjs.d.ts +2 -0
- package/dist/spark-web-box.cjs.dev.js +360 -0
- package/dist/spark-web-box.cjs.js +7 -0
- package/dist/spark-web-box.cjs.prod.js +360 -0
- package/dist/spark-web-box.esm.js +353 -0
- package/package.json +35 -0
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# @spark-web/box — AI Context
|
|
2
|
+
|
|
3
|
+
## What this is
|
|
4
|
+
|
|
5
|
+
The foundational layout primitive. Every Spark component is built on `Box`. It
|
|
6
|
+
exposes a prop-based API for applying theme-constrained styles to any HTML
|
|
7
|
+
element. Use it when no higher-level layout component (`Stack`, `Row`,
|
|
8
|
+
`Columns`) fits the shape of what you need.
|
|
9
|
+
|
|
10
|
+
## What this is NOT
|
|
11
|
+
|
|
12
|
+
- Not a text component — use `Text` for any rendered text content
|
|
13
|
+
- Not a layout shorthand — for vertical stacks use `Stack`, for horizontal rows
|
|
14
|
+
use `Row`, for CSS grid use `Columns`
|
|
15
|
+
- Not a button — use `Button` or `ButtonLink` for interactive elements
|
|
16
|
+
|
|
17
|
+
## Props interface
|
|
18
|
+
|
|
19
|
+
`Box` accepts all `BoxStyleProps` (see below) plus:
|
|
20
|
+
|
|
21
|
+
| Prop | Type | Notes |
|
|
22
|
+
| ----------- | ----------------------------- | ------------------------------------------------ |
|
|
23
|
+
| `as` | `keyof HTMLElementTagNameMap` | Changes the rendered element; defaults to `div` |
|
|
24
|
+
| `asElement` | `keyof HTMLElementTagNameMap` | Tells the reset system what element `as` renders |
|
|
25
|
+
| `children` | `ReactNode` | — |
|
|
26
|
+
| `data` | `DataAttributeMap` | Test/analytics attributes |
|
|
27
|
+
| `id` | `string` | — |
|
|
28
|
+
| `css` | `CSSObject` | Escape hatch for styles not covered by props |
|
|
29
|
+
|
|
30
|
+
### BoxStyleProps — commonly used
|
|
31
|
+
|
|
32
|
+
Spacing values map to `SparkTheme['spacing']` keys:
|
|
33
|
+
`none | xsmall | small | medium | large | xlarge | xxlarge`
|
|
34
|
+
|
|
35
|
+
Sizing values map to `SparkTheme['sizing']` keys:
|
|
36
|
+
`xxsmall | xsmall | small | medium | large | xlarge | xxlarge | full`
|
|
37
|
+
|
|
38
|
+
| Prop | Values |
|
|
39
|
+
| --------------------------------- | ---------------------------------------------------------------------------- |
|
|
40
|
+
| `padding` | spacing token (responsive) |
|
|
41
|
+
| `paddingX` | spacing token (responsive) |
|
|
42
|
+
| `paddingY` | spacing token (responsive) |
|
|
43
|
+
| `paddingTop/Bottom/Left/Right` | spacing token (responsive) |
|
|
44
|
+
| `margin` | spacing token (responsive) |
|
|
45
|
+
| `marginX/Y/Top/Bottom/Left/Right` | spacing token (responsive) |
|
|
46
|
+
| `gap` | spacing token (responsive, excludes `none` and `full`) |
|
|
47
|
+
| `width` | sizing token or `'full'` (responsive) |
|
|
48
|
+
| `height` | sizing token (responsive) |
|
|
49
|
+
| `display` | `'block' \| 'inline' \| 'inline-block' \| 'inline-flex' \| 'flex' \| 'none'` |
|
|
50
|
+
| `flexDirection` | `'row' \| 'rowReverse' \| 'column' \| 'columnReverse'` |
|
|
51
|
+
| `flexWrap` | `'wrap' \| 'nowrap'` |
|
|
52
|
+
| `alignItems` | `'center' \| 'flexStart' \| 'flexEnd' \| 'stretch'` |
|
|
53
|
+
| `justifyContent` | `'start' \| 'center' \| 'end' \| 'spaceBetween' \| 'stretch'` |
|
|
54
|
+
| `flexShrink` | `0 \| 1` |
|
|
55
|
+
| `position` | `'relative' \| 'absolute' \| 'fixed' \| 'sticky'` |
|
|
56
|
+
| `top/bottom/left/right` | `number` (responsive) |
|
|
57
|
+
| `overflow` | `'hidden' \| 'auto' \| 'scroll' \| 'visible'` |
|
|
58
|
+
| `background` | background token (e.g. `'surface' \| 'primary' \| 'primarySoft'`) |
|
|
59
|
+
| `border` | border color token (e.g. `'standard' \| 'primary'`) |
|
|
60
|
+
| `borderRadius` | `'small' \| 'medium' \| 'large' \| 'full'` |
|
|
61
|
+
| `cursor` | `'default' \| 'pointer'` |
|
|
62
|
+
|
|
63
|
+
## Token usage
|
|
64
|
+
|
|
65
|
+
All values come from the theme — never raw hex, px, or Tailwind. Use
|
|
66
|
+
`useTheme()` from `@spark-web/theme` for any value not expressible as a Box prop
|
|
67
|
+
(e.g. inline color from `theme.color.foreground.muted`).
|
|
68
|
+
|
|
69
|
+
The `background` prop automatically pushes a background context so child `Text`
|
|
70
|
+
components can invert their color tone when placed on dark backgrounds.
|
|
71
|
+
|
|
72
|
+
## Composition
|
|
73
|
+
|
|
74
|
+
`Box` is the leaf — it does not compose other Spark components. Every other
|
|
75
|
+
Spark component composes `Box` internally.
|
|
76
|
+
|
|
77
|
+
## Do NOTs
|
|
78
|
+
|
|
79
|
+
- NEVER use raw hex, px, em, rem, or Tailwind classes
|
|
80
|
+
- NEVER use `Box` for text content — use `Text`
|
|
81
|
+
- NEVER use `Box` when `Stack`, `Row`, or `Columns` fits the layout — those
|
|
82
|
+
components encode the correct flex/grid setup automatically
|
|
83
|
+
- NEVER pass `display`, `alignItems`, `flexDirection`, or `justifyContent` to
|
|
84
|
+
`Stack` or `Row` — those are locked internally; use `Box` if you need custom
|
|
85
|
+
flex control
|
|
86
|
+
- NEVER use `style={{}}` for theme values — use Box props or `css` prop with
|
|
87
|
+
theme tokens
|
package/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Box
|
|
3
|
+
storybookPath: page-layout-box--default
|
|
4
|
+
isExperimentalPackage: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
The Box component is our lowest-level primitive. The goal of the Box component
|
|
8
|
+
is to map props to our tokens so that consumers should be able to use these
|
|
9
|
+
props for all of their styling needs. Ideally, you shouldn't need to use the
|
|
10
|
+
`className` or `style` prop at all. Internally, all Spark Web components are
|
|
11
|
+
composed using the Box component.
|
|
12
|
+
|
|
13
|
+
Box is a polymorphic component (meaning it will render different elements
|
|
14
|
+
depending on what is provided to the `as` prop). If no `as` prop is provided,
|
|
15
|
+
Box will render a `div`.
|
|
16
|
+
|
|
17
|
+
We also spread in consumer props, so any valid HTML attributes are also valid
|
|
18
|
+
for Box. Due to some clever TypeScript we can even warn you when you use an
|
|
19
|
+
invalid combination of props.
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
<Box as="input" href="https://spark.brighte.com.au" />
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
In the example above, you should see a "red squiggly" under the `href` element
|
|
26
|
+
with the following error:
|
|
27
|
+
|
|
28
|
+
```console
|
|
29
|
+
Type '{ as: "input"; href: string; }' is not assignable to type 'IntrinsicAttributes & { as?: "input" | undefined; ref?: Ref<HTMLInputElement> | undefined; } & Omit<Pick<DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "key" | keyof InputHTMLAttributes<...>>, "as"> & { ...; } & UnresponsiveBoxProps & ResponsiveBoxProps'.
|
|
30
|
+
Property 'href' does not exist on type 'IntrinsicAttributes & { as?: "input" | undefined; ref?: Ref<HTMLInputElement> | undefined; } & Omit<Pick<DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "key" | keyof InputHTMLAttributes<...>>, "as"> & { ...; } & UnresponsiveBoxProps & ResponsiveBoxProps'. Did you mean 'ref'?
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Unfortunately TypeScript errors can be pretty cryptic sometimes 🙃.
|
|
34
|
+
|
|
35
|
+
**Pro tip**: copying the error message and pasting it into
|
|
36
|
+
[TypeScript Error Translator](https://ts-error-translator.vercel.app/) can
|
|
37
|
+
sometimes help make these errors easier to understand.
|
|
38
|
+
|
|
39
|
+
A minimal CSS reset is also applied to each element rendered with Box. This
|
|
40
|
+
helps prevent styles from "leaking" out and effecting other elements (which
|
|
41
|
+
should make it easier to incrementally adopt Spark Web into existing projects).
|
|
42
|
+
If you provide a non-Spark component to the `as` prop instead of an element, it
|
|
43
|
+
is recommended that you also use the `asElement` prop so the appropriate styles
|
|
44
|
+
can be applied.
|
|
45
|
+
|
|
46
|
+
## Examples
|
|
47
|
+
|
|
48
|
+
### Responsive styles
|
|
49
|
+
|
|
50
|
+
Most of Box's props accept a string value (usually corresponding to a token), we
|
|
51
|
+
also accept an object for responsive styles.
|
|
52
|
+
|
|
53
|
+
```jsx live
|
|
54
|
+
const items = [1, 2, 3];
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Box
|
|
58
|
+
background="primaryLow"
|
|
59
|
+
display="inline-flex"
|
|
60
|
+
flexDirection={{ mobile: 'row', tablet: 'column', desktop: 'rowReverse' }}
|
|
61
|
+
gap={{ mobile: 'small', tablet: 'medium', desktop: 'large' }}
|
|
62
|
+
padding={{ mobile: 'small', tablet: 'medium', desktop: 'large' }}
|
|
63
|
+
>
|
|
64
|
+
{items.map(item => (
|
|
65
|
+
<Row
|
|
66
|
+
key={item}
|
|
67
|
+
align="center"
|
|
68
|
+
alignY="center"
|
|
69
|
+
background="primary"
|
|
70
|
+
height={{ mobile: 'small', tablet: 'medium', desktop: 'large' }}
|
|
71
|
+
width={{ mobile: 'small', tablet: 'medium', desktop: 'large' }}
|
|
72
|
+
>
|
|
73
|
+
<Text>{item}</Text>
|
|
74
|
+
</Row>
|
|
75
|
+
))}
|
|
76
|
+
</Box>
|
|
77
|
+
);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Resize your browser to see the example above change at different breakpoints.
|
|
81
|
+
|
|
82
|
+
### Backgrounds
|
|
83
|
+
|
|
84
|
+
Box stores the background in a provider. We can use this to work out what colour
|
|
85
|
+
to use by default for text elements.
|
|
86
|
+
|
|
87
|
+
```jsx live
|
|
88
|
+
const backgroundTones = [
|
|
89
|
+
// Light
|
|
90
|
+
['surface', 'positiveLight', 'infoLight', 'cautionLight', 'criticalLight'],
|
|
91
|
+
// Dark
|
|
92
|
+
['muted', 'positive', 'info', 'caution', 'critical'],
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<Stack gap="large">
|
|
97
|
+
{backgroundTones.map((backgrounds, index) => (
|
|
98
|
+
<Columns
|
|
99
|
+
key={index}
|
|
100
|
+
collapseBelow="tablet"
|
|
101
|
+
gap="large"
|
|
102
|
+
template={[1, 1, 1]}
|
|
103
|
+
>
|
|
104
|
+
{backgrounds.map(background => (
|
|
105
|
+
<Box
|
|
106
|
+
key={background}
|
|
107
|
+
shadow="medium"
|
|
108
|
+
background={background}
|
|
109
|
+
height="large"
|
|
110
|
+
display="flex"
|
|
111
|
+
flexShrink={0}
|
|
112
|
+
alignItems="center"
|
|
113
|
+
justifyContent="center"
|
|
114
|
+
>
|
|
115
|
+
<Text weight="semibold">{background}</Text>
|
|
116
|
+
</Box>
|
|
117
|
+
))}
|
|
118
|
+
</Columns>
|
|
119
|
+
))}
|
|
120
|
+
</Stack>
|
|
121
|
+
);
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Notice that the Text in the example above doesn't use the tone prop, the colour
|
|
125
|
+
is worked out using the BackgroundProvider in Box.
|
|
126
|
+
|
|
127
|
+
**Note:** this will only work if you use the `background` prop. If you try to
|
|
128
|
+
style the background colour in any other way the Text component will not know
|
|
129
|
+
what colour the background is and so cannot invert its colour to make sure that
|
|
130
|
+
its contents are readable.
|
|
131
|
+
|
|
132
|
+
```jsx
|
|
133
|
+
<Box style={{ background: 'midnightblue' }} padding="large">
|
|
134
|
+
<Text>Good luck reading this!</Text>
|
|
135
|
+
</Box>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Props
|
|
139
|
+
|
|
140
|
+
<PropsTable displayName="Box" />
|
|
141
|
+
|
|
142
|
+
By default, Box renders a `div` element. You can customise this via the `as`
|
|
143
|
+
prop. Extra props will also be forwarded to the underlying element.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
export type BackgroundProviderProps = {
|
|
3
|
+
type: 'light' | 'dark';
|
|
4
|
+
children: ReactElement;
|
|
5
|
+
};
|
|
6
|
+
/** Enforce background "lightness" without applying a background color. */
|
|
7
|
+
export declare const BackgroundProvider: ({ type, children, }: BackgroundProviderProps) => import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CSSObject } from '@emotion/react';
|
|
2
|
+
import type { DataAttributeMap } from '@spark-web/utils/internal';
|
|
3
|
+
import type { ReactNode } from 'react';
|
|
4
|
+
import type { BoxStyleProps } from "./use-box-styles.js";
|
|
5
|
+
export type BoxProps = {
|
|
6
|
+
/** Children element to be rendered inside the component. */
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
/** Sets data attributes on the component. */
|
|
9
|
+
data?: DataAttributeMap;
|
|
10
|
+
/** An identifier which must be unique in the whole document. */
|
|
11
|
+
id?: string;
|
|
12
|
+
/** Custom css styles. */
|
|
13
|
+
css?: CSSObject;
|
|
14
|
+
/**
|
|
15
|
+
* When providing a component using the "as" prop, optionally tell the system
|
|
16
|
+
* what the underlying element will be. Used internally to manage reset
|
|
17
|
+
* styles.
|
|
18
|
+
*/
|
|
19
|
+
asElement?: keyof HTMLElementTagNameMap;
|
|
20
|
+
} & BoxStyleProps;
|
|
21
|
+
/** Exposes a prop-based API for adding styles to a view, within the constraints of the theme. */
|
|
22
|
+
export declare const Box: <Comp extends import("react").ElementType = "div">(props: {
|
|
23
|
+
as?: Comp | undefined;
|
|
24
|
+
ref?: import("react").Ref<Comp extends "symbol" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "set" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | keyof HTMLElementTagNameMap ? (HTMLElementTagNameMap & Pick<SVGElementTagNameMap, "symbol" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "set" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">)[Comp] : Comp extends new (...args: any) => any ? InstanceType<Comp> : undefined> | undefined;
|
|
25
|
+
} & Omit<import("react").PropsWithoutRef<import("react").ComponentProps<Comp>>, "as"> & {
|
|
26
|
+
/** Children element to be rendered inside the component. */
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
/** Sets data attributes on the component. */
|
|
29
|
+
data?: DataAttributeMap;
|
|
30
|
+
/** An identifier which must be unique in the whole document. */
|
|
31
|
+
id?: string;
|
|
32
|
+
/** Custom css styles. */
|
|
33
|
+
css?: CSSObject;
|
|
34
|
+
/**
|
|
35
|
+
* When providing a component using the "as" prop, optionally tell the system
|
|
36
|
+
* what the underlying element will be. Used internally to manage reset
|
|
37
|
+
* styles.
|
|
38
|
+
*/
|
|
39
|
+
asElement?: keyof HTMLElementTagNameMap;
|
|
40
|
+
} & {
|
|
41
|
+
background?: keyof import("@spark-web/theme").SparkTheme["color"]["background"];
|
|
42
|
+
cursor?: "default" | "pointer";
|
|
43
|
+
minHeight?: 0;
|
|
44
|
+
minWidth?: 0;
|
|
45
|
+
overflow?: "hidden" | "scroll" | "visible" | "auto";
|
|
46
|
+
shadow?: keyof import("@spark-web/theme").SparkTheme["shadow"] | string | null;
|
|
47
|
+
userSelect?: "none";
|
|
48
|
+
} & import("./use-box-styles.js").ResponsiveBoxProps) => import("react").ReactElement;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { BoxStyleProps } from "./use-box-styles.js";
|
|
3
|
+
export type BackgroundVariant = NonNullable<BoxStyleProps['background']> | 'UNKNOWN_DARK' | 'UNKNOWN_LIGHT';
|
|
4
|
+
export declare const InternalBackgroundProvider: import("react").Provider<BackgroundVariant>;
|
|
5
|
+
export declare const useBackground: () => BackgroundVariant;
|
|
6
|
+
export declare function renderBackgroundProvider(background: BackgroundVariant | undefined, element: ReactElement | null): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
export declare const useBackgroundLightness: (backgroundOverride?: ReturnType<typeof useBackground>) => "light" | "dark";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { BackgroundProvider } from "./background-provider.js";
|
|
2
|
+
export { Box } from "./box.js";
|
|
3
|
+
export { useBackground, useBackgroundLightness } from "./context.js";
|
|
4
|
+
export type { BackgroundProviderProps } from "./background-provider.js";
|
|
5
|
+
export type { BoxProps } from "./box.js";
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import type { ResponsiveProp, SparkTheme } from '@spark-web/theme';
|
|
2
|
+
type ValidGapKeys = keyof Omit<SparkTheme['spacing'], 'none' | 'full'>;
|
|
3
|
+
type ResponsiveSpacing = ResponsiveProp<keyof SparkTheme['spacing']>;
|
|
4
|
+
type ResponsiveSizing = ResponsiveProp<keyof SparkTheme['sizing']>;
|
|
5
|
+
export type ResponsiveBoxProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The `margin` shorthand property sets the margin area on all four sides of
|
|
8
|
+
* an element at once.
|
|
9
|
+
*/
|
|
10
|
+
margin?: ResponsiveSpacing;
|
|
11
|
+
/**
|
|
12
|
+
* The `marginTop` property sets the margin area on the top side of an
|
|
13
|
+
* element.
|
|
14
|
+
*/
|
|
15
|
+
marginTop?: ResponsiveSpacing;
|
|
16
|
+
/**
|
|
17
|
+
* The `marginRight` property sets the margin area on the right side of an
|
|
18
|
+
* element.
|
|
19
|
+
*/
|
|
20
|
+
marginRight?: ResponsiveSpacing;
|
|
21
|
+
/**
|
|
22
|
+
* The `marginBottom` property sets the margin area on the bottom side of an
|
|
23
|
+
* element.
|
|
24
|
+
*/
|
|
25
|
+
marginBottom?: ResponsiveSpacing;
|
|
26
|
+
/**
|
|
27
|
+
* The `marginLeft` property sets the margin area on the left side of an
|
|
28
|
+
* element.
|
|
29
|
+
*/
|
|
30
|
+
marginLeft?: ResponsiveSpacing;
|
|
31
|
+
/**
|
|
32
|
+
* The `marginY` shorthand property sets the margin area on the top and
|
|
33
|
+
* bottom of the element.
|
|
34
|
+
*/
|
|
35
|
+
marginY?: ResponsiveSpacing;
|
|
36
|
+
/**
|
|
37
|
+
* The `marginY` shorthand property sets the margin area on the left and
|
|
38
|
+
* right of the element.
|
|
39
|
+
*/
|
|
40
|
+
marginX?: ResponsiveSpacing;
|
|
41
|
+
/**
|
|
42
|
+
* The `padding` shorthand property sets the padding area on all four sides
|
|
43
|
+
* of an element at once.
|
|
44
|
+
*/
|
|
45
|
+
padding?: ResponsiveSpacing;
|
|
46
|
+
/**
|
|
47
|
+
* The `paddingTop` property sets the height of the padding area on the top
|
|
48
|
+
* of an element.
|
|
49
|
+
*/
|
|
50
|
+
paddingTop?: ResponsiveSpacing;
|
|
51
|
+
/**
|
|
52
|
+
* The `paddingRight` property sets the width of the padding area on the
|
|
53
|
+
* right of an element.
|
|
54
|
+
*/
|
|
55
|
+
paddingRight?: ResponsiveSpacing;
|
|
56
|
+
/**
|
|
57
|
+
* The `paddingBottom` property sets the height of the padding area on the
|
|
58
|
+
* bottom of an element.
|
|
59
|
+
*/
|
|
60
|
+
paddingBottom?: ResponsiveSpacing;
|
|
61
|
+
/**
|
|
62
|
+
* The `paddingLeft` property sets the width of the padding area on the left
|
|
63
|
+
* of an element.
|
|
64
|
+
*/
|
|
65
|
+
paddingLeft?: ResponsiveSpacing;
|
|
66
|
+
/**
|
|
67
|
+
* The `paddingY` shorthand property sets the padding area on the top and
|
|
68
|
+
* bottom of the element.
|
|
69
|
+
*/
|
|
70
|
+
paddingY?: ResponsiveSpacing;
|
|
71
|
+
/**
|
|
72
|
+
* The `paddingX` shorthand property sets the padding area on the left and
|
|
73
|
+
* right of the element.
|
|
74
|
+
*/
|
|
75
|
+
paddingX?: ResponsiveSpacing;
|
|
76
|
+
/** The `border` property sets the color of an element's border. */
|
|
77
|
+
border?: ResponsiveProp<keyof SparkTheme['border']['color'] | string>;
|
|
78
|
+
/** The `border` property sets the color of an element's border on the top side. */
|
|
79
|
+
borderTop?: ResponsiveProp<keyof SparkTheme['border']['color'] | string>;
|
|
80
|
+
/** The `border` property sets the color of an element's border on the bottom side. */
|
|
81
|
+
borderBottom?: ResponsiveProp<keyof SparkTheme['border']['color'] | string>;
|
|
82
|
+
/** The `border` property sets the color of an element's border on the left side. */
|
|
83
|
+
borderLeft?: ResponsiveProp<keyof SparkTheme['border']['color'] | string>;
|
|
84
|
+
/** The `border` property sets the color of an element's border on the right side. */
|
|
85
|
+
borderRight?: ResponsiveProp<keyof SparkTheme['border']['color'] | string>;
|
|
86
|
+
/**
|
|
87
|
+
* The `borderRadius` property rounds the corners of an element's outer
|
|
88
|
+
* border edge.
|
|
89
|
+
*/
|
|
90
|
+
borderRadius?: ResponsiveProp<keyof SparkTheme['border']['radius']> | number;
|
|
91
|
+
/**
|
|
92
|
+
* The `borderWidth` property sets the width of an element's border.
|
|
93
|
+
*/
|
|
94
|
+
borderWidth?: ResponsiveProp<keyof SparkTheme['border']['width']>;
|
|
95
|
+
/** Sets the element's height. */
|
|
96
|
+
height?: ResponsiveSizing;
|
|
97
|
+
/** Sets the element's width. */
|
|
98
|
+
width?: ResponsiveSizing;
|
|
99
|
+
/** Controls the alignment of items on the cross axis. */
|
|
100
|
+
alignItems?: ResponsiveProp<keyof typeof flexMap.alignItems>;
|
|
101
|
+
/** The size of the gap between each child element. */
|
|
102
|
+
gap?: ResponsiveProp<ValidGapKeys>;
|
|
103
|
+
/** Defines the main axis, or how the children are placed. */
|
|
104
|
+
flexDirection?: ResponsiveProp<keyof typeof flexMap.flexDirection>;
|
|
105
|
+
/**
|
|
106
|
+
* defines how the browser distributes space between and around content items
|
|
107
|
+
* along the main-axis.
|
|
108
|
+
*/
|
|
109
|
+
justifyContent?: ResponsiveProp<keyof typeof flexMap.justifyContent>;
|
|
110
|
+
/** Allow flex items to flow onto multiple lines. */
|
|
111
|
+
flexWrap?: ResponsiveProp<'nowrap' | 'wrap'>;
|
|
112
|
+
/**
|
|
113
|
+
* Overrides the parent's `align-items` value. Controls the alignment of
|
|
114
|
+
* item's on the cross axis.
|
|
115
|
+
*/
|
|
116
|
+
alignSelf?: ResponsiveProp<keyof typeof flexMap.alignItems>;
|
|
117
|
+
/**
|
|
118
|
+
* The `flex` shorthand property sets how a flex item will grow or shrink to
|
|
119
|
+
* fit the space available in its flex container.
|
|
120
|
+
*/
|
|
121
|
+
flex?: ResponsiveProp<0 | 1>;
|
|
122
|
+
/** The `flexGrow` property sets the flex grow factor of a flex item main size. */
|
|
123
|
+
flexGrow?: ResponsiveProp<0 | 1>;
|
|
124
|
+
/**
|
|
125
|
+
* The `flexShrink` property sets the flex shrink factor of a flex item. If
|
|
126
|
+
* the size of all flex items is larger than the flex container, items shrink
|
|
127
|
+
* to fit according to `flex-shrink`.
|
|
128
|
+
*/
|
|
129
|
+
flexShrink?: ResponsiveProp<0 | 1>;
|
|
130
|
+
/**
|
|
131
|
+
* The `position` property sets how an element is positioned in a document.
|
|
132
|
+
* The `top`, `right`, `bottom`, and `left` properties determine the final
|
|
133
|
+
* location of positioned elements.
|
|
134
|
+
*/
|
|
135
|
+
position?: ResponsiveProp<'absolute' | 'fixed' | 'relative' | 'sticky'>;
|
|
136
|
+
/**
|
|
137
|
+
* The `top` property participates in specifying the vertical position of a
|
|
138
|
+
* positioned element. It has no effect on non-positioned elements.
|
|
139
|
+
*/
|
|
140
|
+
top?: ResponsiveProp<number>;
|
|
141
|
+
/**
|
|
142
|
+
* The `right` property participates in specifying the horizontal position of
|
|
143
|
+
* a positioned element. It has no effect on non-positioned elements.
|
|
144
|
+
*/
|
|
145
|
+
right?: ResponsiveProp<number>;
|
|
146
|
+
/**
|
|
147
|
+
* The `bottom` property participates in setting the vertical position of a
|
|
148
|
+
* positioned element. It has no effect on non-positioned elements.
|
|
149
|
+
*/
|
|
150
|
+
bottom?: ResponsiveProp<number>;
|
|
151
|
+
/**
|
|
152
|
+
* The `left` property participates in specifying the horizontal position of a
|
|
153
|
+
* positioned element. It has no effect on non-positioned elements.
|
|
154
|
+
*/
|
|
155
|
+
left?: ResponsiveProp<number>;
|
|
156
|
+
/**
|
|
157
|
+
* The `zIndex` property sets the "z-order" of a positioned element and its
|
|
158
|
+
* descendants or flex items. Overlapping elements with a larger z-index cover
|
|
159
|
+
* those with a smaller one.
|
|
160
|
+
*/
|
|
161
|
+
zIndex?: ResponsiveProp<keyof SparkTheme['elevation']>;
|
|
162
|
+
/**
|
|
163
|
+
* Sets whether an element is treated as a block or inline element and the
|
|
164
|
+
* layout used for its children.
|
|
165
|
+
*/
|
|
166
|
+
display?: ResponsiveProp<'block' | 'flex' | 'inline' | 'inline-block' | 'inline-flex' | 'none'>;
|
|
167
|
+
/**
|
|
168
|
+
* Sets the opacity of the element. Opacity is the degree to which content
|
|
169
|
+
* behind an element is hidden, and is the opposite of transparency.
|
|
170
|
+
*/
|
|
171
|
+
opacity?: ResponsiveProp<number>;
|
|
172
|
+
};
|
|
173
|
+
type UnresponsiveBoxProps = {
|
|
174
|
+
/** The `background` property sets the background color of an element. */
|
|
175
|
+
background?: keyof SparkTheme['color']['background'];
|
|
176
|
+
/**
|
|
177
|
+
* The `cursor` property sets the type of mouse cursor, if any, to show when
|
|
178
|
+
* the mouse pointer is over an element.
|
|
179
|
+
*/
|
|
180
|
+
cursor?: 'default' | 'pointer';
|
|
181
|
+
/**
|
|
182
|
+
* The `minHeight` property sets the minimum height of an element. It prevents
|
|
183
|
+
* the used value of the height property from becoming smaller than the value
|
|
184
|
+
* specified for `minHeight`.
|
|
185
|
+
*/
|
|
186
|
+
minHeight?: 0;
|
|
187
|
+
/**
|
|
188
|
+
* The `minWidth` property sets the minimum width of an element. It prevents
|
|
189
|
+
* the used value of the width property from becoming smaller than the value
|
|
190
|
+
* specified for `minWidth`.
|
|
191
|
+
*/
|
|
192
|
+
minWidth?: 0;
|
|
193
|
+
/**
|
|
194
|
+
* The `overflow` shorthand property sets the desired behavior for an
|
|
195
|
+
* element's overflow — i.e. when an element's content is too big to fit in
|
|
196
|
+
* its block formatting context — in both directions.
|
|
197
|
+
*/
|
|
198
|
+
overflow?: 'hidden' | 'scroll' | 'visible' | 'auto';
|
|
199
|
+
/** The `boxShadow` property adds shadow effects around an element's frame. */
|
|
200
|
+
shadow?: keyof SparkTheme['shadow'] | string | null;
|
|
201
|
+
/** The `userSelect` property controls whether the user can select text. */
|
|
202
|
+
userSelect?: 'none';
|
|
203
|
+
};
|
|
204
|
+
export type BoxStyleProps = UnresponsiveBoxProps & ResponsiveBoxProps;
|
|
205
|
+
export declare const useBoxStyles: ({ alignItems, alignSelf, background, border, borderTop, borderBottom, borderLeft, borderRight, borderRadius, borderWidth, bottom, cursor, display, flex, flexDirection, flexGrow, flexShrink, flexWrap, gap, height, justifyContent, left, margin, marginBottom, marginLeft, marginRight, marginTop, marginX, marginY, minHeight, minWidth, opacity, overflow, padding, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, position, right, shadow, top, userSelect, width, zIndex, }: BoxStyleProps) => import("facepaint").DynamicStyle[];
|
|
206
|
+
declare const flexMap: {
|
|
207
|
+
readonly alignItems: {
|
|
208
|
+
readonly start: "flex-start";
|
|
209
|
+
readonly center: "center";
|
|
210
|
+
readonly end: "flex-end";
|
|
211
|
+
readonly stretch: "stretch";
|
|
212
|
+
};
|
|
213
|
+
readonly justifyContent: {
|
|
214
|
+
readonly start: "flex-start";
|
|
215
|
+
readonly center: "center";
|
|
216
|
+
readonly end: "flex-end";
|
|
217
|
+
readonly spaceBetween: "space-between";
|
|
218
|
+
readonly stretch: "stretch";
|
|
219
|
+
};
|
|
220
|
+
readonly flexDirection: {
|
|
221
|
+
readonly row: "row";
|
|
222
|
+
readonly rowReverse: "row-reverse";
|
|
223
|
+
readonly column: "column";
|
|
224
|
+
readonly columnReverse: "column-reverse";
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from "./declarations/src/index.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3Bhcmstd2ViLWJveC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
|