@carrier-dpx/air-react-library 0.2.2 → 0.4.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/README.md +65 -0
- package/package.json +1 -1
- package/src/components/TextField/TextField.figma.tsx +76 -0
- package/src/components/TextField/TextField.tsx +253 -0
- package/src/components/TextField/index.ts +3 -0
- package/src/components/Typography/Typography.figma.tsx +66 -0
- package/src/components/Typography/Typography.tsx +17 -0
- package/src/components/Typography/index.ts +2 -0
- package/src/components/Typography/types.ts +185 -0
- package/src/components/utils/HeightUtils.ts +38 -0
- package/src/index.ts +4 -0
package/README.md
CHANGED
|
@@ -80,6 +80,69 @@ function App() {
|
|
|
80
80
|
- `onClick`: `() => void` - Click handler
|
|
81
81
|
- All standard Material-UI Button props
|
|
82
82
|
|
|
83
|
+
### Typography Component
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { Typography } from '@carrier-dpx/air-react-library';
|
|
87
|
+
|
|
88
|
+
function App() {
|
|
89
|
+
return (
|
|
90
|
+
<>
|
|
91
|
+
<Typography variant="h1">Heading 1</Typography>
|
|
92
|
+
<Typography variant="body1">Regular body text</Typography>
|
|
93
|
+
<Typography variant="body1Semibold">Semibold body text</Typography>
|
|
94
|
+
<Typography variant="caps2">UPPERCASE TEXT</Typography>
|
|
95
|
+
</>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### Available Typography Variants
|
|
101
|
+
|
|
102
|
+
- **Headings**: `h1`, `h2`, `h3`, `h4`, `h5`, `h6`
|
|
103
|
+
- **Body**: `body1`, `body1Semibold`, `body1Bold`, `body2`, `body2Semibold`, `body2Bold`, `body3`, `body3Semibold`, `body3Bold`
|
|
104
|
+
- **Caps**: `caps1`, `caps1Bold`, `caps2`, `caps2Bold`, `caps3`, `caps3Bold`, `caps4`, `caps4Bold`
|
|
105
|
+
- All standard Material-UI Typography props
|
|
106
|
+
|
|
107
|
+
### TextField Component
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
import { TextField } from '@carrier-dpx/air-react-library';
|
|
111
|
+
|
|
112
|
+
function App() {
|
|
113
|
+
return (
|
|
114
|
+
<>
|
|
115
|
+
<TextField
|
|
116
|
+
label="Email"
|
|
117
|
+
placeholder="Enter your email"
|
|
118
|
+
size="large"
|
|
119
|
+
showBorder
|
|
120
|
+
/>
|
|
121
|
+
<TextField
|
|
122
|
+
label="Password"
|
|
123
|
+
type="password"
|
|
124
|
+
placeholder="Enter your password"
|
|
125
|
+
size="large"
|
|
126
|
+
error
|
|
127
|
+
helperText="Password is required"
|
|
128
|
+
/>
|
|
129
|
+
</>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### Available TextField Props
|
|
135
|
+
|
|
136
|
+
- **size**: `xlarge`, `large` (default), `medium`, `small`
|
|
137
|
+
- **color**: `primary`, `error`, `success`, `warning`, `info`
|
|
138
|
+
- **error**: `boolean` - Shows error state
|
|
139
|
+
- **disabled**: `boolean` - Disables the field
|
|
140
|
+
- **showBorder**: `boolean` - Shows border around field
|
|
141
|
+
- **hideBackgroundColor**: `boolean` - Removes background color
|
|
142
|
+
- **characterCounter**: `boolean` - Shows character count
|
|
143
|
+
- **characterMax**: `number` - Max character limit
|
|
144
|
+
- All standard Material-UI TextField props
|
|
145
|
+
|
|
83
146
|
## Figma Integration
|
|
84
147
|
|
|
85
148
|
This library is integrated with Figma Code Connect. When using Figma Make, components from this library will be automatically suggested and used in generated code.
|
|
@@ -89,6 +152,8 @@ This library is integrated with Figma Code Connect. When using Figma Make, compo
|
|
|
89
152
|
Currently available components:
|
|
90
153
|
|
|
91
154
|
- **Button** - Material-UI based button component with Carrier DPX design system styling
|
|
155
|
+
- **Typography** - Text component with all Carrier DPX typography variants (h1-h6, body1-3, caps, etc.)
|
|
156
|
+
- **TextField** - Input field component with Carrier DPX styling (supports multiple sizes, colors, validation states)
|
|
92
157
|
|
|
93
158
|
More components coming soon!
|
|
94
159
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Figma Code Connect Configuration for TextField Component
|
|
3
|
+
*
|
|
4
|
+
* Maps Figma TextField component to React TextField component
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import figma from "@figma/code-connect";
|
|
8
|
+
import TextField from "./TextField";
|
|
9
|
+
|
|
10
|
+
figma.connect(
|
|
11
|
+
TextField,
|
|
12
|
+
"https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=18128-89412",
|
|
13
|
+
{
|
|
14
|
+
props: {
|
|
15
|
+
/**
|
|
16
|
+
* SIZE MAPPING
|
|
17
|
+
* Maps Figma size format (with px values) to React size prop
|
|
18
|
+
*/
|
|
19
|
+
size: figma.enum("size", {
|
|
20
|
+
"xlarge-56px": "xlarge",
|
|
21
|
+
"large-48px": "large",
|
|
22
|
+
"medium-40px": "medium",
|
|
23
|
+
"small-32px": "small",
|
|
24
|
+
}),
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* COLOR MAPPING
|
|
28
|
+
* Maps Figma color variants to React color prop
|
|
29
|
+
*/
|
|
30
|
+
color: figma.enum("color", {
|
|
31
|
+
primary: "primary",
|
|
32
|
+
error: "error",
|
|
33
|
+
success: "success",
|
|
34
|
+
warning: "warning",
|
|
35
|
+
info: "info",
|
|
36
|
+
}),
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* ERROR STATE
|
|
40
|
+
* Maps Figma error boolean to React error prop
|
|
41
|
+
*/
|
|
42
|
+
error: figma.boolean("error"),
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* DISABLED STATE
|
|
46
|
+
* Maps Figma disabled boolean to React disabled prop
|
|
47
|
+
*/
|
|
48
|
+
disabled: figma.boolean("disabled"),
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* SHOW BORDER
|
|
52
|
+
* Maps Figma showBorder boolean to React showBorder prop
|
|
53
|
+
*/
|
|
54
|
+
showBorder: figma.boolean("showBorder"),
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* CODE EXAMPLE TEMPLATE
|
|
59
|
+
*
|
|
60
|
+
* Shows how TextField should be used in React code
|
|
61
|
+
* Note: label, placeholder, value, onChange etc. are runtime props
|
|
62
|
+
* that aren't configured in Figma's static component
|
|
63
|
+
*/
|
|
64
|
+
example: ({ size, color, error, disabled, showBorder }) => (
|
|
65
|
+
<TextField
|
|
66
|
+
size={size}
|
|
67
|
+
color={color}
|
|
68
|
+
error={error}
|
|
69
|
+
disabled={disabled}
|
|
70
|
+
showBorder={showBorder}
|
|
71
|
+
label="Email"
|
|
72
|
+
placeholder="Enter your email"
|
|
73
|
+
/>
|
|
74
|
+
),
|
|
75
|
+
}
|
|
76
|
+
);
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { forwardRef, useState, ChangeEvent } from "react";
|
|
2
|
+
|
|
3
|
+
import MuiTextField, {
|
|
4
|
+
StandardTextFieldProps as MuiTextFieldProps,
|
|
5
|
+
} from "@mui/material/TextField";
|
|
6
|
+
import { InputProps } from "@mui/material/Input";
|
|
7
|
+
import { InputMaxHeightMap } from "../utils/HeightUtils";
|
|
8
|
+
import { getSxStyles } from "../utils/styles";
|
|
9
|
+
import { CSSObject } from "@mui/material";
|
|
10
|
+
import { fleetPalette } from "../theme";
|
|
11
|
+
import { styleTokens } from "../theme/constants/styleTokens";
|
|
12
|
+
|
|
13
|
+
declare module "@mui/material/TextField" {
|
|
14
|
+
interface TextFieldPropsSizeOverrides {
|
|
15
|
+
xlarge: true;
|
|
16
|
+
large: true;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export interface TextFieldInputProps
|
|
20
|
+
extends Omit<InputProps, "disableUnderline"> {}
|
|
21
|
+
|
|
22
|
+
export interface TextFieldProps
|
|
23
|
+
extends Omit<
|
|
24
|
+
MuiTextFieldProps,
|
|
25
|
+
"variant" | "margin" | "classes" | "hiddenLabel"
|
|
26
|
+
> {
|
|
27
|
+
/** Set to true to remove background color. */
|
|
28
|
+
hideBackgroundColor?: boolean;
|
|
29
|
+
|
|
30
|
+
/** Input Node for Child Input. */
|
|
31
|
+
inputSetting?: TextFieldInputProps;
|
|
32
|
+
|
|
33
|
+
// Renamed 'hiddenLabel' to hideLabel for consistency.
|
|
34
|
+
/**
|
|
35
|
+
* If `true`, the label is hidden.
|
|
36
|
+
* This is used to increase density for a `FilledInput`.
|
|
37
|
+
* Be sure to add `aria-label` to the `input` element.
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
hideLabel?: boolean;
|
|
41
|
+
|
|
42
|
+
/** Set to true to show a border around the TextField.*/
|
|
43
|
+
showBorder?: boolean;
|
|
44
|
+
|
|
45
|
+
/** Toggles the counter visibility. Setting to `true` will display the counter and respect the characterMax if set. `false` will hide the counter and ignore `characterMax`.
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
characterCounter?: boolean;
|
|
49
|
+
|
|
50
|
+
/** Sets a counter character limit while `characterCounter` is enabled. */
|
|
51
|
+
characterMax?: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The TextField component allows users to enter or edit free-form text data.
|
|
55
|
+
*
|
|
56
|
+
* `import TextField from '@carrier-io/air-react/TextField'`
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
const TextField = forwardRef<HTMLDivElement, TextFieldProps>(
|
|
60
|
+
(
|
|
61
|
+
{
|
|
62
|
+
hideBackgroundColor = false,
|
|
63
|
+
inputSetting = {},
|
|
64
|
+
InputProps = {},
|
|
65
|
+
label,
|
|
66
|
+
showBorder = false,
|
|
67
|
+
size = "large",
|
|
68
|
+
type = "text",
|
|
69
|
+
sx = {},
|
|
70
|
+
hideLabel,
|
|
71
|
+
InputLabelProps = {},
|
|
72
|
+
FormHelperTextProps = {},
|
|
73
|
+
helperText,
|
|
74
|
+
characterCounter,
|
|
75
|
+
characterMax,
|
|
76
|
+
defaultValue,
|
|
77
|
+
onChange,
|
|
78
|
+
...rest
|
|
79
|
+
},
|
|
80
|
+
ref
|
|
81
|
+
) => {
|
|
82
|
+
const [value, setValue] = useState<string | number>(
|
|
83
|
+
defaultValue as string | number
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const handleChange = (event: ChangeEvent) => {
|
|
87
|
+
const targetValue = (event.target as HTMLInputElement).value;
|
|
88
|
+
if (
|
|
89
|
+
characterCounter &&
|
|
90
|
+
characterMax &&
|
|
91
|
+
targetValue?.length > characterMax
|
|
92
|
+
) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (onChange) {
|
|
96
|
+
onChange(event as ChangeEvent<HTMLInputElement>);
|
|
97
|
+
}
|
|
98
|
+
setValue(targetValue);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const joinInputLabelProps = {
|
|
102
|
+
sx: {
|
|
103
|
+
...(showBorder ? { paddingLeft: "2px" } : { paddingLeft: "0px" }),
|
|
104
|
+
"& .MuiInputLabel-asterisk": {
|
|
105
|
+
color: fleetPalette.base?.filledInput.required,
|
|
106
|
+
},
|
|
107
|
+
"&.Mui-focused .MuiInputLabel-asterisk": {
|
|
108
|
+
color: "inherit",
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
...InputLabelProps.sx,
|
|
112
|
+
},
|
|
113
|
+
...InputLabelProps,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const joinFormHelperTextProps: typeof FormHelperTextProps = {
|
|
117
|
+
sx: {
|
|
118
|
+
whiteSpace: "nowrap",
|
|
119
|
+
overflow: "hidden",
|
|
120
|
+
textOverflow: "ellipsis",
|
|
121
|
+
m: "2px",
|
|
122
|
+
pl: "2px",
|
|
123
|
+
...FormHelperTextProps.sx,
|
|
124
|
+
},
|
|
125
|
+
...FormHelperTextProps,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const input = {
|
|
129
|
+
...InputProps,
|
|
130
|
+
...inputSetting,
|
|
131
|
+
disableUnderline: true,
|
|
132
|
+
size: size,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const inputSx = input.sx;
|
|
136
|
+
|
|
137
|
+
input.sx = (theme) =>
|
|
138
|
+
({
|
|
139
|
+
...getSxStyles(theme, inputSx),
|
|
140
|
+
// Conditionally apply properties
|
|
141
|
+
...(!rest.multiline && { height: InputMaxHeightMap[size] }),
|
|
142
|
+
...(!showBorder && !rest.error && { border: "0px!important" }),
|
|
143
|
+
...(hideBackgroundColor && { backgroundColor: "inherit!important" }),
|
|
144
|
+
borderRadius: `${styleTokens.borderRadius.large}`,
|
|
145
|
+
"&.MuiInputBase-root": {
|
|
146
|
+
"&:hover": {
|
|
147
|
+
backgroundColor: `${fleetPalette.base?.filledInput.backgroundHover} !important`,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
} as CSSObject);
|
|
151
|
+
|
|
152
|
+
const getHelperText = () => {
|
|
153
|
+
return (
|
|
154
|
+
<>
|
|
155
|
+
{helperText}
|
|
156
|
+
{characterCounter && (
|
|
157
|
+
<span
|
|
158
|
+
style={{
|
|
159
|
+
float: "right",
|
|
160
|
+
padding: `0px 2px`,
|
|
161
|
+
}}
|
|
162
|
+
>
|
|
163
|
+
{value ? value?.toString().length : "0"}
|
|
164
|
+
{!!characterMax && `/${characterMax}`}
|
|
165
|
+
</span>
|
|
166
|
+
)}
|
|
167
|
+
</>
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
let largeSizeLabelValue: string | number;
|
|
172
|
+
if (size === "large") {
|
|
173
|
+
largeSizeLabelValue = "16px";
|
|
174
|
+
} else if (size === "xlarge") {
|
|
175
|
+
largeSizeLabelValue = "24px";
|
|
176
|
+
} else {
|
|
177
|
+
largeSizeLabelValue = 0;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const largeSizeLabelSX = {
|
|
181
|
+
"& .MuiFormLabel-root": {
|
|
182
|
+
lineHeight: largeSizeLabelValue,
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<MuiTextField
|
|
188
|
+
variant="filled"
|
|
189
|
+
type={type}
|
|
190
|
+
margin={size === "medium" ? "dense" : "none"}
|
|
191
|
+
color={rest.error ? "error" : rest.color}
|
|
192
|
+
hiddenLabel={size === "small" || size === "medium" || hideLabel}
|
|
193
|
+
InputProps={input}
|
|
194
|
+
InputLabelProps={joinInputLabelProps}
|
|
195
|
+
FormHelperTextProps={joinFormHelperTextProps}
|
|
196
|
+
helperText={getHelperText()}
|
|
197
|
+
onChange={handleChange}
|
|
198
|
+
value={value}
|
|
199
|
+
sx={(theme) =>
|
|
200
|
+
({
|
|
201
|
+
...getSxStyles(theme, sx),
|
|
202
|
+
"& .MuiInputBase-root.MuiFilledInput-root": {
|
|
203
|
+
borderRadius: `${styleTokens.borderRadius.large}`,
|
|
204
|
+
"& .MuiInputBase-input::placeholder": {
|
|
205
|
+
color: fleetPalette.base?.filledInput.placeholderLabel,
|
|
206
|
+
},
|
|
207
|
+
"& .MuiInputBase-input.MuiFilledInput-input::-webkit-input-placeholder":
|
|
208
|
+
{
|
|
209
|
+
opacity: "unset",
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
...((size === "large" || size === "xlarge") && largeSizeLabelSX),
|
|
214
|
+
"& .MuiInputBase-root.Mui-focused": {
|
|
215
|
+
backgroundColor:
|
|
216
|
+
fleetPalette.base?.background.paper + " !important",
|
|
217
|
+
...((rest.error === false || rest.error === undefined) && {
|
|
218
|
+
"&.MuiInputBase-colorPrimary": {
|
|
219
|
+
border: `1px solid ${theme.palette.primary.main} !important`,
|
|
220
|
+
},
|
|
221
|
+
"&.MuiInputBase-colorSecondary": {
|
|
222
|
+
border: `1px solid ${theme.palette.secondary.main} !important`,
|
|
223
|
+
},
|
|
224
|
+
"&.MuiInputBase-colorBase": {
|
|
225
|
+
border: `1px solid ${theme.palette.base?.main} !important`,
|
|
226
|
+
},
|
|
227
|
+
"&.MuiInputBase-colorWarning": {
|
|
228
|
+
border: `1px solid ${theme.palette.warning.main} !important`,
|
|
229
|
+
},
|
|
230
|
+
"&.MuiInputBase-colorSuccess": {
|
|
231
|
+
border: `1px solid ${theme.palette.success.main} !important`,
|
|
232
|
+
},
|
|
233
|
+
"&.MuiInputBase-colorInfo": {
|
|
234
|
+
border: `1px solid ${theme.palette.info.main} !important`,
|
|
235
|
+
},
|
|
236
|
+
"&.MuiInputBase-colorError": {
|
|
237
|
+
border: `1px solid ${theme.palette.error.main} !important`,
|
|
238
|
+
},
|
|
239
|
+
}),
|
|
240
|
+
},
|
|
241
|
+
} as CSSObject)
|
|
242
|
+
}
|
|
243
|
+
label={!(size === "small" || size === "medium" || hideLabel) && label}
|
|
244
|
+
{...rest}
|
|
245
|
+
ref={ref}
|
|
246
|
+
/>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
TextField.displayName = "TextField";
|
|
252
|
+
|
|
253
|
+
export default TextField;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Figma Code Connect Configuration for Typography Component
|
|
3
|
+
*
|
|
4
|
+
* Maps Figma Typography component to React Typography component
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import figma from "@figma/code-connect";
|
|
8
|
+
import Typography from "./Typography";
|
|
9
|
+
|
|
10
|
+
figma.connect(
|
|
11
|
+
Typography,
|
|
12
|
+
"https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=10984-58055",
|
|
13
|
+
{
|
|
14
|
+
props: {
|
|
15
|
+
/**
|
|
16
|
+
* VARIANT MAPPING
|
|
17
|
+
* Maps Figma's "variant" property to React's "variant" prop
|
|
18
|
+
*
|
|
19
|
+
* Figma variant names with spaces need to be converted to camelCase for React
|
|
20
|
+
*/
|
|
21
|
+
variant: figma.enum("variant", {
|
|
22
|
+
body1: "body1",
|
|
23
|
+
"body1 semibold": "body1Semibold",
|
|
24
|
+
"body1 bold": "body1Bold",
|
|
25
|
+
body2: "body2",
|
|
26
|
+
"body2 semibold": "body2Semibold",
|
|
27
|
+
"body2 bold": "body2Bold",
|
|
28
|
+
body3: "body3",
|
|
29
|
+
"body3 semibold": "body3Semibold",
|
|
30
|
+
"body3 bold": "body3Bold",
|
|
31
|
+
h1: "h1",
|
|
32
|
+
h2: "h2",
|
|
33
|
+
h3: "h3",
|
|
34
|
+
h4: "h4",
|
|
35
|
+
h5: "h5",
|
|
36
|
+
h6: "h6",
|
|
37
|
+
caps1: "caps1",
|
|
38
|
+
"caps1 bold": "caps1Bold",
|
|
39
|
+
caps2: "caps2",
|
|
40
|
+
"caps2 bold": "caps2Bold",
|
|
41
|
+
caps3: "caps3",
|
|
42
|
+
"caps3 bold": "caps3Bold",
|
|
43
|
+
caps4: "caps4",
|
|
44
|
+
"caps4 bold": "caps4Bold",
|
|
45
|
+
}),
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* TEXT CONTENT
|
|
49
|
+
* Maps the text content from Figma's "Label" layer
|
|
50
|
+
* This is the editable text in the Typography component
|
|
51
|
+
*/
|
|
52
|
+
children: figma.children("Label"),
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* CODE EXAMPLE TEMPLATE
|
|
57
|
+
*
|
|
58
|
+
* Shows how the Typography component should be used in React code
|
|
59
|
+
*/
|
|
60
|
+
example: ({ variant, children }) => (
|
|
61
|
+
<Typography variant={variant}>
|
|
62
|
+
{children}
|
|
63
|
+
</Typography>
|
|
64
|
+
),
|
|
65
|
+
}
|
|
66
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import MuiTypography from "@mui/material/Typography";
|
|
3
|
+
import { TypographyProps } from "./types";
|
|
4
|
+
|
|
5
|
+
/** The Typography component provides access to available font variations within the FDS theme and is useful for creating content hierarchy and instance swapping.
|
|
6
|
+
*
|
|
7
|
+
* `import Typography from '@carrier-io/air-react/Typography'`
|
|
8
|
+
*/
|
|
9
|
+
const Typography = forwardRef<HTMLSpanElement, TypographyProps>(
|
|
10
|
+
(props, ref) => {
|
|
11
|
+
return <MuiTypography {...props} ref={ref} />;
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
Typography.displayName = "Typography";
|
|
16
|
+
|
|
17
|
+
export default Typography;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { ElementType, CSSProperties } from "react";
|
|
2
|
+
import { ResponsiveStyleValue, AllSystemCSSProperties } from "@mui/system";
|
|
3
|
+
import { TypographyProps as MuiTypographyProps } from "@mui/material/Typography";
|
|
4
|
+
|
|
5
|
+
export interface AdditionalTypographyVariants {
|
|
6
|
+
body3: CSSProperties;
|
|
7
|
+
buttonLarge: CSSProperties;
|
|
8
|
+
buttonMedium: CSSProperties;
|
|
9
|
+
buttonSmall: CSSProperties;
|
|
10
|
+
avatarLetter: CSSProperties;
|
|
11
|
+
inputText1: CSSProperties;
|
|
12
|
+
inputText2: CSSProperties;
|
|
13
|
+
alertTitle: CSSProperties;
|
|
14
|
+
tableHeader1: CSSProperties;
|
|
15
|
+
tableHeader2: CSSProperties;
|
|
16
|
+
inputLabel: CSSProperties;
|
|
17
|
+
chip: CSSProperties;
|
|
18
|
+
helperText: CSSProperties;
|
|
19
|
+
badge: CSSProperties;
|
|
20
|
+
tooltip: CSSProperties;
|
|
21
|
+
body1Semibold: CSSProperties;
|
|
22
|
+
body1Bold: CSSProperties;
|
|
23
|
+
body2Semibold: CSSProperties;
|
|
24
|
+
body2Bold: CSSProperties;
|
|
25
|
+
body3Semibold: CSSProperties;
|
|
26
|
+
body3Bold: CSSProperties;
|
|
27
|
+
caps1: CSSProperties;
|
|
28
|
+
caps1Bold: CSSProperties;
|
|
29
|
+
caps2: CSSProperties;
|
|
30
|
+
caps2Bold: CSSProperties;
|
|
31
|
+
caps3: CSSProperties;
|
|
32
|
+
caps3Bold: CSSProperties;
|
|
33
|
+
caps4: CSSProperties;
|
|
34
|
+
caps4Bold: CSSProperties;
|
|
35
|
+
body4Semibold: CSSProperties;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ExtraTypographyFontWeightOptions {
|
|
39
|
+
fontWeightExtraLight?: CSSProperties["fontWeight"];
|
|
40
|
+
fontWeightSemiBold?: CSSProperties["fontWeight"];
|
|
41
|
+
fontWeightExtraBold?: CSSProperties["fontWeight"];
|
|
42
|
+
fontWeightBlack?: CSSProperties["fontWeight"];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type UnnecessaryTypographyVariants = "button";
|
|
46
|
+
|
|
47
|
+
export type CustomTypographyVariant =
|
|
48
|
+
| "body3"
|
|
49
|
+
| "buttonLarge"
|
|
50
|
+
| "buttonMedium"
|
|
51
|
+
| "buttonSmall"
|
|
52
|
+
| "avatarLetter"
|
|
53
|
+
| "inputLabel"
|
|
54
|
+
| "chip"
|
|
55
|
+
| "helperText"
|
|
56
|
+
| "badge"
|
|
57
|
+
| "tooltip"
|
|
58
|
+
| "inputText1"
|
|
59
|
+
| "inputText2"
|
|
60
|
+
| "alertTitle"
|
|
61
|
+
| "tableHeader1"
|
|
62
|
+
| "tableHeader2"
|
|
63
|
+
| "body1Semibold"
|
|
64
|
+
| "body1Bold"
|
|
65
|
+
| "body2Semibold"
|
|
66
|
+
| "body2Bold"
|
|
67
|
+
| "body3Semibold"
|
|
68
|
+
| "body3Bold"
|
|
69
|
+
| "caps1"
|
|
70
|
+
| "caps1Bold"
|
|
71
|
+
| "caps2"
|
|
72
|
+
| "caps2Bold"
|
|
73
|
+
| "caps3"
|
|
74
|
+
| "caps3Bold"
|
|
75
|
+
| "caps4"
|
|
76
|
+
| "caps4Bold"
|
|
77
|
+
| "body4Semibold";
|
|
78
|
+
|
|
79
|
+
declare module "@mui/material/styles" {
|
|
80
|
+
/**
|
|
81
|
+
* Extended TypographyVariants
|
|
82
|
+
*/
|
|
83
|
+
interface TypographyVariants
|
|
84
|
+
extends AdditionalTypographyVariants,
|
|
85
|
+
ExtraTypographyFontWeightOptions {}
|
|
86
|
+
/**
|
|
87
|
+
* Extended TypographyVariantsOptions (allow configuration using `createTheme`)
|
|
88
|
+
*/
|
|
89
|
+
interface TypographyVariantsOptions
|
|
90
|
+
extends AdditionalTypographyVariants,
|
|
91
|
+
ExtraTypographyFontWeightOptions {}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare module "@mui/material/Typography" {
|
|
95
|
+
/**
|
|
96
|
+
* Update the Typography's variant prop options
|
|
97
|
+
*/
|
|
98
|
+
interface TypographyPropsVariantOverrides {
|
|
99
|
+
body3: true;
|
|
100
|
+
button: false;
|
|
101
|
+
buttonLarge: true;
|
|
102
|
+
buttonMedium: true;
|
|
103
|
+
buttonSmall: true;
|
|
104
|
+
avatarLetter: true;
|
|
105
|
+
inputText1: true;
|
|
106
|
+
inputText2: true;
|
|
107
|
+
alertTitle: true;
|
|
108
|
+
tableHeader1: true;
|
|
109
|
+
tableHeader2: true;
|
|
110
|
+
inputLabel: true;
|
|
111
|
+
chip: true;
|
|
112
|
+
helperText: true;
|
|
113
|
+
badge: true;
|
|
114
|
+
tooltip: true;
|
|
115
|
+
body1Semibold: true;
|
|
116
|
+
body1Bold: true;
|
|
117
|
+
body2Semibold: true;
|
|
118
|
+
body2Bold: true;
|
|
119
|
+
body3Semibold: true;
|
|
120
|
+
body3Bold: true;
|
|
121
|
+
caps1: true;
|
|
122
|
+
caps1Bold: true;
|
|
123
|
+
caps2: true;
|
|
124
|
+
caps2Bold: true;
|
|
125
|
+
caps3: true;
|
|
126
|
+
caps3Bold: true;
|
|
127
|
+
caps4: true;
|
|
128
|
+
caps4Bold: true;
|
|
129
|
+
body4Semibold: true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface TypographyProps
|
|
134
|
+
extends Omit<MuiTypographyProps, "variant" | "variantMapping"> {
|
|
135
|
+
/**
|
|
136
|
+
* Applies the theme typography styles.
|
|
137
|
+
* @default 'body1'
|
|
138
|
+
*/
|
|
139
|
+
variant?:
|
|
140
|
+
| Exclude<MuiTypographyProps["variant"], UnnecessaryTypographyVariants>
|
|
141
|
+
| CustomTypographyVariant;
|
|
142
|
+
/**
|
|
143
|
+
* The component maps the variant prop to a range of different HTML element types.
|
|
144
|
+
* For instance, subtitle1 to `<h6>`.
|
|
145
|
+
* If you wish to change that mapping, you can provide your own.
|
|
146
|
+
* Alternatively, you can use the `component` prop.
|
|
147
|
+
* @default {
|
|
148
|
+
* h1: 'h1',
|
|
149
|
+
* h2: 'h2',
|
|
150
|
+
* h3: 'h3',
|
|
151
|
+
* h4: 'h4',
|
|
152
|
+
* h5: 'h5',
|
|
153
|
+
* h6: 'h6',
|
|
154
|
+
* subtitle1: 'h6',
|
|
155
|
+
* subtitle2: 'h6',
|
|
156
|
+
* body1: 'p',
|
|
157
|
+
* body2: 'p',
|
|
158
|
+
* body3: 'p',
|
|
159
|
+
* inherit: 'p',
|
|
160
|
+
* buttonLarge: "span",
|
|
161
|
+
* buttonMedium: "span",
|
|
162
|
+
* buttonSmall: "span",
|
|
163
|
+
* avatarLetter: "span",
|
|
164
|
+
* inputText1: "span",
|
|
165
|
+
* inputText2: "span",
|
|
166
|
+
* alertTitle: "span",
|
|
167
|
+
* tableHeader1: "span",
|
|
168
|
+
* tableHeader2: "span",
|
|
169
|
+
* inputLabel: "span",
|
|
170
|
+
* chip: "span",
|
|
171
|
+
* helperText: "span",
|
|
172
|
+
* badge: "span",
|
|
173
|
+
* tooltip: "span",
|
|
174
|
+
* }
|
|
175
|
+
*/
|
|
176
|
+
variantMapping?: MuiTypographyProps["variantMapping"];
|
|
177
|
+
/**
|
|
178
|
+
* The component used for the root node. Either a string to use a HTML element or a component.
|
|
179
|
+
*/
|
|
180
|
+
component?: ElementType;
|
|
181
|
+
/**
|
|
182
|
+
* Specifies how to capitalize an element's text
|
|
183
|
+
*/
|
|
184
|
+
textTransform?: ResponsiveStyleValue<AllSystemCSSProperties["textTransform"]>;
|
|
185
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const heightMap = {
|
|
2
|
+
small: 32,
|
|
3
|
+
medium: 40,
|
|
4
|
+
large: 48,
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const InputMaxHeightMap = {
|
|
8
|
+
small: 32,
|
|
9
|
+
medium: 40,
|
|
10
|
+
large: 48,
|
|
11
|
+
xlarge: 56,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const InputMaxDividerHeightMap = {
|
|
15
|
+
small: 16,
|
|
16
|
+
medium: 24,
|
|
17
|
+
large: 32,
|
|
18
|
+
xlarge: 40,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const AutocompleteInternalHeightMap = {
|
|
22
|
+
small: "26px",
|
|
23
|
+
medium: 40,
|
|
24
|
+
large: 48,
|
|
25
|
+
xlarge: 56,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const ChipHeightMap = {
|
|
29
|
+
micro: 20,
|
|
30
|
+
xsmall: 24,
|
|
31
|
+
small: 32,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const RangeChartHeightMap = {
|
|
35
|
+
xsmall: 8,
|
|
36
|
+
small: 16,
|
|
37
|
+
medium: 24,
|
|
38
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export { default as Button } from "./components/Button";
|
|
2
2
|
export type { ButtonProps } from "./components/Button";
|
|
3
|
+
export { default as Typography } from "./components/Typography";
|
|
4
|
+
export type { TypographyProps } from "./components/Typography";
|
|
5
|
+
export { default as TextField } from "./components/TextField";
|
|
6
|
+
export type { TextFieldProps, TextFieldInputProps } from "./components/TextField";
|
|
3
7
|
export * from "./components/theme";
|