Skip to content

Commit 58a0da8

Browse files
authored
refactor: hyphenate all sections (#4981)
Migrated to hyphenated properties all left sections - filter - list item - transforms - typography
1 parent 935983b commit 58a0da8

File tree

10 files changed

+91
-95
lines changed

10 files changed

+91
-95
lines changed

apps/builder/app/builder/features/style-panel/sections/advanced/stores.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { computed } from "nanostores";
2-
import {
3-
hyphenateProperty,
4-
type CssProperty,
5-
type CssStyleMap,
6-
} from "@webstudio-is/css-engine";
2+
import type { CssProperty, CssStyleMap } from "@webstudio-is/css-engine";
73
import { $matchingBreakpoints, getDefinedStyles } from "../../shared/model";
84
import { sections } from "../sections";
95
import {
@@ -60,7 +56,7 @@ export const $advancedStylesLonghands = computed(
6056
const visualProperties = new Set<CssProperty>([]);
6157
for (const { properties } of sections.values()) {
6258
for (const property of properties) {
63-
visualProperties.add(hyphenateProperty(property));
59+
visualProperties.add(property);
6460
}
6561
}
6662
for (const style of definedStyles) {

apps/builder/app/builder/features/style-panel/sections/filter/filter.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Flex, Tooltip, Text } from "@webstudio-is/design-system";
22
import { InfoCircleIcon } from "@webstudio-is/icons";
33
import {
44
toValue,
5-
type StyleProperty,
5+
type CssProperty,
66
type StyleValue,
77
} from "@webstudio-is/css-engine";
88
import { RepeatedStyleSection } from "../../shared/style-section";
@@ -16,12 +16,8 @@ import { parseCssFragment } from "../../shared/css-fragment";
1616
import { useComputedStyleDecl } from "../../shared/model";
1717
import { humanizeString } from "~/shared/string-utils";
1818

19-
export const properties = ["filter"] satisfies [
20-
StyleProperty,
21-
...StyleProperty[],
22-
];
19+
export const properties = ["filter"] satisfies [CssProperty, ...CssProperty[]];
2320

24-
const property: StyleProperty = properties[0];
2521
const label = "Filters";
2622
const initialFilter = "blur(0px)";
2723

@@ -55,7 +51,7 @@ export const Section = () => {
5551
renderItemContent={(index, primaryValue) => (
5652
<FilterSectionContent
5753
index={index}
58-
property={property}
54+
property="filter"
5955
propertyValue={toValue(primaryValue)}
6056
layer={primaryValue}
6157
onEditLayer={(index, value, options) => {

apps/builder/app/builder/features/style-panel/sections/list-item.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { propertyDescriptions } from "@webstudio-is/css-data";
2-
import type { StyleProperty } from "@webstudio-is/css-engine";
2+
import type { CssProperty } from "@webstudio-is/css-engine";
33
import { Grid, theme } from "@webstudio-is/design-system";
44
import { SelectControl } from "../controls";
55
import { StyleSection } from "../shared/style-section";
66
import { PropertyLabel } from "../property-label";
77

8-
export const properties = ["listStyleType"] satisfies Array<StyleProperty>;
8+
export const properties = ["list-style-type"] satisfies CssProperty[];
99

1010
export const Section = () => {
1111
return (
@@ -14,9 +14,9 @@ export const Section = () => {
1414
<PropertyLabel
1515
label="List Style Type"
1616
description={propertyDescriptions.listStyleType}
17-
properties={["listStyleType"]}
17+
properties={["list-style-type"]}
1818
/>
19-
<SelectControl property="listStyleType" />
19+
<SelectControl property="list-style-type" />
2020
</Grid>
2121
</StyleSection>
2222
);

apps/builder/app/builder/features/style-panel/sections/sections.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ import * as advanced from "./advanced/advanced";
1616
import * as textShadows from "./text-shadows/text-shadows";
1717
import * as backdropFilter from "./backdrop-filter/backdrop-filter";
1818
import * as transforms from "./transforms/transforms";
19-
import type { CssProperty, StyleProperty } from "@webstudio-is/css-engine";
19+
import type { CssProperty } from "@webstudio-is/css-engine";
2020

2121
export const sections = new Map<
2222
string,
2323
{
24-
properties: (StyleProperty | CssProperty)[];
24+
properties: CssProperty[];
2525
Section: () => ReactNode;
2626
}
2727
>([

apps/builder/app/builder/features/style-panel/sections/transforms/transform-and-perspective-origin.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
import { propertyDescriptions, propertySyntaxes } from "@webstudio-is/css-data";
1+
import {
2+
camelCaseProperty,
3+
propertyDescriptions,
4+
propertySyntaxes,
5+
} from "@webstudio-is/css-data";
26
import { Flex, Grid, PositionGrid } from "@webstudio-is/design-system";
37
import {
48
KeywordValue,
59
StyleValue,
610
TupleValue,
711
UnitValue,
8-
type StyleProperty,
12+
type CssProperty,
913
} from "@webstudio-is/css-engine";
1014
import { styleConfigByName } from "../../shared/configs";
1115
import { useMemo } from "react";
@@ -21,9 +25,9 @@ import { useComputedStyleDecl } from "../../shared/model";
2125
// Fake properties to use in the CssValueInputContainer
2226
// x, y axis takes length | percentage | keyword
2327
// z axis takes length
24-
const fakePropertyX: StyleProperty = "backgroundPositionX";
25-
const fakePropertyY: StyleProperty = "backgroundPositionY";
26-
const fakePropertyZ: StyleProperty = "outlineOffset";
28+
const fakePropertyX: CssProperty = "background-position-x";
29+
const fakePropertyY: CssProperty = "background-position-y";
30+
const fakePropertyZ: CssProperty = "outline-offset";
2731

2832
const keywordToValue: Record<string, number> = {
2933
left: 0,
@@ -52,7 +56,7 @@ export const calculatePositionFromOrigin = (value: StyleValue | undefined) => {
5256
export const TransformAndPerspectiveOrigin = ({
5357
property,
5458
}: {
55-
property: StyleProperty;
59+
property: CssProperty;
5660
}) => {
5761
const styleDecl = useComputedStyleDecl(property);
5862
const value = styleDecl.cascadedValue;
@@ -142,7 +146,7 @@ export const TransformAndPerspectiveOrigin = ({
142146
],
143147
};
144148

145-
if (property === "transformOrigin" && origin.z !== undefined) {
149+
if (property === "transform-origin" && origin.z !== undefined) {
146150
value.value.push(origin.z);
147151
}
148152

@@ -153,7 +157,7 @@ export const TransformAndPerspectiveOrigin = ({
153157
<Grid gap="2">
154158
<PropertyLabel
155159
label={label}
156-
description={propertyDescriptions[property]}
160+
description={propertyDescriptions[camelCaseProperty(property)]}
157161
properties={[property]}
158162
/>
159163
<Flex gap="6">
@@ -171,10 +175,10 @@ export const TransformAndPerspectiveOrigin = ({
171175
<PropertyInlineLabel
172176
label="X"
173177
title={
174-
property === "transformOrigin" ? "X Offset" : "X Position"
178+
property === "transform-origin" ? "X Offset" : "X Position"
175179
}
176180
description={
177-
property === "transformOrigin"
181+
property === "transform-origin"
178182
? propertySyntaxes.transformOriginY
179183
: propertySyntaxes.perspectiveOriginX
180184
}
@@ -198,10 +202,10 @@ export const TransformAndPerspectiveOrigin = ({
198202
<PropertyInlineLabel
199203
label="Y"
200204
title={
201-
property === "transformOrigin" ? "Y Offset" : "Y Position"
205+
property === "transform-origin" ? "Y Offset" : "Y Position"
202206
}
203207
description={
204-
property === "transformOrigin"
208+
property === "transform-origin"
205209
? propertySyntaxes.transformOriginY
206210
: propertySyntaxes.perspectiveOriginY
207211
}
@@ -217,7 +221,7 @@ export const TransformAndPerspectiveOrigin = ({
217221
}
218222
/>
219223
</Grid>
220-
{property === "transformOrigin" && origin.z !== undefined && (
224+
{property === "transform-origin" && origin.z !== undefined && (
221225
<Grid
222226
gap="2"
223227
align="center"

apps/builder/app/builder/features/style-panel/sections/transforms/transform-scale.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
SmallToggleButton,
88
theme,
99
} from "@webstudio-is/design-system";
10-
import type { StyleValue, StyleProperty } from "@webstudio-is/css-engine";
10+
import type { StyleValue, CssProperty } from "@webstudio-is/css-engine";
1111
import {
1212
BorderRadiusIcon,
1313
XAxisIcon,
@@ -30,7 +30,7 @@ import {
3030
useComputedStyleDecl,
3131
} from "../../shared/model";
3232

33-
const property: StyleProperty = "scale";
33+
const property: CssProperty = "scale";
3434

3535
export const ScalePanelContent = () => {
3636
const styleDecl = useComputedStyleDecl(property);

apps/builder/app/builder/features/style-panel/sections/transforms/transform-translate.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Flex, Grid } from "@webstudio-is/design-system";
2-
import type { StyleProperty, StyleValue } from "@webstudio-is/css-engine";
2+
import type { CssProperty, StyleValue } from "@webstudio-is/css-engine";
33
import { XAxisIcon, YAxisIcon, ZAxisIcon } from "@webstudio-is/icons";
44
import { propertySyntaxes } from "@webstudio-is/css-data";
55
import { CssValueInputContainer } from "../../shared/css-value-input";
@@ -13,7 +13,7 @@ import {
1313
useComputedStyleDecl,
1414
} from "../../shared/model";
1515

16-
const property: StyleProperty = "translate";
16+
const property: CssProperty = "translate";
1717

1818
export const TranslatePanelContent = () => {
1919
const styleDecl = useComputedStyleDecl(property);

apps/builder/app/builder/features/style-panel/sections/transforms/transforms.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { forwardRef, type ElementRef, type ComponentProps } from "react";
2-
import type { StyleProperty } from "@webstudio-is/css-engine";
2+
import type { CssProperty } from "@webstudio-is/css-engine";
33
import { propertyDescriptions } from "@webstudio-is/css-data";
44
import {
55
CssValueListArrowFocus,
@@ -31,6 +31,16 @@ import {
3131
CollapsibleSectionRoot,
3232
useOpenState,
3333
} from "~/builder/shared/collapsible-section";
34+
import { humanizeString } from "~/shared/string-utils";
35+
import { getDots } from "../../shared/style-section";
36+
import {
37+
getPriorityStyleValueSource,
38+
PropertyLabel,
39+
PropertySectionLabel,
40+
} from "../../property-label";
41+
import { useComputedStyleDecl, useComputedStyles } from "../../shared/model";
42+
import { createBatchUpdate } from "../../shared/use-style-data";
43+
import { TextControl } from "../../controls";
3444
import {
3545
addDefaultsForTransormSection,
3646
isTransformPanelPropertyUsed,
@@ -44,33 +54,23 @@ import { TranslatePanelContent } from "./transform-translate";
4454
import { ScalePanelContent } from "./transform-scale";
4555
import { RotatePanelContent } from "./transform-rotate";
4656
import { SkewPanelContent } from "./transform-skew";
47-
import { humanizeString } from "~/shared/string-utils";
48-
import { getDots } from "../../shared/style-section";
4957
import { TransformAndPerspectiveOrigin } from "./transform-and-perspective-origin";
50-
import {
51-
getPriorityStyleValueSource,
52-
PropertyLabel,
53-
PropertySectionLabel,
54-
} from "../../property-label";
55-
import { useComputedStyleDecl, useComputedStyles } from "../../shared/model";
56-
import { createBatchUpdate } from "../../shared/use-style-data";
57-
import { TextControl } from "../../controls";
5858

5959
const label = "Transforms";
6060

6161
const advancedProperties = [
62-
"transformOrigin",
63-
"backfaceVisibility",
62+
"transform-origin",
63+
"backface-visibility",
6464
"perspective",
65-
"perspectiveOrigin",
66-
] satisfies [StyleProperty, ...StyleProperty[]];
65+
"perspective-origin",
66+
] satisfies [CssProperty, ...CssProperty[]];
6767

6868
export const properties = [
6969
"transform",
7070
"translate",
7171
"scale",
7272
...advancedProperties,
73-
] satisfies [StyleProperty, ...StyleProperty[]];
73+
] satisfies [CssProperty, ...CssProperty[]];
7474

7575
const TransformAdvancedButton = forwardRef<
7676
ElementRef<"button">,
@@ -113,11 +113,11 @@ const TransformAdvancedPopover = () => {
113113
<PropertyLabel
114114
label="Backface Visibility"
115115
description={propertyDescriptions.backfaceVisibility}
116-
properties={["backfaceVisibility"]}
116+
properties={["backface-visibility"]}
117117
/>
118-
<TextControl property="backfaceVisibility" />
118+
<TextControl property="backface-visibility" />
119119
</Grid>
120-
<TransformAndPerspectiveOrigin property="transformOrigin" />
120+
<TransformAndPerspectiveOrigin property="transform-origin" />
121121
<Grid css={{ gridTemplateColumns: `2fr 1fr` }}>
122122
<PropertyLabel
123123
label="Perspective"
@@ -126,7 +126,7 @@ const TransformAdvancedPopover = () => {
126126
/>
127127
<TextControl property="perspective" />
128128
</Grid>
129-
<TransformAndPerspectiveOrigin property="perspectiveOrigin" />
129+
<TransformAndPerspectiveOrigin property="perspective-origin" />
130130
</Grid>
131131
}
132132
>

0 commit comments

Comments
 (0)