@spark-web/button 0.0.0-snapshot-release-20220907020533
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 +213 -0
- package/dist/declarations/src/BaseButton.d.ts +10 -0
- package/dist/declarations/src/Button.d.ts +28 -0
- package/dist/declarations/src/ButtonLink.d.ts +9 -0
- package/dist/declarations/src/index.d.ts +8 -0
- package/dist/declarations/src/resolveButtonChildren.d.ts +10 -0
- package/dist/declarations/src/types.d.ts +37 -0
- package/dist/declarations/src/useButtonStyles.d.ts +88 -0
- package/dist/declarations/src/utils.d.ts +43 -0
- package/dist/spark-web-button.cjs.d.ts +1 -0
- package/dist/spark-web-button.cjs.dev.js +505 -0
- package/dist/spark-web-button.cjs.js +7 -0
- package/dist/spark-web-button.cjs.prod.js +505 -0
- package/dist/spark-web-button.esm.js +498 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Button
|
|
3
|
+
storybookPath: forms-buttons-button--default
|
|
4
|
+
isExperimentalPackage: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Buttons are clickable elements that are used to trigger actions. They
|
|
8
|
+
communicate calls to action to the user and allow users to interact with pages
|
|
9
|
+
in a variety of ways. Button labels express what action will occur when the user
|
|
10
|
+
interacts with it.
|
|
11
|
+
|
|
12
|
+
## Tone
|
|
13
|
+
|
|
14
|
+
Button tones can be broken up into two types; decorative and semantic.
|
|
15
|
+
|
|
16
|
+
For destructive actions like “delete” you should use the semantic `tone` of
|
|
17
|
+
`critical`.
|
|
18
|
+
|
|
19
|
+
For buttons that have no semantic action type (more common on marketing pages)
|
|
20
|
+
use one of our decorative `tones`.
|
|
21
|
+
|
|
22
|
+
Defaults to `primary`.
|
|
23
|
+
|
|
24
|
+
```jsx live
|
|
25
|
+
<Stack gap="large">
|
|
26
|
+
<Text weight="strong">Decorative tones</Text>
|
|
27
|
+
<Inline gap="small">
|
|
28
|
+
<Button tone="primary">Primary</Button>
|
|
29
|
+
<Button tone="secondary">Secondary</Button>
|
|
30
|
+
</Inline>
|
|
31
|
+
<Divider />
|
|
32
|
+
<Text weight="strong">Semantic tones</Text>
|
|
33
|
+
<Inline gap="small">
|
|
34
|
+
<Button tone="neutral">Neutral</Button>
|
|
35
|
+
<Button tone="positive">Positive</Button>
|
|
36
|
+
<Button tone="critical">Critical</Button>
|
|
37
|
+
</Inline>
|
|
38
|
+
</Stack>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Prominence
|
|
42
|
+
|
|
43
|
+
The appearance of the button can be customised with the prominence prop. Valid
|
|
44
|
+
options are: `low` and `high`.
|
|
45
|
+
|
|
46
|
+
Defaults to `high`.
|
|
47
|
+
|
|
48
|
+
```jsx live
|
|
49
|
+
const baseButtonTones = [
|
|
50
|
+
{ label: 'Primary', tone: 'primary' },
|
|
51
|
+
{ label: 'Secondary', tone: 'secondary' },
|
|
52
|
+
{ label: 'Neutral', tone: 'neutral' },
|
|
53
|
+
{ label: 'Positive', tone: 'positive' },
|
|
54
|
+
{ label: 'Critical', tone: 'critical' },
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
const extraButtonTones = [
|
|
58
|
+
{ label: 'Caution', tone: 'caution' },
|
|
59
|
+
{ label: 'Informative', tone: 'info' },
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<Stack gap="large" dividers>
|
|
64
|
+
<Stack gap="large">
|
|
65
|
+
<Text weight="strong">High prominence</Text>
|
|
66
|
+
<Inline gap="small">
|
|
67
|
+
{baseButtonTones.map(({ label, tone }) => (
|
|
68
|
+
<Button key={label} tone={tone} prominence="high">
|
|
69
|
+
<LightBulbIcon />
|
|
70
|
+
{label}
|
|
71
|
+
</Button>
|
|
72
|
+
))}
|
|
73
|
+
</Inline>
|
|
74
|
+
</Stack>
|
|
75
|
+
<Stack gap="large">
|
|
76
|
+
<Text weight="strong">Low prominence</Text>
|
|
77
|
+
<Inline gap="small">
|
|
78
|
+
{baseButtonTones.concat(extraButtonTones).map(({ label, tone }) => (
|
|
79
|
+
<Button key={label} tone={tone} prominence="low">
|
|
80
|
+
<LightBulbIcon />
|
|
81
|
+
{label}
|
|
82
|
+
</Button>
|
|
83
|
+
))}
|
|
84
|
+
</Inline>
|
|
85
|
+
</Stack>
|
|
86
|
+
<Stack gap="large">
|
|
87
|
+
<Text weight="strong">None prominence</Text>
|
|
88
|
+
<Inline gap="small">
|
|
89
|
+
{baseButtonTones.concat(extraButtonTones).map(({ label, tone }) => (
|
|
90
|
+
<Button key={label} tone={tone} prominence="none">
|
|
91
|
+
<LightBulbIcon />
|
|
92
|
+
{label}
|
|
93
|
+
</Button>
|
|
94
|
+
))}
|
|
95
|
+
</Inline>
|
|
96
|
+
</Stack>
|
|
97
|
+
</Stack>
|
|
98
|
+
);
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Size
|
|
102
|
+
|
|
103
|
+
Button's are available in two size: `medium` and `large`.
|
|
104
|
+
|
|
105
|
+
Defaults to `medium`.
|
|
106
|
+
|
|
107
|
+
```jsx live
|
|
108
|
+
<Inline gap="small">
|
|
109
|
+
<Button size="medium">Medium</Button>
|
|
110
|
+
<Button size="large">Large</Button>
|
|
111
|
+
</Inline>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Icons
|
|
115
|
+
|
|
116
|
+
Icons can be placed next to labels to both clarify an action and call attention
|
|
117
|
+
to a button.
|
|
118
|
+
|
|
119
|
+
```jsx live
|
|
120
|
+
<Inline gap="small">
|
|
121
|
+
<Button>
|
|
122
|
+
<DownloadIcon />
|
|
123
|
+
Download
|
|
124
|
+
</Button>
|
|
125
|
+
<Button tone="critical">
|
|
126
|
+
<TrashIcon />
|
|
127
|
+
Delete
|
|
128
|
+
</Button>
|
|
129
|
+
</Inline>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Icon only
|
|
133
|
+
|
|
134
|
+
When using buttons that contain only an icon, you must provide a `label` for
|
|
135
|
+
users of assistive technology.
|
|
136
|
+
|
|
137
|
+
```jsx live
|
|
138
|
+
<Inline gap="small">
|
|
139
|
+
<Button label="Download PDF">
|
|
140
|
+
<DownloadIcon />
|
|
141
|
+
</Button>
|
|
142
|
+
<Button tone="critical" label="Delete item">
|
|
143
|
+
<TrashIcon />
|
|
144
|
+
</Button>
|
|
145
|
+
<Button tone="neutral" label="Dismiss">
|
|
146
|
+
<XIcon size="xxsmall" />
|
|
147
|
+
</Button>
|
|
148
|
+
</Inline>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Loading
|
|
152
|
+
|
|
153
|
+
Buttons have an optional `loading` prop to indicate that an action is in
|
|
154
|
+
progress. When this is true a spinner will be displayed.
|
|
155
|
+
|
|
156
|
+
Note: buttons will not be interative when `loading` is true.
|
|
157
|
+
|
|
158
|
+
```jsx live
|
|
159
|
+
const [loading, setLoading] = React.useState(false);
|
|
160
|
+
const toggle = event => setLoading(event.target.checked);
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<Stack gap="large">
|
|
164
|
+
<Checkbox size="medium" checked={loading} onChange={toggle}>
|
|
165
|
+
<Text>Toggle loading state</Text>
|
|
166
|
+
</Checkbox>
|
|
167
|
+
<Inline gap="large">
|
|
168
|
+
<Button label="Download" loading={loading}>
|
|
169
|
+
<DownloadIcon />
|
|
170
|
+
</Button>
|
|
171
|
+
<Button loading={loading}>
|
|
172
|
+
<DownloadIcon />
|
|
173
|
+
Download
|
|
174
|
+
</Button>
|
|
175
|
+
</Inline>
|
|
176
|
+
<Inline gap="large">
|
|
177
|
+
<Button label="Download" size="large" loading={loading}>
|
|
178
|
+
<DownloadIcon />
|
|
179
|
+
</Button>
|
|
180
|
+
<Button size="large" loading={loading}>
|
|
181
|
+
<DownloadIcon />
|
|
182
|
+
Download
|
|
183
|
+
</Button>
|
|
184
|
+
</Inline>
|
|
185
|
+
</Stack>
|
|
186
|
+
);
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## ButtonLink
|
|
190
|
+
|
|
191
|
+
The appearance of a button, with the semantics of a link — shares `Button` API,
|
|
192
|
+
with the exception of `href` vs `onClick` props.
|
|
193
|
+
|
|
194
|
+
```jsx live
|
|
195
|
+
<Text>
|
|
196
|
+
<ButtonLink href="#">Visually a link, with button semantics</ButtonLink>
|
|
197
|
+
</Text>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## BaseButton
|
|
201
|
+
|
|
202
|
+
Unstyled button primitive that:
|
|
203
|
+
|
|
204
|
+
- Forwards the button ref
|
|
205
|
+
- Provides a default type of `button` (so it doesn't accidently submit forms if
|
|
206
|
+
left off)
|
|
207
|
+
- Prevents `onClick` from firing when disabled without disabling the button
|
|
208
|
+
- Forces focus of the underlying button when clicked (to address a bug in
|
|
209
|
+
Safari)
|
|
210
|
+
|
|
211
|
+
## Button Props
|
|
212
|
+
|
|
213
|
+
<PropsTable displayName="Button" />
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BoxProps } from '@spark-web/box';
|
|
2
|
+
import type { MouseEvent as ReactMouseEvent } from 'react';
|
|
3
|
+
import type { NativeButtonProps } from './types';
|
|
4
|
+
export declare type BaseButtonProps = NativeButtonProps & Partial<BoxProps>;
|
|
5
|
+
export declare const BaseButton: import("react").ForwardRefExoticComponent<NativeButtonProps & Partial<BoxProps> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
/**
|
|
7
|
+
* handle "disabled" behaviour w/o disabling buttons
|
|
8
|
+
* @see https://axesslab.com/disabled-buttons-suck/
|
|
9
|
+
*/
|
|
10
|
+
export declare function getPreventableClickHandler(onClick: BaseButtonProps['onClick'], disabled: boolean): (event: ReactMouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { CommonButtonProps, NativeButtonProps } from './types';
|
|
3
|
+
export declare type ButtonProps = CommonButtonProps & {
|
|
4
|
+
/**
|
|
5
|
+
* Identifies the element (or elements) whose contents or presence
|
|
6
|
+
* are controlled by the current element.
|
|
7
|
+
*/
|
|
8
|
+
'aria-controls'?: NativeButtonProps['aria-controls'];
|
|
9
|
+
/** Identifies the element (or elements) that describes the object. */
|
|
10
|
+
'aria-describedby'?: NativeButtonProps['aria-describedby'];
|
|
11
|
+
/** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */
|
|
12
|
+
'aria-expanded'?: NativeButtonProps['aria-expanded'];
|
|
13
|
+
/** When true, prevents onClick from firing. */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** When true, the button will display a loading spinner. */
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
/** Function to be fired following a click event of the button. Only applicable for Button. */
|
|
18
|
+
onClick?: NativeButtonProps['onClick'];
|
|
19
|
+
/** The size of the button. */
|
|
20
|
+
size?: CommonButtonProps['size'];
|
|
21
|
+
/** Provide an alternate type if the button is within a form. */
|
|
22
|
+
type?: 'button' | 'submit' | 'reset';
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Buttons are used to initialize an action, their label should express what
|
|
26
|
+
* action will occur when the user interacts with it.
|
|
27
|
+
*/
|
|
28
|
+
export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { LinkComponentProps } from '@spark-web/link';
|
|
3
|
+
import type { CommonButtonProps } from './types';
|
|
4
|
+
export declare type ButtonLinkProps = LinkComponentProps & CommonButtonProps;
|
|
5
|
+
/** The appearance of a `Button`, with the semantics of a link. */
|
|
6
|
+
export declare const ButtonLink: <Comp extends import("react").ElementType<any> = "a">(props: {
|
|
7
|
+
as?: Comp | undefined;
|
|
8
|
+
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" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | "set" | 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" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | "set">)[Comp] : Comp extends new (...args: any) => any ? InstanceType<Comp> : undefined> | undefined;
|
|
9
|
+
} & Omit<import("react").PropsWithoutRef<import("react").ComponentProps<Comp>>, "as"> & ButtonLinkProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { BaseButton } from './BaseButton';
|
|
2
|
+
export { Button } from './Button';
|
|
3
|
+
export { ButtonLink } from './ButtonLink';
|
|
4
|
+
export { useButtonStyles } from './useButtonStyles';
|
|
5
|
+
export type { BaseButtonProps } from './BaseButton';
|
|
6
|
+
export type { ButtonProps } from './Button';
|
|
7
|
+
export type { ButtonLinkProps } from './ButtonLink';
|
|
8
|
+
export type { UseButtonStylesProps } from './useButtonStyles';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ButtonChildrenProps, ButtonProminence, ButtonSize, ButtonTone } from './types';
|
|
3
|
+
declare type ResolveButtonChildren = ButtonChildrenProps & {
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
prominence: ButtonProminence;
|
|
6
|
+
size: ButtonSize;
|
|
7
|
+
tone: ButtonTone;
|
|
8
|
+
};
|
|
9
|
+
export declare const resolveButtonChildren: ({ children, isLoading, prominence, size, tone, }: ResolveButtonChildren) => JSX.Element[];
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { BackgroundTone } from '@spark-web/a11y';
|
|
2
|
+
import type { IconProps } from '@spark-web/icon';
|
|
3
|
+
import type { DataAttributeMap } from '@spark-web/utils/internal';
|
|
4
|
+
import type { ButtonHTMLAttributes, ReactElement } from 'react';
|
|
5
|
+
import type { mapTokens } from './utils';
|
|
6
|
+
export declare type ButtonSize = keyof typeof mapTokens[keyof typeof mapTokens];
|
|
7
|
+
export declare type ButtonProminence = 'high' | 'low' | 'none';
|
|
8
|
+
export declare type ButtonTone = Exclude<BackgroundTone, 'disabled'>;
|
|
9
|
+
declare type ChildrenWithText = {
|
|
10
|
+
label?: never;
|
|
11
|
+
children: string | number | [ReactElement<IconProps>, string | number] | [string | number, ReactElement<IconProps>];
|
|
12
|
+
};
|
|
13
|
+
declare type IconOnly = {
|
|
14
|
+
/**
|
|
15
|
+
* Implicit label for buttons only required for icon-only buttons
|
|
16
|
+
* for accessibility reasons.
|
|
17
|
+
*/
|
|
18
|
+
label: string;
|
|
19
|
+
children: ReactElement<IconProps>;
|
|
20
|
+
};
|
|
21
|
+
export declare type ButtonChildrenProps = ChildrenWithText | IconOnly;
|
|
22
|
+
export declare type NativeButtonProps = ButtonHTMLAttributes<HTMLButtonElement>;
|
|
23
|
+
export declare type CommonButtonProps = {
|
|
24
|
+
/** Allows setting of data attributes on the underlying element. */
|
|
25
|
+
data?: DataAttributeMap;
|
|
26
|
+
/** Unique identifier for the underlying element. */
|
|
27
|
+
id?: string;
|
|
28
|
+
} & ButtonChildrenProps & ButtonStyleProps;
|
|
29
|
+
export declare type ButtonStyleProps = {
|
|
30
|
+
/** Sets the visual prominence of the button. */
|
|
31
|
+
prominence?: ButtonProminence;
|
|
32
|
+
/** Sets the size of the button. */
|
|
33
|
+
size?: ButtonSize;
|
|
34
|
+
/** Sets the tone of the button. */
|
|
35
|
+
tone?: ButtonTone;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { ButtonProminence, ButtonSize, ButtonTone } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* useButtonStyles
|
|
4
|
+
*
|
|
5
|
+
* Custom hook for styling buttons and certain links.
|
|
6
|
+
* Returns a tuple where the first item is an object of props to spread onto the
|
|
7
|
+
* underlying `Box` component, and the second item is a CSS object that can be
|
|
8
|
+
* passed to Emotion's `css` function.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useButtonStyles({ iconOnly, prominence, size, tone, }: UseButtonStylesProps): readonly [{
|
|
11
|
+
readonly alignItems: "center";
|
|
12
|
+
readonly background: "body" | "input" | "infoLight" | "criticalLight" | "positiveLight" | "cautionLight" | "muted" | "disabled" | "backdrop" | "surface" | "surfaceMuted" | "surfacePressed" | "fieldAccent" | "inputPressed" | "inputDisabled" | "accent" | "accentMuted" | "neutral" | "neutralLow" | "primary" | "primaryLow" | "primaryMuted" | "secondary" | "secondaryLow" | "secondaryMuted" | "caution" | "cautionLow" | "cautionMuted" | "critical" | "criticalLow" | "criticalMuted" | "info" | "infoLow" | "infoMuted" | "positive" | "positiveLow" | "positiveMuted" | undefined;
|
|
13
|
+
readonly border: import("@spark-web/theme").ResponsiveProp<"standard" | "fieldAccent" | "accent" | "accentMuted" | "neutral" | "primary" | "secondary" | "caution" | "cautionMuted" | "critical" | "criticalMuted" | "info" | "infoMuted" | "positive" | "positiveMuted" | "standardInverted" | "field" | "fieldHover" | "fieldDisabled" | "primaryHover" | "primaryActive" | "secondaryHover" | "secondaryActive"> | undefined;
|
|
14
|
+
readonly borderWidth: import("@spark-web/theme").ResponsiveProp<"standard" | "large"> | undefined;
|
|
15
|
+
readonly borderRadius: "small" | "medium";
|
|
16
|
+
readonly cursor: "pointer";
|
|
17
|
+
readonly display: "inline-flex";
|
|
18
|
+
readonly gap: "small";
|
|
19
|
+
readonly height: "large" | "medium";
|
|
20
|
+
readonly justifyContent: "center";
|
|
21
|
+
readonly paddingX: "medium" | "xlarge" | undefined;
|
|
22
|
+
readonly position: "relative";
|
|
23
|
+
readonly width: "large" | "medium" | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
readonly '&:not([aria-disabled=true])': {
|
|
26
|
+
readonly ':hover': {
|
|
27
|
+
readonly borderColor: string | undefined;
|
|
28
|
+
readonly backgroundColor: string | undefined;
|
|
29
|
+
readonly '> *': {
|
|
30
|
+
readonly color: string | undefined;
|
|
31
|
+
readonly stroke: string | undefined;
|
|
32
|
+
readonly transitionProperty: string;
|
|
33
|
+
readonly transitionTimingFunction: string;
|
|
34
|
+
readonly transitionDuration: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
readonly ':active': {
|
|
38
|
+
readonly borderColor: string | undefined;
|
|
39
|
+
readonly backgroundColor: string | undefined;
|
|
40
|
+
readonly transform: "scale(0.98)";
|
|
41
|
+
readonly '> *': {
|
|
42
|
+
readonly color: string | undefined;
|
|
43
|
+
readonly stroke: string | undefined;
|
|
44
|
+
readonly transitionProperty: string;
|
|
45
|
+
readonly transitionTimingFunction: string;
|
|
46
|
+
readonly transitionDuration: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
readonly ':focus': {
|
|
50
|
+
boxShadow: string;
|
|
51
|
+
outline: string;
|
|
52
|
+
outlineOffset: string;
|
|
53
|
+
} | {
|
|
54
|
+
outline: string;
|
|
55
|
+
outlineOffset: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
readonly '&[aria-disabled=true]': {
|
|
59
|
+
readonly backgroundColor: string | undefined;
|
|
60
|
+
readonly borderColor: string | undefined;
|
|
61
|
+
readonly cursor: "default";
|
|
62
|
+
readonly '*': {
|
|
63
|
+
readonly color: string | undefined;
|
|
64
|
+
readonly stroke: string | undefined;
|
|
65
|
+
};
|
|
66
|
+
readonly ':focus': {
|
|
67
|
+
boxShadow: string;
|
|
68
|
+
outline: string;
|
|
69
|
+
outlineOffset: string;
|
|
70
|
+
} | {
|
|
71
|
+
outline: string;
|
|
72
|
+
outlineOffset: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
readonly transitionProperty: string;
|
|
76
|
+
readonly transitionTimingFunction: string;
|
|
77
|
+
readonly transitionDuration: string;
|
|
78
|
+
}];
|
|
79
|
+
export declare type UseButtonStylesProps = {
|
|
80
|
+
/** Whether the children of the button is a single icon or not. */
|
|
81
|
+
iconOnly: boolean;
|
|
82
|
+
/** Sets the visual prominence of the button. */
|
|
83
|
+
prominence: ButtonProminence;
|
|
84
|
+
/** Sets the size of the button. */
|
|
85
|
+
size: ButtonSize;
|
|
86
|
+
/** Sets the tone of the button. */
|
|
87
|
+
tone: ButtonTone;
|
|
88
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { BoxProps } from '@spark-web/box';
|
|
2
|
+
import type { ForegroundTone } from '@spark-web/text';
|
|
3
|
+
import type { BrighteTheme } from '@spark-web/theme';
|
|
4
|
+
import type { ButtonProminence, ButtonTone } from './types';
|
|
5
|
+
declare type BaseButtonStyles = {
|
|
6
|
+
background: BoxProps['background'];
|
|
7
|
+
border?: BoxProps['border'];
|
|
8
|
+
borderWidth?: BoxProps['borderWidth'];
|
|
9
|
+
textTone?: ForegroundTone;
|
|
10
|
+
};
|
|
11
|
+
declare type HoverButtonStyles = {
|
|
12
|
+
backgroundHover: keyof BrighteTheme['backgroundInteractions'];
|
|
13
|
+
borderHover?: keyof BrighteTheme['border']['color'];
|
|
14
|
+
textToneHover?: keyof BrighteTheme['color']['foreground'];
|
|
15
|
+
};
|
|
16
|
+
declare type ActiveButtonStyles = {
|
|
17
|
+
backgroundActive: keyof BrighteTheme['backgroundInteractions'];
|
|
18
|
+
borderActive?: keyof BrighteTheme['border']['color'];
|
|
19
|
+
textToneActive?: keyof BrighteTheme['color']['foreground'];
|
|
20
|
+
};
|
|
21
|
+
declare type DisabledButtonStyles = {
|
|
22
|
+
backgroundDisabled: keyof BrighteTheme['color']['background'];
|
|
23
|
+
borderDisabled?: keyof BrighteTheme['border']['color'];
|
|
24
|
+
textToneDisabled: keyof BrighteTheme['color']['foreground'];
|
|
25
|
+
};
|
|
26
|
+
declare type ButtonStyles = BaseButtonStyles & HoverButtonStyles & ActiveButtonStyles & DisabledButtonStyles;
|
|
27
|
+
declare type Variants = Record<ButtonProminence, Record<ButtonTone, ButtonStyles | undefined>>;
|
|
28
|
+
export declare const variants: Variants;
|
|
29
|
+
export declare const mapTokens: {
|
|
30
|
+
readonly fontSize: {
|
|
31
|
+
readonly medium: "small";
|
|
32
|
+
readonly large: "standard";
|
|
33
|
+
};
|
|
34
|
+
readonly size: {
|
|
35
|
+
readonly medium: "medium";
|
|
36
|
+
readonly large: "large";
|
|
37
|
+
};
|
|
38
|
+
readonly spacing: {
|
|
39
|
+
readonly medium: "medium";
|
|
40
|
+
readonly large: "xlarge";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./declarations/src/index";
|