Skip to content

Commit 083e7a7

Browse files
authored
Merge branch 'dev' into fonts
2 parents ffc8494 + f1e86c1 commit 083e7a7

22 files changed

+1402
-73
lines changed

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@
2626
"remark-gfm": "^3.0.1"
2727
},
2828
"devDependencies": {
29+
"@types/hast": "^3.0.0",
2930
"@types/node": "^20.4.2",
3031
"@types/react": "^18.2.15",
3132
"@types/react-dom": "^18.2.7",
3233
"eslint": "^8.45.0",
3334
"eslint-config-next": "^13.4.10",
35+
"image-size": "^1.0.2",
3436
"polished": "^4.2.2",
35-
"typescript": "^5.1.6"
37+
"typescript": "^5.1.6",
38+
"unified": "^10.0.0",
39+
"unist-util-visit": "^5.0.0"
3640
}
3741
}

src/@chakra-ui/components/Alert.ts

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import {
2+
createMultiStyleConfigHelpers,
3+
SystemStyleObject,
4+
} from "@chakra-ui/react"
5+
import { alertAnatomy } from "@chakra-ui/anatomy"
6+
import { alertDefaultTheme, defineMergeStyles } from "./components.utils"
7+
import { AlertStatusType } from "@/components/Alert"
8+
9+
const STATUS_COLORS: Record<
10+
"solid" | "subtle",
11+
Record<AlertStatusType, SystemStyleObject>
12+
> = {
13+
solid: {
14+
error: {
15+
bg: "error.base",
16+
color: "error.light",
17+
},
18+
info: {
19+
bg: "body.medium",
20+
color: "background.base",
21+
},
22+
warning: {
23+
bg: "attention.base",
24+
color: "attention.light",
25+
},
26+
success: {
27+
bg: "success.base",
28+
color: "success.light",
29+
},
30+
},
31+
subtle: {
32+
error: {
33+
bg: "error.light",
34+
color: "error.base",
35+
},
36+
info: {
37+
bg: "background.highlight",
38+
color: "body.base",
39+
},
40+
warning: {
41+
bg: "attention.light",
42+
color: "gray.700",
43+
},
44+
success: {
45+
bg: "success.light",
46+
color: "success",
47+
},
48+
},
49+
}
50+
51+
const { baseStyle: alertBaseStyle } = alertDefaultTheme
52+
53+
const { defineMultiStyleConfig, definePartsStyle } =
54+
createMultiStyleConfigHelpers(alertAnatomy.keys)
55+
56+
const baseStyleContainer = defineMergeStyles(alertBaseStyle?.container, {
57+
justifyContent: "center",
58+
gap: 2,
59+
})
60+
61+
const baseStyleIcon = defineMergeStyles(alertBaseStyle?.icon, {
62+
me: 2,
63+
})
64+
65+
const baseStyle = definePartsStyle({
66+
container: baseStyleContainer,
67+
icon: baseStyleIcon,
68+
})
69+
70+
const variantSolid = definePartsStyle((props) => ({
71+
container: {
72+
...STATUS_COLORS["solid"][props.status],
73+
},
74+
}))
75+
76+
const variantSubtle = definePartsStyle((props) => ({
77+
container: {
78+
...STATUS_COLORS["subtle"][props.status],
79+
},
80+
}))
81+
82+
const variants = {
83+
solid: variantSolid,
84+
subtle: variantSubtle,
85+
}
86+
87+
export const Alert = defineMultiStyleConfig({
88+
baseStyle,
89+
variants,
90+
defaultProps: {
91+
variant: "solid",
92+
},
93+
})
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import {
2+
createMultiStyleConfigHelpers,
3+
cssVar,
4+
defineStyle,
5+
getToken,
6+
} from "@chakra-ui/react"
7+
import { avatarAnatomy } from "@chakra-ui/anatomy"
8+
import { avatarDefaultTheme, defineMergeStyles } from "./components.utils"
9+
import { pick } from "lodash"
10+
11+
const { defineMultiStyleConfig, definePartsStyle } =
12+
createMultiStyleConfigHelpers(avatarAnatomy.keys)
13+
14+
const { baseStyle: defaultBaseStyle, sizes: defaultSizes } = avatarDefaultTheme
15+
16+
const $border = cssVar("avatar-border-color", "transparent")
17+
const $mlBySize = cssVar("ml-by-size")
18+
19+
const baseStyleContainer = defineStyle((props) => {
20+
const primaryLowContrast = getToken(
21+
"colors",
22+
"primary.lowContrast"
23+
)(props.theme)
24+
25+
return defineMergeStyles(defaultBaseStyle?.(props).container, {
26+
[$border.variable]: "transparent",
27+
borderWidth: "1px",
28+
"&:hover, [data-peer]:hover ~ &": {
29+
boxShadow: `0.15em 0.15em 0 ${primaryLowContrast}`,
30+
},
31+
_focus: {
32+
outline: "4px solid",
33+
outlineColor: "primary.hover",
34+
outlineOffset: "-1px",
35+
},
36+
_active: {
37+
[$border.variable]: "colors.primary.hover",
38+
boxShadow: "none",
39+
"& img": {
40+
opacity: 0.7,
41+
},
42+
},
43+
"[role='group'] &": {
44+
[$border.variable]: "colors.background.base",
45+
_notLast: {
46+
marginLeft: $mlBySize.reference,
47+
},
48+
},
49+
})
50+
})
51+
52+
const baseStyleExessLabel = defineStyle((props) =>
53+
defineMergeStyles(defaultBaseStyle?.(props).excessLabel, {
54+
bg: "body.base",
55+
color: "background.base",
56+
ms: $mlBySize.reference,
57+
})
58+
)
59+
60+
const baseStyle = definePartsStyle((props) => ({
61+
container: baseStyleContainer(props),
62+
excessLabel: baseStyleExessLabel(props),
63+
}))
64+
65+
const USED_SIZES = ["xs", "sm", "md", "lg"] as const
66+
67+
const pickedDefaultSizes: { [k in (typeof USED_SIZES)[number]]?: object } =
68+
pick(defaultSizes, ...USED_SIZES)
69+
70+
const sizes = defineMergeStyles(pickedDefaultSizes, {
71+
xs: {
72+
group: {
73+
[$mlBySize.variable]: "space.-1",
74+
},
75+
excessLabel: {
76+
fontSize: "0.563rem",
77+
},
78+
},
79+
sm: {
80+
group: {
81+
[$mlBySize.variable]: "space.-2",
82+
},
83+
excessLabel: {
84+
fontSize: "sm",
85+
},
86+
},
87+
})
88+
89+
export const Avatar = defineMultiStyleConfig({
90+
baseStyle,
91+
// @ts-expect-error
92+
sizes,
93+
})

src/@chakra-ui/components/Badge.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { defineStyle, defineStyleConfig } from "@chakra-ui/react"
2+
import { badgeDefaultTheme, defineMergeStyles } from "./components.utils"
3+
4+
const { baseStyle: defaultBaseStyle } = badgeDefaultTheme
5+
6+
const baseStyle = defineMergeStyles(defaultBaseStyle, {
7+
borderRadius: "base",
8+
border: "1px solid",
9+
borderColor: "transparent",
10+
fontWeight: "initial",
11+
py: 1,
12+
px: 2,
13+
textTransform: "uppercase",
14+
})
15+
16+
const variantSecondary = defineStyle({
17+
borderColor: "primary100",
18+
color: "text",
19+
})
20+
21+
const variantSolid = defineStyle({
22+
color: "black300",
23+
background: "primary100",
24+
})
25+
26+
export const Badge = defineStyleConfig({
27+
baseStyle,
28+
variants: {
29+
solid: variantSolid,
30+
secondary: variantSecondary,
31+
},
32+
sizes: {
33+
sm: {
34+
py: 0,
35+
},
36+
lg: {
37+
px: 3,
38+
},
39+
},
40+
defaultProps: {
41+
variant: "solid",
42+
},
43+
})
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { createMultiStyleConfigHelpers, defineStyle } from "@chakra-ui/react"
2+
import { checkboxAnatomy } from "@chakra-ui/anatomy"
3+
import {
4+
checkboxDefaultTheme,
5+
commonInputTriggerStyles,
6+
defineMergeStyles,
7+
} from "./components.utils"
8+
9+
const { sizes: defaultSizes } = checkboxDefaultTheme
10+
11+
const { definePartsStyle, defineMultiStyleConfig } =
12+
createMultiStyleConfigHelpers(checkboxAnatomy.keys)
13+
14+
const { commonContainerProps, commonControlProps, commonLabelProps } =
15+
commonInputTriggerStyles
16+
17+
const checkboxMdSize = defaultSizes?.md
18+
19+
const baseStyleControl = defineMergeStyles(
20+
checkboxMdSize?.control,
21+
commonControlProps,
22+
{
23+
boxSize: "var(--checkbox-size)", // Comes from default theme
24+
borderRadius: "sm",
25+
}
26+
)
27+
28+
const baseStyleLabel = defineStyle({ ...commonLabelProps })
29+
30+
const baseStyleContainer = defineStyle({ ...commonContainerProps })
31+
32+
const baseStyleIcon = defineStyle({
33+
boxSize: 2,
34+
})
35+
36+
const baseStyle = definePartsStyle({
37+
container: baseStyleContainer,
38+
control: baseStyleControl,
39+
label: baseStyleLabel,
40+
icon: baseStyleIcon,
41+
})
42+
43+
export const Checkbox = defineMultiStyleConfig({
44+
baseStyle,
45+
})

0 commit comments

Comments
 (0)