Skip to content

Commit b52a113

Browse files
committed
Added new custom properties.
1 parent 358e276 commit b52a113

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

scripts/utils/custom-css-properties-list.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,11 @@
33
/*
44
* This file is only needed to generate the proper js and scss files in custom-css-properties script
55
*/
6-
const customCssPropertiesList = ["avatarSize"];
6+
const customCssPropertiesList = [
7+
"avatarSize",
8+
"rootBorderWidth",
9+
"focusRingBorderColor",
10+
"focusRingBorderRadius",
11+
"focusRingBorderWidth",
12+
];
713
export default customCssPropertiesList;

src/avatar/style.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { SYSTEM } from "../internal/environment";
5+
import customCssProps from "../internal/generated/custom-css-properties";
56
import { AvatarProps } from "./interfaces";
67

78
export function getRootStyles(style: AvatarProps.Style | undefined) {
@@ -13,10 +14,10 @@ export function getRootStyles(style: AvatarProps.Style | undefined) {
1314
borderRadius: style.root?.borderRadius,
1415
boxShadow: style.root?.boxShadow,
1516
color: style.root?.color,
16-
["--root-border-width"]: style.root?.borderWidth,
17-
["--focus-ring-border-color"]: style.root?.focusRing?.borderColor,
18-
["--focus-ring-border-radius"]: style.root?.focusRing?.borderRadius,
19-
["--focus-ring-border-width"]: style.root?.focusRing?.borderWidth,
17+
[customCssProps.rootBorderWidth]: style.root?.borderWidth,
18+
[customCssProps.focusRingBorderColor]: style.root?.focusRing?.borderColor,
19+
[customCssProps.focusRingBorderRadius]: style.root?.focusRing?.borderRadius,
20+
[customCssProps.focusRingBorderWidth]: style.root?.focusRing?.borderWidth,
2021
};
2122
}
2223

src/avatar/styles.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939

4040
&:focus-visible {
4141
@include shared.focus-highlight(
42-
$gutter: calc(4px + var(--root-border-width, 0px) + var(--focus-ring-border-width, 0px)),
43-
$border-radius: var(--focus-ring-border-radius, 50%),
44-
$border-color: var(--focus-ring-border-color, cs.$color-border-item-focused),
45-
$border-width: var(--focus-ring-border-width, 2px)
42+
$gutter: calc(4px + var(#{custom-props.$rootBorderWidth}, 0px) + var(#{custom-props.$focusRingBorderWidth}, 0px)),
43+
$border-radius: var(#{custom-props.$focusRingBorderRadius}, 50%),
44+
$border-color: var(#{custom-props.$focusRingBorderColor}, cs.$color-border-item-focused),
45+
$border-width: var(#{custom-props.$focusRingBorderWidth}, 2px)
4646
);
4747
}
4848

0 commit comments

Comments
 (0)