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.

Update background-image-control.tsx

Oleg Isonen8f23b1e87c5b
diff --git a/apps/designer/app/designer/features/style-panel/controls/background-image/background-image-control.tsx b/apps/designer/app/designer/features/style-panel/controls/background-image/background-image-control.tsx
index 46e7031767..d213201d2c 100644
--- a/apps/designer/app/designer/features/style-panel/controls/background-image/background-image-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/background-image/background-image-control.tsx
@@ -1,26 +1,17 @@
-import { Grid, TextField } from "@webstudio-is/design-system";
+import { TextField } from "@webstudio-is/design-system";
import type { ControlProps } from "../../style-sections";
import { getFinalValue } from "../../shared/get-final-value";
-import { PropertyName } from "../../shared/property-name";
import { ValuePickerPopover } from "../../shared/value-picker-popover";
import { ImageManager } from "~/designer/shared/image-manager";
-//import { useAssets } from "~/designer/shared/assets";
-
-// @todo get rid of this custom styling, it should be part of the design system and/or reused across style panel
-const textFieldStyle = {
- paddingLeft: "calc($sizes$1 + $nudge$3)",
- textAlign: "left",
- height: "$6",
- fontWeight: "500",
-};
+import { useAssets } from "~/designer/shared/assets";
export const BackgroundImageControl = ({
currentStyle,
inheritedStyle,
- //setProperty,
+ setProperty,
styleConfig,
}: ControlProps) => {
- //const { assets } = useAssets("image");
+ const { assets } = useAssets("image");
// @todo show which instance we inherited the value from
const value = getFinalValue({
currentStyle,
@@ -30,31 +21,23 @@ export const BackgroundImageControl = ({
if (value === undefined) return null;
- //const setValue = setProperty(styleConfig.property);
+ const setValue = setProperty(styleConfig.property);
- //const selectedAsset = assets.find((asset) => asset.id === value.value);
+ const selectedAsset = assets.find((asset) => asset.id === value.value);
return (
- <Grid columns={2}>
- <PropertyName property={styleConfig.property} label={styleConfig.label} />
- <ValuePickerPopover
- title="Images"
- content={
- <ImageManager
- onSelect={() => {
- //setValue(asset.id);
- }}
- />
- }
- >
- {/* @todo this should be part of the design system, probably a varian="button" */}
- <TextField
- css={textFieldStyle}
- spellCheck={false}
- readOnly
- //defaultValue={selectedAsset?.name}
+ <ValuePickerPopover
+ title="Images"
+ content={
+ <ImageManager
+ onSelect={(asset) => {
+ setValue(asset.id);
+ }}
/>
- </ValuePickerPopover>
- </Grid>
+ }
+ >
+ {/* @todo this should be part of the design system, probably a varian="button" */}
+ <TextField defaultValue={selectedAsset?.name} />
+ </ValuePickerPopover>
);
};