Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Show badges on inherited styles (#1911)

Bogdan Chadkinb5d65d4bfae4
diff --git a/apps/builder/app/builder/features/style-panel/shared/property-name.tsx b/apps/builder/app/builder/features/style-panel/shared/property-name.tsx
index 1430eecdf0..904660c9d7 100644
--- a/apps/builder/app/builder/features/style-panel/shared/property-name.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/property-name.tsx
@@ -77,6 +77,12 @@ const getSourceName = (
? selectedStyleSource.name
: "Local";
}
+
+ if (styleValueInfo.inherited?.styleSourceId !== undefined) {
+ const { styleSourceId } = styleValueInfo.inherited;
+ const styleSource = styleSources.get(styleSourceId);
+ return styleSource?.type === "token" ? styleSource.name : "Local";
+ }
};
const getBreakpointName = (
@@ -191,7 +197,9 @@ const TooltipContent = ({
</Text>
</ScrollArea>
{descriptionWithFallback && <Text>{descriptionWithFallback}</Text>}
- {styleSourceNameSet.size > 0 && (
+ {(styleSourceNameSet.size > 0 ||
+ // show badges when inherited from preset
+ (instanceSet.size > 0 && styleSourcesList.includes("remote"))) && (
<Flex
direction="column"
gap="1"
diff --git a/apps/builder/app/builder/features/style-panel/shared/style-info.test.ts b/apps/builder/app/builder/features/style-panel/shared/style-info.test.ts
index 891cca3c50..c37597b88e 100644
--- a/apps/builder/app/builder/features/style-panel/shared/style-info.test.ts
+++ b/apps/builder/app/builder/features/style-panel/shared/style-info.test.ts
@@ -202,6 +202,7 @@ test("compute inherited styles", () => {
},
"fontSize": {
"instanceId": "1",
+ "styleSourceId": "styleSourceId1",
"value": {
"type": "unit",
"unit": "px",
@@ -210,6 +211,7 @@ test("compute inherited styles", () => {
},
"fontWeight": {
"instanceId": "2",
+ "styleSourceId": "styleSourceId2",
"value": {
"type": "keyword",
"value": "600",
diff --git a/apps/builder/app/builder/features/style-panel/shared/style-info.ts b/apps/builder/app/builder/features/style-panel/shared/style-info.ts
index fb69096a4f..397a2c13fa 100644
--- a/apps/builder/app/builder/features/style-panel/shared/style-info.ts
+++ b/apps/builder/app/builder/features/style-panel/shared/style-info.ts
@@ -44,6 +44,7 @@ type CascadedProperties = {
type InheritedValueInfo = {
instanceId: string;
+ styleSourceId?: StyleSourceType["id"];
value: StyleValue;
};
@@ -329,6 +330,7 @@ export const getInheritedInfo = (
) {
inheritedStyle[styleDecl.property] = {
instanceId: ancestorInstance.id,
+ styleSourceId: styleDecl.styleSourceId,
value: styleDecl.value,
};
}