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.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
define css vars using exported util
Oleg Isonen63121ab98738
diff --git a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/asset-info-tigger.tsx b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/asset-info-tigger.tsxindex 1fe10a496f..b28ee96555 100644--- a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/asset-info-tigger.tsx+++ b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/asset-info-tigger.tsx@@ -1,11 +1,15 @@import { useState } from "react";-import { Button, theme, Tooltip } from "@webstudio-is/design-system";-import { GearIcon } from "@webstudio-is/icons";+import { Button, Tooltip } from "@webstudio-is/design-system";+import { GearIcon, gearIconCssVars } from "@webstudio-is/icons";import { AssetInfo } from "./asset-info";import { PANEL_WIDTH } from "~/designer/shared/constants";import { Asset } from "@webstudio-is/asset-uploader";+export const assetInfoTriggerCssVars = ({ show }: { show: boolean }) => ({+ "--asset-info-trigger-visibility": show ? "visible" : "hidden",+});+export const AssetInfoTrigger = ({asset,onDelete,@@ -40,7 +44,7 @@ export const AssetInfoTrigger = ({title="Options"onClick={() => setTooltipOpen(true)}css={{- visibility: "var(--info-trigger-visibility)",+ visibility: "var(--asset-info-trigger-visibility, hidden)",position: "absolute",color: "$slate11",top: "$1",@@ -50,9 +54,10 @@ export const AssetInfoTrigger = ({"&:hover": {color: "$hiContrast",},+ ...gearIconCssVars({ fill: "$colors$loContrast" }),}}>- <GearIcon fill={String(theme.colors.loContrast)} />+ <GearIcon /></Button></Tooltip>);diff --git a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/asset-thumbnail.tsx b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/asset-thumbnail.tsxindex ab7a6c99a2..451cda46fb 100644--- a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/asset-thumbnail.tsx+++ b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/asset-thumbnail.tsx@@ -3,7 +3,7 @@ import { Box } from "@webstudio-is/design-system";import placeholderImage from "~/shared/images/image-placeholder.svg";import brokenImage from "~/shared/images/broken-image-placeholder.svg";import { UploadingAnimation } from "./uploading-animation";-import { AssetInfoTrigger } from "./asset-info-tigger";+import { AssetInfoTrigger, assetInfoTriggerCssVars } from "./asset-info-tigger";import { Asset, UploadingAsset } from "@webstudio-is/asset-uploader";const useImageWithFallback = ({@@ -67,10 +67,7 @@ export const AssetThumbnail = (asset: Asset | UploadingAsset) => {alignItems: "center",padding: "0 $2",position: "relative",- "--info-trigger-visibility": "hidden",- "&:hover": {- "--info-trigger-visibility": "visible",- },+ "&:hover": assetInfoTriggerCssVars({ show: true }),}}><Thumbnail path={path} status={status} />diff --git a/apps/designer/app/designer/features/topbar/topbar.tsx b/apps/designer/app/designer/features/topbar/topbar.tsxindex 86bc0c2915..f7125f59aa 100644--- a/apps/designer/app/designer/features/topbar/topbar.tsx+++ b/apps/designer/app/designer/features/topbar/topbar.tsx@@ -1,5 +1,4 @@import type { Publish } from "~/shared/pubsub";-import type { Project } from "@webstudio-is/prisma-client";import { darkTheme, Flex, type CSS } from "@webstudio-is/design-system";import type { Config } from "~/config";import { PreviewButton } from "./preview";diff --git a/packages/icons/src/gear.tsx b/packages/icons/src/gear.tsxindex 2d8ff07702..3609638bbe 100644--- a/packages/icons/src/gear.tsx+++ b/packages/icons/src/gear.tsx@@ -1,31 +1,40 @@import * as React from "react";import { IconProps } from "./types";-export const GearIcon = React.forwardRef<- SVGSVGElement,- IconProps & { fill?: string }->(({ color = "currentColor", fill = "none", ...props }, forwardedRef) => {- return (- <svg- width={16}- height={16}- viewBox="0 0 16 16"- fill="none"- xmlns="http://www.w3.org/2000/svg"- {...props}- ref={forwardedRef}- >- <path- d="M9.117 2.878c-.284-1.17-1.95-1.17-2.234 0a1.149 1.149 0 01-1.714.71c-1.03-.627-2.207.551-1.58 1.58a1.15 1.15 0 01-.711 1.715c-1.17.284-1.17 1.95 0 2.234a1.15 1.15 0 01.71 1.714c-.627 1.03.551 2.207 1.58 1.58a1.148 1.148 0 011.715.711c.284 1.17 1.95 1.17 2.234 0a1.15 1.15 0 011.714-.71c1.03.627 2.207-.551 1.58-1.58a1.148 1.148 0 01.711-1.715c1.17-.284 1.17-1.95 0-2.234a1.15 1.15 0 01-.71-1.714c.627-1.03-.551-2.207-1.58-1.58a1.15 1.15 0 01-1.715-.711z"- stroke={color}- strokeWidth={1.25}- strokeLinecap="round"- strokeLinejoin="round"- style={{ fill }}- />- <circle cx={8} cy={7.99988} r={1.875} stroke={color} strokeWidth={1.25} />- </svg>- );+export const gearIconCssVars = ({ fill }: { fill: string }) => ({+ "--gear-icon-fill": fill,});+export const GearIcon = React.forwardRef<SVGSVGElement, IconProps>(+ ({ color = "currentColor", ...props }, forwardedRef) => {+ return (+ <svg+ width={16}+ height={16}+ viewBox="0 0 16 16"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ ref={forwardedRef}+ >+ <path+ d="M9.117 2.878c-.284-1.17-1.95-1.17-2.234 0a1.149 1.149 0 01-1.714.71c-1.03-.627-2.207.551-1.58 1.58a1.15 1.15 0 01-.711 1.715c-1.17.284-1.17 1.95 0 2.234a1.15 1.15 0 01.71 1.714c-.627 1.03.551 2.207 1.58 1.58a1.148 1.148 0 011.715.711c.284 1.17 1.95 1.17 2.234 0a1.15 1.15 0 011.714-.71c1.03.627 2.207-.551 1.58-1.58a1.148 1.148 0 01.711-1.715c1.17-.284 1.17-1.95 0-2.234a1.15 1.15 0 01-.71-1.714c.627-1.03-.551-2.207-1.58-1.58a1.15 1.15 0 01-1.715-.711z"+ stroke={color}+ strokeWidth={1.25}+ strokeLinecap="round"+ strokeLinejoin="round"+ style={{ fill: "var(--gear-icon-fill, none)" }}+ />+ <circle+ cx={8}+ cy={7.99988}+ r={1.875}+ stroke={color}+ strokeWidth={1.25}+ />+ </svg>+ );+ }+);+GearIcon.displayName = "GearIcon";diff --git a/packages/icons/src/index.ts b/packages/icons/src/index.tsindex de149e8eda..9cceef89b6 100644--- a/packages/icons/src/index.ts+++ b/packages/icons/src/index.ts@@ -15,4 +15,4 @@ export * from "./cloud";export { TrashIcon } from "./trash";export { SizeIcon } from "./size";export { UploadIcon } from "./upload";-export { GearIcon } from "./gear";+export { GearIcon, gearIconCssVars } from "./gear";