@carrier-dpx/air-react-library 0.2.2 → 0.3.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
CHANGED
|
@@ -80,6 +80,30 @@ 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
|
+
|
|
83
107
|
## Figma Integration
|
|
84
108
|
|
|
85
109
|
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 +113,7 @@ This library is integrated with Figma Code Connect. When using Figma Make, compo
|
|
|
89
113
|
Currently available components:
|
|
90
114
|
|
|
91
115
|
- **Button** - Material-UI based button component with Carrier DPX design system styling
|
|
116
|
+
- **Typography** - Text component with all Carrier DPX typography variants (h1-h6, body1-3, caps, etc.)
|
|
92
117
|
|
|
93
118
|
More components coming soon!
|
|
94
119
|
|
package/package.json
CHANGED
|
@@ -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
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
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";
|
|
3
5
|
export * from "./components/theme";
|