@carrier-dpx/air-react-library 0.7.0 → 0.7.2
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/package.json +4 -4
- package/src/components/BottomNavigation/BottomNavigation.figma.tsx +15 -6
- package/src/components/BottomNavigation/BottomNavigationAction.figma.tsx +5 -3
- package/src/components/Box/Box.tsx +29 -0
- package/src/components/Box/index.ts +3 -0
- package/src/components/Button/Button.figma.tsx +4 -3
- package/src/components/Icon/icons/demo/DEMO_USAGE.md +3 -3
- package/src/components/Icon/icons/demo/DeviceManagerIcon.figma.tsx +5 -5
- package/src/components/Icon/icons/demo/HomeIcon.figma.tsx +7 -2
- package/src/components/Icon/icons/demo/SiteIcon.figma.tsx +7 -2
- package/src/components/Icon/icons/demo/WarningTriangle.figma.tsx +33 -0
- package/src/components/Icon/icons/demo/{WarningIcon.tsx → WarningTriangle.tsx} +2 -2
- package/src/components/Icon/icons/demo/iconRegistry.ts +3 -9
- package/src/components/Icon/icons/demo/index.ts +2 -5
- package/src/components/Link/Link.figma.tsx +4 -2
- package/src/components/Navbar/NavbarButtons/NavbarTooltip.tsx +1 -1
- package/src/components/Tooltip/Tooltip.figma.tsx +82 -0
- package/src/components/Tooltip/Tooltip.tsx +66 -0
- package/src/components/Tooltip/index.ts +2 -0
- package/src/components/Tooltip/styles.ts +40 -0
- package/src/index.ts +24 -0
- package/src/components/Icon/icons/demo/AlertIcon.figma.tsx +0 -28
- package/src/components/Icon/icons/demo/AlertIcon.tsx +0 -19
- package/src/components/Icon/icons/demo/WarningIcon.figma.tsx +0 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carrier-dpx/air-react-library",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Air web React component library for Figma Make",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"figma:connect": "figma connect",
|
|
20
|
-
"figma:publish": "figma connect publish"
|
|
19
|
+
"figma:connect": "npx figma connect",
|
|
20
|
+
"figma:publish": "npx figma connect publish"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
|
23
23
|
"react",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@emotion/react": "^11.11.0",
|
|
43
43
|
"@emotion/styled": "^11.11.0",
|
|
44
|
-
"@figma/code-connect": "^1.
|
|
44
|
+
"@figma/code-connect": "^1.3.13",
|
|
45
45
|
"@mui/material": "^5.15.0",
|
|
46
46
|
"@types/react": "^18.0.0",
|
|
47
47
|
"@types/react-dom": "^18.0.0",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import figma from "@figma/code-connect";
|
|
13
13
|
import BottomNavigation from "./BottomNavigation";
|
|
14
|
+
// Import BottomNavigationAction so Figma Code Connect can resolve component instances
|
|
14
15
|
import BottomNavigationAction from "./BottomNavigationAction";
|
|
15
16
|
|
|
16
17
|
figma.connect(
|
|
@@ -29,25 +30,33 @@ figma.connect(
|
|
|
29
30
|
"selected-only": "Selected Only",
|
|
30
31
|
off: "Off",
|
|
31
32
|
}),
|
|
32
|
-
|
|
33
33
|
/**
|
|
34
34
|
* CHILDREN
|
|
35
|
-
* Maps BottomNavigationAction instances
|
|
36
|
-
*
|
|
35
|
+
* Maps nested BottomNavigationAction instances from Figma
|
|
36
|
+
* Each "Nav Item X" is an instance of the BottomNavigationAction component
|
|
37
|
+
* We map each one individually using the exact layer names, then combine them
|
|
37
38
|
*/
|
|
38
|
-
|
|
39
|
+
navItem1: figma.children("Nav Item 1"),
|
|
40
|
+
navItem2: figma.children("Nav Item 2"),
|
|
41
|
+
navItem3: figma.children("Nav Item 3"),
|
|
42
|
+
navItem4: figma.children("Nav Item 4"),
|
|
43
|
+
navItem5: figma.children("Nav Item 5"),
|
|
39
44
|
},
|
|
40
45
|
/**
|
|
41
46
|
* EXAMPLE CODE TEMPLATE
|
|
42
47
|
* Shows how BottomNavigation should be used with BottomNavigationAction children
|
|
43
48
|
*/
|
|
44
|
-
example: ({ showLabel,
|
|
49
|
+
example: ({ showLabel, navItem1, navItem2, navItem3, navItem4, navItem5 }) => (
|
|
45
50
|
<BottomNavigation
|
|
46
51
|
showLabel={showLabel}
|
|
47
52
|
value={0}
|
|
48
53
|
onChange={() => {}}
|
|
49
54
|
>
|
|
50
|
-
{
|
|
55
|
+
{navItem1}
|
|
56
|
+
{navItem2}
|
|
57
|
+
{navItem3}
|
|
58
|
+
{navItem4}
|
|
59
|
+
{navItem5}
|
|
51
60
|
</BottomNavigation>
|
|
52
61
|
),
|
|
53
62
|
}
|
|
@@ -50,11 +50,13 @@ figma.connect(
|
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* LABEL TEXT
|
|
53
|
-
* Maps text
|
|
54
|
-
*
|
|
53
|
+
* Maps text property "✏️ Label" from BottomNavigationAction component
|
|
54
|
+
* This requires the "✏️ Label" text property to be surfaced from the "Label" layer
|
|
55
|
+
* Similar to Navbar Item which uses figma.string("✏️ Label")
|
|
55
56
|
* The label is rendered as a Typography component in React
|
|
56
57
|
*/
|
|
57
|
-
label: figma.
|
|
58
|
+
label: figma.string("✏️ Label"),
|
|
59
|
+
|
|
58
60
|
|
|
59
61
|
/**
|
|
60
62
|
* ICON NESTED PROPERTIES
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import MuiBox, { BoxProps as MuiBoxProps } from "@mui/material/Box";
|
|
4
|
+
import { AllSystemCSSProperties, ResponsiveStyleValue } from "@mui/system";
|
|
5
|
+
|
|
6
|
+
export interface BoxProps extends MuiBoxProps {
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* Specifies how to capitalize an element's text
|
|
10
|
+
*/
|
|
11
|
+
textTransform?: ResponsiveStyleValue<AllSystemCSSProperties["textTransform"]>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The Box component serves as a wrapper component for most of the CSS utility needs.
|
|
15
|
+
*
|
|
16
|
+
* // Default import
|
|
17
|
+
* import Box from '@carrier-io/air-react/Box'
|
|
18
|
+
*
|
|
19
|
+
* // Named import
|
|
20
|
+
* import { Box } from '@carrier-io/air-react'
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const Box = forwardRef<unknown, BoxProps>((props: BoxProps, ref) => {
|
|
24
|
+
return <MuiBox {...props} ref={ref} />;
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
Box.displayName = "Box";
|
|
28
|
+
|
|
29
|
+
export default Box;
|
|
@@ -92,10 +92,11 @@ figma.connect(
|
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
94
|
* BUTTON TEXT/CHILDREN
|
|
95
|
-
* Maps
|
|
96
|
-
*
|
|
95
|
+
* Maps text property "✏️ Text" from Button component
|
|
96
|
+
* The text property must be surfaced from the "Button Label" layer
|
|
97
|
+
* Similar to BottomNavigationAction which uses figma.string("✏️ Label")
|
|
97
98
|
*/
|
|
98
|
-
children: figma.
|
|
99
|
+
children: figma.string("✏️ Text"),
|
|
99
100
|
|
|
100
101
|
/**
|
|
101
102
|
* START ICON
|
|
@@ -7,7 +7,7 @@ This guide shows how to use the demo icons in BottomNavigation for your Leadersh
|
|
|
7
7
|
- `devicemanager` - Device Manager icon
|
|
8
8
|
- `home` - Home icon
|
|
9
9
|
- `site` - Site icon
|
|
10
|
-
- `
|
|
10
|
+
- `warningtriangle` - Warning triangle icon
|
|
11
11
|
|
|
12
12
|
## Usage in BottomNavigation
|
|
13
13
|
|
|
@@ -53,7 +53,7 @@ function DemoBottomNavigation() {
|
|
|
53
53
|
<BottomNavigationAction
|
|
54
54
|
icon={
|
|
55
55
|
<Icon fontSize="medium">
|
|
56
|
-
<SvgIcon name="
|
|
56
|
+
<SvgIcon name="warningtriangle" />
|
|
57
57
|
</Icon>
|
|
58
58
|
}
|
|
59
59
|
label={<Typography variant="body3Semibold">Alerts</Typography>}
|
|
@@ -69,7 +69,7 @@ function DemoBottomNavigation() {
|
|
|
69
69
|
If you prefer individual components (already created):
|
|
70
70
|
|
|
71
71
|
```tsx
|
|
72
|
-
import { DeviceManagerIcon, HomeIcon, SiteIcon,
|
|
72
|
+
import { DeviceManagerIcon, HomeIcon, SiteIcon, WarningTriangle } from './icons/demo';
|
|
73
73
|
|
|
74
74
|
// Usage:
|
|
75
75
|
<Icon fontSize="medium">
|
|
@@ -19,12 +19,12 @@ figma.connect(
|
|
|
19
19
|
{
|
|
20
20
|
props: {
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* Maps Figma's "
|
|
24
|
-
* Figma:
|
|
25
|
-
* Figma:
|
|
22
|
+
* STYLE/VARIANT MAPPING
|
|
23
|
+
* Maps Figma's "Style" property to React's "variant" prop
|
|
24
|
+
* Figma: Style="Outlined" → React: variant="outlined"
|
|
25
|
+
* Figma: Style="Filled" → React: variant="filled"
|
|
26
26
|
*/
|
|
27
|
-
variant: figma.enum("
|
|
27
|
+
variant: figma.enum("Style", {
|
|
28
28
|
Outlined: "outlined",
|
|
29
29
|
Filled: "filled",
|
|
30
30
|
}),
|
|
@@ -8,13 +8,18 @@ import figma from "@figma/code-connect";
|
|
|
8
8
|
import Icon from "../../Icon";
|
|
9
9
|
import { HomeIcon } from "./HomeIcon";
|
|
10
10
|
|
|
11
|
-
// TODO: Uncomment and update with real Figma URL when ready
|
|
12
11
|
figma.connect(
|
|
13
12
|
HomeIcon,
|
|
14
13
|
"https://www.figma.com/design/RT43n0bKuuIt7ylllD3DR0/Icon-Library?node-id=38-171",
|
|
15
14
|
{
|
|
16
15
|
props: {
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* STYLE/VARIANT MAPPING
|
|
18
|
+
* Maps Figma's "Style" property to React's "variant" prop
|
|
19
|
+
* Figma: Style="Outlined" → React: variant="outlined"
|
|
20
|
+
* Figma: Style="Filled" → React: variant="filled"
|
|
21
|
+
*/
|
|
22
|
+
variant: figma.enum("Style", {
|
|
18
23
|
Outlined: "outlined",
|
|
19
24
|
Filled: "filled",
|
|
20
25
|
}),
|
|
@@ -8,13 +8,18 @@ import figma from "@figma/code-connect";
|
|
|
8
8
|
import Icon from "../../Icon";
|
|
9
9
|
import { SiteIcon } from "./SiteIcon";
|
|
10
10
|
|
|
11
|
-
// TODO: Uncomment and update with real Figma URL when ready
|
|
12
11
|
figma.connect(
|
|
13
12
|
SiteIcon,
|
|
14
13
|
"https://www.figma.com/design/RT43n0bKuuIt7ylllD3DR0/Icon-Library?node-id=76-846",
|
|
15
14
|
{
|
|
16
15
|
props: {
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* STYLE/VARIANT MAPPING
|
|
18
|
+
* Maps Figma's "Style" property to React's "variant" prop
|
|
19
|
+
* Figma: Style="Outlined" → React: variant="outlined"
|
|
20
|
+
* Figma: Style="Filled" → React: variant="filled"
|
|
21
|
+
*/
|
|
22
|
+
variant: figma.enum("Style", {
|
|
18
23
|
Outlined: "outlined",
|
|
19
24
|
Filled: "filled",
|
|
20
25
|
}),
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Figma Code Connect Configuration for WarningTriangle
|
|
3
|
+
*
|
|
4
|
+
* This connects Figma's warning_triangle icon component to the React WarningTriangle component.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import figma from "@figma/code-connect";
|
|
8
|
+
import Icon from "../../Icon";
|
|
9
|
+
import { WarningTriangle } from "./WarningTriangle";
|
|
10
|
+
|
|
11
|
+
figma.connect(
|
|
12
|
+
WarningTriangle,
|
|
13
|
+
"https://www.figma.com/design/RT43n0bKuuIt7ylllD3DR0/Icon-Library?node-id=29-54",
|
|
14
|
+
{
|
|
15
|
+
props: {
|
|
16
|
+
/**
|
|
17
|
+
* STYLE/VARIANT MAPPING
|
|
18
|
+
* Maps Figma's "Style" property to React's "variant" prop
|
|
19
|
+
* Figma: Style="Outlined" → React: variant="outlined"
|
|
20
|
+
* Figma: Style="Filled" → React: variant="filled"
|
|
21
|
+
*/
|
|
22
|
+
variant: figma.enum("Style", {
|
|
23
|
+
Outlined: "outlined",
|
|
24
|
+
Filled: "filled",
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
example: ({ variant }) => (
|
|
28
|
+
<Icon fontSize="medium">
|
|
29
|
+
<WarningTriangle variant={variant} />
|
|
30
|
+
</Icon>
|
|
31
|
+
),
|
|
32
|
+
}
|
|
33
|
+
);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FC, SVGProps } from "react";
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface WarningTriangleProps extends SVGProps<SVGSVGElement> {
|
|
4
4
|
variant?: "outlined" | "filled";
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export const
|
|
7
|
+
export const WarningTriangle: FC<WarningTriangleProps> = ({ variant = "outlined", ...props }) => {
|
|
8
8
|
return (
|
|
9
9
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
|
10
10
|
<path d="M12 16C12.2833 16 12.5212 16.0954 12.7129 16.2871C12.9046 16.4788 13 16.7167 13 17C13 17.2833 12.9046 17.5212 12.7129 17.7129C12.5212 17.9046 12.2833 18 12 18C11.7167 18 11.4788 17.9045 11.2871 17.7129C11.0955 17.5212 11 17.2833 11 17C11 16.7167 11.0955 16.4788 11.2871 16.2871C11.4788 16.0955 11.7167 16 12 16Z" fill="currentColor"/>
|
|
@@ -45,8 +45,7 @@ const WarningSvg: FC<React.SVGProps<SVGSVGElement>> = (props) => (
|
|
|
45
45
|
</svg>
|
|
46
46
|
);
|
|
47
47
|
|
|
48
|
-
//
|
|
49
|
-
const AlertSvg = WarningSvg;
|
|
48
|
+
// WarningTriangle SVG (previously WarningIcon)
|
|
50
49
|
|
|
51
50
|
export interface IconInfo {
|
|
52
51
|
name: string;
|
|
@@ -70,16 +69,11 @@ export const iconRegistry: Record<string, IconInfo> = {
|
|
|
70
69
|
component: SiteSvg,
|
|
71
70
|
variant: "outlined",
|
|
72
71
|
},
|
|
73
|
-
|
|
74
|
-
name: "
|
|
72
|
+
warningtriangle: {
|
|
73
|
+
name: "warningtriangle",
|
|
75
74
|
component: WarningSvg,
|
|
76
75
|
variant: "outlined",
|
|
77
76
|
},
|
|
78
|
-
alert: {
|
|
79
|
-
name: "alert",
|
|
80
|
-
component: AlertSvg,
|
|
81
|
-
variant: "outlined",
|
|
82
|
-
},
|
|
83
77
|
};
|
|
84
78
|
|
|
85
79
|
/**
|
|
@@ -16,8 +16,5 @@ export type { HomeIconProps } from "./HomeIcon";
|
|
|
16
16
|
export { SiteIcon } from "./SiteIcon";
|
|
17
17
|
export type { SiteIconProps } from "./SiteIcon";
|
|
18
18
|
|
|
19
|
-
export {
|
|
20
|
-
export type {
|
|
21
|
-
|
|
22
|
-
export { AlertIcon } from "./AlertIcon";
|
|
23
|
-
export type { AlertIconProps } from "./AlertIcon";
|
|
19
|
+
export { WarningTriangle } from "./WarningTriangle";
|
|
20
|
+
export type { WarningTriangleProps } from "./WarningTriangle";
|
|
@@ -52,9 +52,11 @@ figma.connect(
|
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* TEXT CONTENT
|
|
55
|
-
* Maps
|
|
55
|
+
* Maps text property "✏️ Text" from Link component
|
|
56
|
+
* The text property must be surfaced from the "Label" layer
|
|
57
|
+
* Similar to Button and BottomNavigationAction which use surfaced text properties
|
|
56
58
|
*/
|
|
57
|
-
children: figma.
|
|
59
|
+
children: figma.string("✏️ Text"),
|
|
58
60
|
},
|
|
59
61
|
|
|
60
62
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC, SyntheticEvent, useState } from "react";
|
|
2
2
|
import Tooltip, { TooltipProps } from "../../Tooltip";
|
|
3
3
|
import Typography from "../../Typography";
|
|
4
|
-
import Fade from "
|
|
4
|
+
import { Fade } from "@mui/material";
|
|
5
5
|
import { useNavbarContext } from "../hooks/useNavbarContext";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Figma Code Connect Configuration for Tooltip Component
|
|
3
|
+
*
|
|
4
|
+
* This connects Figma's Tooltip component to the React Tooltip component.
|
|
5
|
+
*
|
|
6
|
+
* Figma URL: https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=6590-48770
|
|
7
|
+
*
|
|
8
|
+
* Figma Properties:
|
|
9
|
+
* - ✏️ Label (text property) → title prop
|
|
10
|
+
* - color (white, black) → color prop
|
|
11
|
+
* - placement (top, top-start, top-end, bottom, bottom-start, bottom-end, left, left-start, left-end, right, right-start, right-end) → placement prop
|
|
12
|
+
* - arrow (true, false) → arrow prop
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import figma from "@figma/code-connect";
|
|
16
|
+
import Tooltip from "./Tooltip";
|
|
17
|
+
|
|
18
|
+
figma.connect(
|
|
19
|
+
Tooltip,
|
|
20
|
+
"https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=6590-48770",
|
|
21
|
+
{
|
|
22
|
+
props: {
|
|
23
|
+
/**
|
|
24
|
+
* TOOLTIP TEXT/TITLE
|
|
25
|
+
* Maps text property "✏️ label" from nested TooltipContent component
|
|
26
|
+
* The label is nested within TooltipContent component
|
|
27
|
+
* Similar to how Icon properties are accessed in BottomNavigationAction
|
|
28
|
+
*/
|
|
29
|
+
title: figma.nestedProps("TooltipContent", {
|
|
30
|
+
label: figma.string("✏️ label"),
|
|
31
|
+
}),
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* COLOR
|
|
35
|
+
* Maps Figma's "color" property to React's "color" prop
|
|
36
|
+
* Figma: white, black
|
|
37
|
+
* React: "white", "black"
|
|
38
|
+
*/
|
|
39
|
+
color: figma.enum("color", {
|
|
40
|
+
white: "white",
|
|
41
|
+
black: "black",
|
|
42
|
+
}),
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* PLACEMENT
|
|
46
|
+
* Maps Figma's "placement" property to React's "placement" prop
|
|
47
|
+
* Controls where the tooltip appears relative to the target element
|
|
48
|
+
*/
|
|
49
|
+
placement: figma.enum("placement", {
|
|
50
|
+
top: "top",
|
|
51
|
+
"top-start": "top-start",
|
|
52
|
+
"top-end": "top-end",
|
|
53
|
+
bottom: "bottom",
|
|
54
|
+
"bottom-start": "bottom-start",
|
|
55
|
+
"bottom-end": "bottom-end",
|
|
56
|
+
left: "left",
|
|
57
|
+
"left-start": "left-start",
|
|
58
|
+
"left-end": "left-end",
|
|
59
|
+
right: "right",
|
|
60
|
+
"right-start": "right-start",
|
|
61
|
+
"right-end": "right-end",
|
|
62
|
+
}),
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* ARROW
|
|
66
|
+
* Maps Figma's "arrow" boolean to React's "arrow" prop
|
|
67
|
+
* Controls whether the tooltip displays an arrow pointing to the target
|
|
68
|
+
*/
|
|
69
|
+
arrow: figma.boolean("arrow"),
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* EXAMPLE CODE TEMPLATE
|
|
73
|
+
* Shows how Tooltip should be used
|
|
74
|
+
* Note: Tooltip wraps children - in actual usage, wrap the target element
|
|
75
|
+
*/
|
|
76
|
+
example: ({ title, color, placement, arrow }) => (
|
|
77
|
+
<Tooltip title={title.label} color={color} placement={placement} arrow={arrow}>
|
|
78
|
+
<span>Hover me</span>
|
|
79
|
+
</Tooltip>
|
|
80
|
+
),
|
|
81
|
+
}
|
|
82
|
+
);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
CSSObject,
|
|
5
|
+
Tooltip as MuiTooltip,
|
|
6
|
+
TooltipProps as MuiTooltipProps,
|
|
7
|
+
Theme,
|
|
8
|
+
} from "@mui/material";
|
|
9
|
+
import { baseTooltipSx } from "./styles";
|
|
10
|
+
|
|
11
|
+
export interface TooltipProps extends MuiTooltipProps {
|
|
12
|
+
/**
|
|
13
|
+
* Color sets the background-color and font color.
|
|
14
|
+
*/
|
|
15
|
+
color?: "white" | "black";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Tooltip displays informative text when users hover over, focus on, or tap an element.
|
|
19
|
+
*
|
|
20
|
+
* `import Tooltip from '@carrier-io/air-react/Tooltip'`
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const Tooltip = forwardRef<unknown, TooltipProps>(
|
|
24
|
+
({ children, color = "white", ...rest }, ref) => {
|
|
25
|
+
const componentsOverrideProps: any = {
|
|
26
|
+
tooltip: {
|
|
27
|
+
sx: { ...baseTooltipSx },
|
|
28
|
+
},
|
|
29
|
+
arrow: {
|
|
30
|
+
color: (theme: Theme) => theme.palette.base?.background?.paper,
|
|
31
|
+
},
|
|
32
|
+
...(color === "black"
|
|
33
|
+
? {
|
|
34
|
+
arrow: {
|
|
35
|
+
sx: (theme: Theme) =>
|
|
36
|
+
({
|
|
37
|
+
color: theme.palette.base?.dark,
|
|
38
|
+
"&:before": {
|
|
39
|
+
boxShadow: theme.shadows[2],
|
|
40
|
+
},
|
|
41
|
+
} as CSSObject),
|
|
42
|
+
},
|
|
43
|
+
tooltip: {
|
|
44
|
+
sx: (theme: Theme) =>
|
|
45
|
+
({
|
|
46
|
+
backgroundColor: theme.palette.base?.dark,
|
|
47
|
+
color: theme.palette.base?.contrastText,
|
|
48
|
+
boxShadow: theme.shadows[2],
|
|
49
|
+
} as CSSObject),
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
: {}),
|
|
53
|
+
...rest.componentsProps,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<MuiTooltip {...rest} componentsProps={componentsOverrideProps} ref={ref}>
|
|
58
|
+
{children}
|
|
59
|
+
</MuiTooltip>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
Tooltip.displayName = "Tooltip";
|
|
65
|
+
|
|
66
|
+
export default Tooltip;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Theme } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
const tooltipArrowBeforeSx = {
|
|
4
|
+
"&:before": {
|
|
5
|
+
backgroundColor: (theme: Theme) => theme.palette.base?.background?.paper,
|
|
6
|
+
boxShadow: (theme: Theme) => theme.shadows[2],
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const baseTooltipSx = {
|
|
11
|
+
backgroundColor: (theme: Theme) => theme.palette.base?.background?.paper,
|
|
12
|
+
color: (theme: Theme) => theme.palette.base?.text?.primary,
|
|
13
|
+
boxShadow: (theme: Theme) => theme.shadows[2],
|
|
14
|
+
fontSize: "12px",
|
|
15
|
+
lineHeight: "14px",
|
|
16
|
+
"&.MuiTooltip-tooltipPlacementLeft": {
|
|
17
|
+
"& .MuiTooltip-arrow": {
|
|
18
|
+
marginRight: "-0.6em!important",
|
|
19
|
+
...tooltipArrowBeforeSx,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
"&.MuiTooltip-tooltipPlacementTop": {
|
|
23
|
+
"& .MuiTooltip-arrow": {
|
|
24
|
+
marginBottom: "-0.6em!important",
|
|
25
|
+
...tooltipArrowBeforeSx,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
"&.MuiTooltip-tooltipPlacementRight": {
|
|
29
|
+
"& .MuiTooltip-arrow": {
|
|
30
|
+
marginLeft: "-0.6em!important",
|
|
31
|
+
...tooltipArrowBeforeSx,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
"&.MuiTooltip-tooltipPlacementBottom": {
|
|
35
|
+
"& .MuiTooltip-arrow": {
|
|
36
|
+
marginTop: "-0.6em !important",
|
|
37
|
+
...tooltipArrowBeforeSx,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,10 @@ export { default as Link } from "./components/Link";
|
|
|
8
8
|
export type { LinkProps } from "./components/Link";
|
|
9
9
|
export { default as Divider } from "./components/Divider";
|
|
10
10
|
export type { DividerProps } from "./components/Divider";
|
|
11
|
+
export { default as Box } from "./components/Box";
|
|
12
|
+
export type { BoxProps } from "./components/Box";
|
|
13
|
+
export { default as Tooltip } from "./components/Tooltip";
|
|
14
|
+
export type { TooltipProps } from "./components/Tooltip";
|
|
11
15
|
export { default as Copyright } from "./components/Copyright";
|
|
12
16
|
export type { CopyrightProps } from "./components/Copyright";
|
|
13
17
|
export { default as Icon } from "./components/Icon";
|
|
@@ -19,3 +23,23 @@ export { default as BottomNavigationAction } from "./components/BottomNavigation
|
|
|
19
23
|
export type { BottomNavigationProps } from "./components/BottomNavigation";
|
|
20
24
|
export type { BottomNavigationActionProps } from "./components/BottomNavigation/BottomNavigationAction";
|
|
21
25
|
export * from "./components/theme";
|
|
26
|
+
|
|
27
|
+
// Demo Icons - exported from main index to avoid deep-path imports
|
|
28
|
+
export {
|
|
29
|
+
HomeIcon,
|
|
30
|
+
DeviceManagerIcon,
|
|
31
|
+
SiteIcon,
|
|
32
|
+
WarningTriangle,
|
|
33
|
+
SvgIcon,
|
|
34
|
+
iconRegistry,
|
|
35
|
+
getIcon,
|
|
36
|
+
getIconNames,
|
|
37
|
+
} from "./components/Icon/icons/demo";
|
|
38
|
+
export type {
|
|
39
|
+
HomeIconProps,
|
|
40
|
+
DeviceManagerIconProps,
|
|
41
|
+
SiteIconProps,
|
|
42
|
+
WarningTriangleProps,
|
|
43
|
+
SvgIconProps,
|
|
44
|
+
IconInfo,
|
|
45
|
+
} from "./components/Icon/icons/demo";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Figma Code Connect Configuration for AlertIcon
|
|
3
|
-
*
|
|
4
|
-
* This connects Figma's warning_triangle icon component to the React AlertIcon component.
|
|
5
|
-
* Also known as WarningIcon in some contexts.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import figma from "@figma/code-connect";
|
|
9
|
-
import Icon from "../../Icon";
|
|
10
|
-
import { AlertIcon } from "./AlertIcon";
|
|
11
|
-
|
|
12
|
-
figma.connect(
|
|
13
|
-
AlertIcon,
|
|
14
|
-
"https://www.figma.com/design/RT43n0bKuuIt7ylllD3DR0/Icon-Library?node-id=29-54",
|
|
15
|
-
{
|
|
16
|
-
props: {
|
|
17
|
-
variant: figma.enum("State", {
|
|
18
|
-
Outlined: "outlined",
|
|
19
|
-
Filled: "filled",
|
|
20
|
-
}),
|
|
21
|
-
},
|
|
22
|
-
example: ({ variant }) => (
|
|
23
|
-
<Icon fontSize="medium">
|
|
24
|
-
<AlertIcon variant={variant} />
|
|
25
|
-
</Icon>
|
|
26
|
-
),
|
|
27
|
-
}
|
|
28
|
-
);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { FC, SVGProps } from "react";
|
|
2
|
-
|
|
3
|
-
export interface AlertIconProps extends SVGProps<SVGSVGElement> {
|
|
4
|
-
variant?: "outlined" | "filled";
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* AlertIcon (also known as WarningIcon)
|
|
9
|
-
* Warning triangle icon for alerts
|
|
10
|
-
*/
|
|
11
|
-
export const AlertIcon: FC<AlertIconProps> = ({ variant = "outlined", ...props }) => {
|
|
12
|
-
return (
|
|
13
|
-
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
|
14
|
-
<path d="M12 16C12.2833 16 12.5212 16.0954 12.7129 16.2871C12.9046 16.4788 13 16.7167 13 17C13 17.2833 12.9046 17.5212 12.7129 17.7129C12.5212 17.9046 12.2833 18 12 18C11.7167 18 11.4788 17.9045 11.2871 17.7129C11.0955 17.5212 11 17.2833 11 17C11 16.7167 11.0955 16.4788 11.2871 16.2871C11.4788 16.0955 11.7167 16 12 16Z" fill="currentColor"/>
|
|
15
|
-
<path d="M12 10C12.2833 10 12.5212 10.0954 12.7129 10.2871C12.9046 10.4788 13 10.7167 13 11V14C13 14.2833 12.9046 14.5212 12.7129 14.7129C12.5212 14.9046 12.2833 15 12 15C11.7167 15 11.4788 14.9045 11.2871 14.7129C11.0955 14.5212 11 14.2833 11 14V11C11 10.7167 11.0955 10.4788 11.2871 10.2871C11.4788 10.0955 11.7167 10 12 10Z" fill="currentColor"/>
|
|
16
|
-
<path fillRule="evenodd" clipRule="evenodd" d="M12 3C12.1666 3 12.329 3.04172 12.4873 3.125C12.6456 3.20833 12.775 3.33334 12.875 3.5L22.125 19.5C22.225 19.6667 22.271 19.8377 22.2627 20.0127C22.2544 20.1876 22.2083 20.3501 22.125 20.5C22.0417 20.6499 21.9252 20.7707 21.7754 20.8623C21.6255 20.9539 21.4586 20.9999 21.2754 21H2.72462C2.54144 20.9999 2.37452 20.9539 2.22462 20.8623C2.0748 20.7707 1.95828 20.6499 1.87501 20.5C1.79171 20.3501 1.74567 20.1876 1.73732 20.0127C1.72898 19.8377 1.77501 19.6667 1.87501 19.5L11.125 3.5C11.225 3.33334 11.3544 3.20833 11.5127 3.125C11.671 3.04173 11.8334 3 12 3ZM4.45021 19H19.5498L12 6L4.45021 19Z" fill="currentColor"/>
|
|
17
|
-
</svg>
|
|
18
|
-
);
|
|
19
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Figma Code Connect Configuration for WarningIcon
|
|
3
|
-
*
|
|
4
|
-
* TODO: Update the Figma URL below with the actual Figma component URL
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import figma from "@figma/code-connect";
|
|
8
|
-
import Icon from "../../Icon";
|
|
9
|
-
import { WarningIcon } from "./WarningIcon";
|
|
10
|
-
|
|
11
|
-
// TODO: Uncomment and update with real Figma URL when ready
|
|
12
|
-
figma.connect(
|
|
13
|
-
WarningIcon,
|
|
14
|
-
"https://www.figma.com/design/RT43n0bKuuIt7ylllD3DR0/Icon-Library?node-id=29-54",
|
|
15
|
-
{
|
|
16
|
-
props: {
|
|
17
|
-
variant: figma.enum("State", {
|
|
18
|
-
Outlined: "outlined",
|
|
19
|
-
Filled: "filled",
|
|
20
|
-
}),
|
|
21
|
-
},
|
|
22
|
-
example: ({ variant }) => (
|
|
23
|
-
<Icon fontSize="medium">
|
|
24
|
-
<WarningIcon variant={variant} />
|
|
25
|
-
</Icon>
|
|
26
|
-
),
|
|
27
|
-
}
|
|
28
|
-
);
|