Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 16 additions & 23 deletions apps/builder/app/builder/features/settings-panel/property-label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,18 @@ import {
rawTheme,
theme,
} from "@webstudio-is/design-system";
import { InfoCircleIcon } from "@webstudio-is/icons";
import { AlertIcon } from "@webstudio-is/icons";
import type { Prop } from "@webstudio-is/sdk";
import { showAttribute } from "@webstudio-is/react-sdk";
import { updateWebstudioData } from "~/shared/instance-utils";
import { $selectedInstance } from "~/shared/awareness";
import { $props, $registeredComponentPropsMetas } from "~/shared/nano-states";
import { humanizeAttribute, showAttributeMeta } from "./shared";
import { $selectedInstancePropsMetas, humanizeAttribute } from "./shared";

const usePropMeta = (name: string) => {
const store = useMemo(() => {
return computed(
[$selectedInstance, $registeredComponentPropsMetas],
(instance, propsMetas) => {
if (name === showAttribute) {
return showAttributeMeta;
}
const metas = propsMetas.get(instance?.component ?? "");
const propMeta = metas?.props[name];
return propMeta;
}
return computed($selectedInstancePropsMetas, (propsMetas) =>
propsMetas.get(name)
);
}, [name]);
return useStore(store);
Expand Down Expand Up @@ -144,6 +136,18 @@ export const PropertyLabel = ({
{label}
</Text>
{propMeta?.description && <Text>{propMeta.description}</Text>}
{readOnly && (
<Flex gap="1">
<AlertIcon
color={rawTheme.colors.backgroundAlertMain}
style={{ flexShrink: 0 }}
/>
<Text>
The value is controlled by an expression and cannot be
changed.
</Text>
</Flex>
)}
{isDeletable && (
<Button
color="dark"
Expand All @@ -167,17 +171,6 @@ export const PropertyLabel = ({
</Label>
</Tooltip>
</div>
{readOnly && (
<Tooltip
content="The value is controlled by an expression and cannot be changed."
variant="wrapped"
>
<InfoCircleIcon
color={rawTheme.colors.foregroundSubtle}
tabIndex={0}
/>
</Tooltip>
)}
</Flex>
);
};
Expand Down
11 changes: 7 additions & 4 deletions apps/builder/app/builder/features/settings-panel/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import equal from "fast-deep-equal";
import { ariaAttributes, attributesByTag } from "@webstudio-is/html-data";
import {
reactPropsToStandardAttributes,
showAttribute,
standardAttributesToReactProps,
} from "@webstudio-is/react-sdk";
import {
Expand Down Expand Up @@ -498,11 +499,13 @@ export const $selectedInstancePropsMetas = computed(
}
metas.set(name, propMeta);
}
metas.set(showAttribute, showAttributeMeta);
// ui should render in the following order
// 1. component properties
// 2. specific tag attributes
// 3. global html attributes
// 4. aria attributes
// 1. system properties
// 2. component properties
// 3. specific tag attributes
// 4. global html attributes
// 5. aria attributes
return new Map(Array.from(metas.entries()).reverse());
}
);