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.

feat: Allow maximizing CSS value for complex values (#4566)

Oleg Isonen215034f4d87d
diff --git a/apps/builder/app/builder/features/pages/page-settings.tsx b/apps/builder/app/builder/features/pages/page-settings.tsx
index b13c673071..cd875fcd14 100644
--- a/apps/builder/app/builder/features/pages/page-settings.tsx
+++ b/apps/builder/app/builder/features/pages/page-settings.tsx
@@ -677,7 +677,7 @@ const MarketplaceSection = ({
justifySelf: "start",
}}
>
- <Grid gap={1} css={{ width: theme.sizes.sidebarWidth }}>
+ <Grid gap={1} css={{ width: theme.spacing[30] }}>
{category && <Label text="title">{category}</Label>}
<Card
title={values.name}
diff --git a/apps/builder/app/builder/features/project-settings/section-general.tsx b/apps/builder/app/builder/features/project-settings/section-general.tsx
index b08025d19d..876f33a4c7 100644
--- a/apps/builder/app/builder/features/project-settings/section-general.tsx
+++ b/apps/builder/app/builder/features/project-settings/section-general.tsx
@@ -196,6 +196,7 @@ export const SectionGeneral = () => {
lang="html"
value={meta.code ?? ""}
onChange={handleSave("code")}
+ onChangeComplete={handleSave("code")}
/>
</Grid>
</Grid>
diff --git a/apps/builder/app/builder/features/settings-panel/controls/code.tsx b/apps/builder/app/builder/features/settings-panel/controls/code.tsx
index 397399608f..28deeae89d 100644
--- a/apps/builder/app/builder/features/settings-panel/controls/code.tsx
+++ b/apps/builder/app/builder/features/settings-panel/controls/code.tsx
@@ -173,7 +173,7 @@ export const CodeControl = ({
setError(undefined);
localValue.set(value);
}}
- onBlur={localValue.save}
+ onChangeComplete={localValue.save}
/>
<BindingPopover
scope={scope}
diff --git a/apps/builder/app/builder/features/settings-panel/controls/json.tsx b/apps/builder/app/builder/features/settings-panel/controls/json.tsx
index b4d5428e36..647242cd57 100644
--- a/apps/builder/app/builder/features/settings-panel/controls/json.tsx
+++ b/apps/builder/app/builder/features/settings-panel/controls/json.tsx
@@ -74,7 +74,7 @@ export const JsonControl = ({
readOnly={overwritable === false}
value={localValue.value}
onChange={localValue.set}
- onBlur={localValue.save}
+ onChangeComplete={localValue.save}
/>
<BindingPopover
scope={scope}
diff --git a/apps/builder/app/builder/features/settings-panel/resource-panel.tsx b/apps/builder/app/builder/features/settings-panel/resource-panel.tsx
index 283a60bb24..8457ae45c6 100644
--- a/apps/builder/app/builder/features/settings-panel/resource-panel.tsx
+++ b/apps/builder/app/builder/features/settings-panel/resource-panel.tsx
@@ -515,7 +515,7 @@ const BodyField = ({
) ?? "")
}
onChange={onChange}
- onBlur={() => bodyRef.current?.checkValidity()}
+ onChangeComplete={() => bodyRef.current?.checkValidity()}
/>
</div>
) : (
@@ -943,7 +943,7 @@ export const GraphqlResourceForm = forwardRef<
) ?? "")
}
onChange={setVariables}
- onBlur={() => variablesRef.current?.checkValidity()}
+ onChangeComplete={() => variablesRef.current?.checkValidity()}
/>
</div>
</InputErrorsTooltip>
diff --git a/apps/builder/app/builder/features/settings-panel/variable-popover.tsx b/apps/builder/app/builder/features/settings-panel/variable-popover.tsx
index 91e68acfd7..f3ebfc7a75 100644
--- a/apps/builder/app/builder/features/settings-panel/variable-popover.tsx
+++ b/apps/builder/app/builder/features/settings-panel/variable-popover.tsx
@@ -470,7 +470,7 @@ const JsonForm = forwardRef<
color={valueError ? "error" : undefined}
value={value}
onChange={setValue}
- onBlur={() => valueRef.current?.checkValidity()}
+ onChangeComplete={() => valueRef.current?.checkValidity()}
/>
</Flex>
</>
@@ -667,7 +667,7 @@ export const VariablePopoverTrigger = forwardRef<
// flex fixes content overflowing artificial scroll area
display: "flex",
flexDirection: "column",
- width: theme.sizes.sidebarWidth,
+ width: theme.spacing[30],
}}
>
<Flex
diff --git a/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-gradient.tsx b/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-gradient.tsx
index 838e79a9e1..93cddb9353 100644
--- a/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-gradient.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-gradient.tsx
@@ -13,7 +13,11 @@ import {
editRepeatedStyleItem,
setRepeatedStyleItem,
} from "../../shared/repeated-style";
-import { parseCssFragment, CssFragmentEditor } from "../../shared/css-fragment";
+import {
+ parseCssFragment,
+ CssFragmentEditor,
+ CssFragmentEditorContent,
+} from "../../shared/css-fragment";
type IntermediateValue = {
type: "intermediate";
@@ -137,17 +141,15 @@ export const BackgroundGradient = ({ index }: { index: number }) => {
</Flex>
</Label>
<CssFragmentEditor
- invalid={intermediateValue?.type === "invalid"}
- autoFocus={styleValue.type === "var"}
- value={textAreaValue ?? ""}
- onChange={handleChange}
- onBlur={handleOnComplete}
- onKeyDown={(event) => {
- if (event.key === "Enter") {
- handleOnComplete();
- event.preventDefault();
- }
- }}
+ content={
+ <CssFragmentEditorContent
+ invalid={intermediateValue?.type === "invalid"}
+ autoFocus={styleValue.type === "var"}
+ value={textAreaValue ?? ""}
+ onChange={handleChange}
+ onChangeComplete={handleOnComplete}
+ />
+ }
/>
</Flex>
);
diff --git a/apps/builder/app/builder/features/style-panel/sections/backgrounds/backgrounds.stories.tsx b/apps/builder/app/builder/features/style-panel/sections/backgrounds/backgrounds.stories.tsx
index b72572f7ac..495371b97e 100644
--- a/apps/builder/app/builder/features/style-panel/sections/backgrounds/backgrounds.stories.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/backgrounds/backgrounds.stories.tsx
@@ -52,7 +52,7 @@ $awareness.set({
});
const Panel = styled("div", {
- width: theme.sizes.sidebarWidth,
+ width: theme.spacing[30],
});
export const Backgrounds = () => {
diff --git a/apps/builder/app/builder/features/style-panel/sections/borders/borders.stories.tsx b/apps/builder/app/builder/features/style-panel/sections/borders/borders.stories.tsx
index 47ef991b0b..4708e3fbd3 100644
--- a/apps/builder/app/builder/features/style-panel/sections/borders/borders.stories.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/borders/borders.stories.tsx
@@ -2,7 +2,7 @@ import { styled, theme } from "@webstudio-is/design-system";
import { Section } from "./borders";
const Panel = styled("div", {
- width: theme.sizes.sidebarWidth,
+ width: theme.spacing[30],
boxSizing: "border-box",
});
diff --git a/apps/builder/app/builder/features/style-panel/sections/shared/input-popover.tsx b/apps/builder/app/builder/features/style-panel/sections/shared/input-popover.tsx
index fb323c7232..be9b479151 100644
--- a/apps/builder/app/builder/features/style-panel/sections/shared/input-popover.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/shared/input-popover.tsx
@@ -79,7 +79,7 @@ const Input = ({
batch.setProperty(property)(styleValue);
batch.publish({ isEphemeral: true });
}}
- onChangeComplete={({ value, altKey, shiftKey }) => {
+ onChangeComplete={({ value, close = true, altKey, shiftKey }) => {
const activeProperties = getActiveProperties({
altKey,
shiftKey,
@@ -93,7 +93,9 @@ const Input = ({
batch.setProperty(property)(value);
}
batch.publish();
- onClosePopover();
+ if (close) {
+ onClosePopover();
+ }
}}
onAbort={() => {
const batch = createBatchUpdate();
diff --git a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-content.tsx b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-content.tsx
index af3e70cb66..ad3756a040 100644
--- a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-content.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-content.tsx
@@ -231,7 +231,7 @@ export const TransitionContent = ({ index }: { index: number }) => {
css={{
padding: theme.panel.padding,
gap: theme.spacing[3],
- minWidth: theme.sizes.sidebarWidth,
+ minWidth: theme.spacing[30],
}}
>
<Label>
diff --git a/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.stories.tsx b/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.stories.tsx
index efe6250182..eee6514016 100644
--- a/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.stories.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.stories.tsx
@@ -12,7 +12,7 @@ import { Section } from "./transitions";
import { $awareness } from "~/shared/awareness";
const Panel = styled("div", {
- width: theme.sizes.sidebarWidth,
+ width: theme.spacing[30],
boxShadow: theme.shadows.panelSectionDropShadow,
});
diff --git a/apps/builder/app/builder/features/style-panel/sections/typography/typography.tsx b/apps/builder/app/builder/features/style-panel/sections/typography/typography.tsx
index e2f871d8dd..09047200a8 100644
--- a/apps/builder/app/builder/features/style-panel/sections/typography/typography.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/typography/typography.tsx
@@ -283,7 +283,7 @@ const TypographySectionAdvancedPopover = () => {
css={{
padding: theme.panel.padding,
gap: theme.spacing[9],
- width: theme.sizes.sidebarWidth,
+ width: theme.spacing[30],
}}
>
<Grid css={{ gridTemplateColumns: "5fr 5fr" }} gap={2}>
diff --git a/apps/builder/app/builder/features/style-panel/shared/css-fragment.tsx b/apps/builder/app/builder/features/style-panel/shared/css-fragment.tsx
index 0d7cc133a0..0926fac112 100644
--- a/apps/builder/app/builder/features/style-panel/shared/css-fragment.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/css-fragment.tsx
@@ -1,4 +1,4 @@
-import { useMemo, useRef } from "react";
+import { useMemo, useRef, type ComponentProps, type ReactNode } from "react";
import { matchSorter, type RankingInfo } from "match-sorter";
import { EditorView, keymap, tooltips } from "@codemirror/view";
import { css } from "@codemirror/lang-css";
@@ -10,7 +10,10 @@ import {
import { parseCss } from "@webstudio-is/css-data";
import { css as style } from "@webstudio-is/design-system";
import {
- CodeEditorBase,
+ EditorContent,
+ EditorDialog,
+ EditorDialogButton,
+ EditorDialogControl,
getMinMaxHeightVars,
} from "~/builder/shared/code-editor-base";
import { $availableVariables } from "./model";
@@ -65,15 +68,10 @@ const wrapperStyle = style({
...getMinMaxHeightVars({ minHeight: "40px", maxHeight: "80px" }),
});
-export const CssFragmentEditor = ({
+export const CssFragmentEditorContent = ({
onKeyDown,
...props
-}: {
- invalid?: boolean;
- autoFocus?: boolean;
- value: string;
- onChange: (newValue: string) => void;
- onBlur?: (event: FocusEvent) => void;
+}: ComponentProps<typeof EditorContent> & {
onKeyDown?: (event: KeyboardEvent) => void;
}) => {
const onKeyDownRef = useRef(onKeyDown);
@@ -96,10 +94,33 @@ export const CssFragmentEditor = ({
}),
];
}, []);
+ return <EditorContent extensions={extensions} {...props} />;
+};
+export const CssFragmentEditor = ({
+ title,
+ open,
+ content,
+ onOpenChange,
+}: {
+ title?: ReactNode;
+ open?: boolean;
+ content: ReactNode;
+ onOpenChange?: (newOpen: boolean) => void;
+}) => {
return (
<div className={wrapperStyle()}>
- <CodeEditorBase {...props} extensions={extensions} />
+ <EditorDialogControl>
+ {content}
+ <EditorDialog
+ open={open}
+ onOpenChange={onOpenChange}
+ title={title}
+ content={content}
+ >
+ <EditorDialogButton />
+ </EditorDialog>
+ </EditorDialogControl>
</div>
);
};
diff --git a/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.stories.tsx b/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.stories.tsx
index 6714c32bad..0c464fa06c 100644
--- a/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.stories.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.stories.tsx
@@ -158,7 +158,7 @@ export const WithUnits = () => {
);
};
-export const AutoScroll = () => {
+export const Oversized = () => {
const [value, setValue] = React.useState<StyleValue>({
type: "var",
value: "start-test-test-test-test-test-test-test-end",
diff --git a/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx b/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx
index ae5d20d516..99dff139d1 100644
--- a/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx
@@ -53,6 +53,7 @@ import { mergeRefs } from "@react-aria/utils";
import { composeEventHandlers } from "~/shared/event-utils";
import type { StyleValueSourceColor } from "~/shared/style-object-model";
import { ColorThumb } from "../color-thumb";
+import { cssButtonDisplay, ValueEditorDialog } from "./value-editor-dialog";
// We need to enable scrub on properties that can have numeric value.
const canBeNumber = (property: StyleProperty, value: CssValueInputValue) => {
@@ -240,8 +241,10 @@ type ChangeCompleteEvent = {
| "scrub-end"
| "unit-select"
| "keyword-select"
- | "delta";
+ | "delta"
+ | "dialog-change-complete";
value: StyleValue;
+ close?: boolean;
} & Modifiers;
type CssValueInputProps = Pick<
@@ -296,11 +299,8 @@ const itemToString = (item: CssValueInputValue | null) => {
const scrollAhead = ({ target, clientX }: MouseEvent) => {
const element = target as HTMLInputElement;
- // Get the scrollable width of the input element
- const scrollWidth = element.scrollWidth;
- const visibleWidth = element.clientWidth;
- if (scrollWidth === visibleWidth) {
+ if (element.scrollWidth === element.clientWidth) {
// Nothing to scroll.
return false;
}
@@ -323,7 +323,8 @@ const scrollAhead = ({ target, clientX }: MouseEvent) => {
// Calculate the scroll position corresponding to the adjusted percentage
const scrollPosition =
- (adjustedMousePercentageX / 100) * (scrollWidth - visibleWidth);
+ (adjustedMousePercentageX / 100) *
+ (element.scrollWidth - element.clientWidth);
// Scroll the input element
element.scroll({ left: scrollPosition });
@@ -344,9 +345,7 @@ const getAutoScrollProps = () => {
abort("focused");
return;
}
-
if (scrollAhead(event) === false) {
- // Nothing to scroll.
return;
}
@@ -464,6 +463,7 @@ export const CssValueInput = ({
event: {
type: ChangeCompleteEvent["type"];
value: CssValueInputValue;
+ close?: boolean;
} & Partial<Modifiers>
) => {
const { value } = event;
@@ -655,8 +655,20 @@ export const CssValueInput = ({
const menuProps = getMenuProps();
+ const getInputValue = () => {
+ const isFocused = document.activeElement === inputRef.current;
+ // When input is not focused, we are removing var() to fit more into the small inputs.
+ return value.type === "var" && isFocused === false
+ ? `--${value.value}`
+ : inputProps.value;
+ };
const handleOnBlur: KeyboardEventHandler = (event) => {
inputProps.onBlur(event);
+
+ // Restore the value without var()
+ if (event.target instanceof HTMLInputElement) {
+ event.target.value = getInputValue();
+ }
// When unit select is open, onBlur is triggered,though we don't want a change event in this case.
if (isUnitsOpen) {
return;
@@ -674,6 +686,7 @@ export const CssValueInput = ({
onAbort();
return;
}
+
onChangeComplete({ value, type: "blur" });
};
@@ -688,30 +701,14 @@ export const CssValueInput = ({
</NestedIconLabel>
));
- const keywordButtonElement = (
- <NestedInputButton
- {...getToggleButtonProps()}
- data-state={isOpen ? "open" : "closed"}
- tabIndex={-1}
- />
- );
-
- const isUnitValue = unitSelectElement !== null;
-
- const hasItems = items.length !== 0;
- const isKeywordValue = value.type === "keyword" && hasItems;
- const suffixRef = useRef<HTMLDivElement | null>(null);
-
- const suffix =
- showSuffix === false ? null : (
- <Flex align="center" ref={suffixRef}>
- {isUnitValue
- ? unitSelectElement
- : isKeywordValue
- ? keywordButtonElement
- : null}
- </Flex>
- );
+ const keywordButtonElement =
+ value.type === "keyword" && items.length !== 0 ? (
+ <NestedInputButton
+ {...getToggleButtonProps()}
+ data-state={isOpen ? "open" : "closed"}
+ tabIndex={-1}
+ />
+ ) : undefined;
let description;
// When user hovers or focuses an item in the combobox list we want to show the description of the item and otherwise show the description of the current value
@@ -808,6 +805,14 @@ export const CssValueInput = ({
}
};
+ const { abort, ...autoScrollProps } = useMemo(() => {
+ return getAutoScrollProps();
+ }, []);
+
+ useEffect(() => {
+ return () => abort("unmount");
+ }, [abort]);
+
const inputPropsHandleKeyDown = composeEventHandlers(
composeEventHandlers(handleUpDownNumeric, inputProps.onKeyDown, {
// Pass prevented events to the combobox (e.g., the Escape key doesn't work otherwise, as it's blocked by Radix)
@@ -816,12 +821,27 @@ export const CssValueInput = ({
handleMetaEnter
);
- const { abort, ...autoScrollProps } = useMemo(() => {
- return getAutoScrollProps();
- }, []);
- useEffect(() => {
- return () => abort("unmount");
- }, [abort]);
+ const suffixRef = useRef<HTMLDivElement | null>(null);
+ const valueEditorButtonElement =
+ value.type === "unparsed" ? (
+ <ValueEditorDialog
+ property={property}
+ value={inputProps.value}
+ onChangeComplete={(value) => {
+ onChangeComplete({
+ type: "dialog-change-complete",
+ value,
+ close: false,
+ });
+ }}
+ />
+ ) : undefined;
+ const invalidValueElement = value.type === "invalid" ? <></> : undefined;
+ const suffixElement =
+ invalidValueElement ??
+ unitSelectElement ??
+ keywordButtonElement ??
+ valueEditorButtonElement;
return (
<ComboboxRoot open={isOpen}>
@@ -834,10 +854,13 @@ export const CssValueInput = ({
fieldSizing={fieldSizing}
{...inputProps}
{...autoScrollProps}
- onFocus={() => {
- const isFocused = document.activeElement === inputRef.current;
- if (isFocused) {
- inputRef.current?.select();
+ value={getInputValue()}
+ onFocus={(event) => {
+ if (event.target instanceof HTMLInputElement) {
+ // We are setting the value on focus because we might have removed the var() from the value,
+ // but once focused, we need to show the full value
+ event.target.value = itemToString(value);
+ event.target.select();
}
}}
autoFocus={autoFocus}
@@ -848,8 +871,18 @@ export const CssValueInput = ({
name={property}
color={value.type === "invalid" ? "error" : undefined}
prefix={finalPrefix}
- suffix={suffix}
- css={{ cursor: "default", minWidth: "2em" }}
+ suffix={
+ <Flex align="center" ref={suffixRef}>
+ {suffixElement}
+ </Flex>
+ }
+ css={{
+ cursor: "default",
+ minWidth: "2em",
+ "&:hover": {
+ [cssButtonDisplay]: "block",
+ },
+ }}
text={text}
/>
</ComboboxAnchor>
diff --git a/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select.tsx b/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select.tsx
index b15f50e4ef..3d28a0b977 100644
--- a/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select.tsx
@@ -36,41 +36,47 @@ export const useUnitSelect = ({
value,
onChange,
onCloseAutoFocus,
-}: UseUnitSelectType): [boolean, JSX.Element | null] => {
+}: UseUnitSelectType): [boolean, JSX.Element | undefined] => {
const [isOpen, setIsOpen] = useState(false);
- const unit =
- value.type === "unit" || value.type === "intermediate"
- ? value.unit
- : undefined;
-
const options = useMemo(
() => buildOptions(property, value, nestedSelectButtonUnitless),
[property, value]
);
- if (options.length === 0) {
- return [isOpen, null];
- }
+ const unit =
+ value.type === "unit" || value.type === "intermediate"
+ ? value.unit
+ : undefined;
- const unitOrKeyword: string | undefined =
+ const unitOrKeywordValue: string | undefined =
unit ?? (value.type === "keyword" ? value.value : undefined);
+ if (
+ options.length === 0 ||
+ value.type === "var" ||
+ value.type === "unparsed" ||
+ value.type === "invalid" ||
+ unitOrKeywordValue === undefined
+ ) {
+ return [isOpen, undefined];
+ }
+
const select = (
<UnitSelect
- value={unitOrKeyword}
+ value={unitOrKeywordValue}
label={unit ?? nestedSelectButtonUnitless}
options={options}
open={isOpen}
onCloseAutoFocus={onCloseAutoFocus}
onOpenChange={setIsOpen}
- onChange={(unitOption) => {
- if (unitOption.type === "keyword") {
- onChange({ type: "keyword", value: unitOption.id });
+ onChange={(option) => {
+ if (option.type === "keyword") {
+ onChange({ type: "keyword", value: option.id });
return;
}
- onChange({ type: "unit", value: unitOption.id });
+ onChange({ type: "unit", value: option.id });
}}
/>
);
diff --git a/apps/builder/app/builder/features/style-panel/shared/css-value-input/value-editor-dialog.tsx b/apps/builder/app/builder/features/style-panel/shared/css-value-input/value-editor-dialog.tsx
new file mode 100644
index 0000000000..55c690db56
--- /dev/null
+++ b/apps/builder/app/builder/features/style-panel/shared/css-value-input/value-editor-dialog.tsx
@@ -0,0 +1,120 @@
+import {
+ NestedInputButton,
+ rawTheme,
+ theme,
+} from "@webstudio-is/design-system";
+import { MaximizeIcon } from "@webstudio-is/icons";
+import { useEffect, useRef, useState } from "react";
+import { EditorDialog } from "~/builder/shared/code-editor-base";
+import { CssFragmentEditorContent } from "../css-fragment";
+import type { IntermediateStyleValue } from "./css-value-input";
+import {
+ type InvalidValue,
+ type StyleProperty,
+ type StyleValue,
+} from "@webstudio-is/css-engine";
+import { parseIntermediateOrInvalidValue } from "./parse-intermediate-or-invalid-value";
+
+export const cssButtonDisplay = "--ws-css-value-input-maximize-button-display";
+
+const width = parseFloat(rawTheme.sizes.sidebarWidth);
+
+export const ValueEditorDialog = ({
+ property,
+ value,
+ onChangeComplete,
+}: {
+ property: StyleProperty;
+ value: string;
+ onChangeComplete: (value: StyleValue) => void;
+}) => {
+ const [intermediateValue, setIntermediateValue] = useState<
+ IntermediateStyleValue | InvalidValue | undefined
+ >({ type: "intermediate", value });
+
+ useEffect(() => {
+ setIntermediateValue({ type: "intermediate", value });
+ }, [value]);
+
+ const triggerRef = useRef<HTMLButtonElement>(null);
+
+ const [rect, setRect] = useState(() => ({
+ height: 200,
+ width,
+ x: window.innerWidth - width,
+ y: 0,
+ }));
+
+ const handleOpenChange = (isOpen: boolean) => {
+ if (isOpen && triggerRef.current) {
+ const triggerRect = triggerRef.current.getBoundingClientRect();
+ setRect({
+ ...rect,
+ y: triggerRect.y,
+ });
+ }
+ };
+
+ const handleChange = (value: string) => {
+ const parsedValue = parseIntermediateOrInvalidValue(property, {
+ type: "intermediate",
+ value,
+ });
+
+ if (parsedValue.type === "invalid") {
+ setIntermediateValue({
+ type: "invalid",
+ value,
+ });
+ return;
+ }
+
+ if (parsedValue) {
+ setIntermediateValue({
+ type: "intermediate",
+ value,
+ });
+ }
+
+ return parsedValue;
+ };
+
+ const handleChangeComplete = (value: string) => {
+ const parsedValue = handleChange(value);
+ if (parsedValue) {
+ onChangeComplete(parsedValue);
+ }
+ };
+
+ return (
+ <EditorDialog
+ title="CSS Value"
+ onOpenChange={handleOpenChange}
+ {...rect}
+ content={
+ <CssFragmentEditorContent
+ autoFocus
+ value={intermediateValue?.value ?? value ?? ""}
+ invalid={intermediateValue?.type === "invalid"}
+ showShortcuts
+ onChange={handleChange}
+ onChangeComplete={handleChangeComplete}
+ />
+ }
+ >
+ <NestedInputButton
+ tabIndex={-1}
+ css={{
+ display: `var(${cssButtonDisplay}, none)`,
+ background: theme.colors.backgroundControls,
+ '&[data-state="open"]': {
+ display: "block",
+ },
+ }}
+ ref={triggerRef}
+ >
+ <MaximizeIcon size={12} />
+ </NestedInputButton>
+ </EditorDialog>
+ );
+};
diff --git a/apps/builder/app/builder/features/style-panel/shared/filter-content.tsx b/apps/builder/app/builder/features/style-panel/shared/filter-content.tsx
index 5a902111ed..ef6fff8f3c 100644
--- a/apps/builder/app/builder/features/style-panel/shared/filter-content.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/filter-content.tsx
@@ -240,7 +240,7 @@ export const FilterSectionContent = ({
css={{
padding: theme.panel.padding,
gap: theme.spacing[3],
- minWidth: theme.sizes.sidebarWidth,
+ minWidth: theme.spacing[30],
}}
>
<Label>
diff --git a/apps/builder/app/builder/features/style-panel/shared/shadow-content.tsx b/apps/builder/app/builder/features/style-panel/shared/shadow-content.tsx
index 4a0496ef7f..31827e5579 100644
--- a/apps/builder/app/builder/features/style-panel/shared/shadow-content.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/shadow-content.tsx
@@ -35,7 +35,11 @@ import type { IntermediateStyleValue } from "../shared/css-value-input";
import { CssValueInputContainer } from "../shared/css-value-input";
import { toPascalCase } from "../shared/keyword-utils";
import type { StyleUpdateOptions } from "../shared/use-style-data";
-import { CssFragmentEditor, parseCssFragment } from "./css-fragment";
+import {
+ CssFragmentEditor,
+ CssFragmentEditorContent,
+ parseCssFragment,
+} from "./css-fragment";
import { PropertyInlineLabel } from "../property-label";
import { styleConfigByName } from "./configs";
import { ColorPicker } from "./color-picker";
@@ -383,7 +387,7 @@ export const ShadowContent = ({
css={{
padding: theme.panel.padding,
gap: theme.spacing[3],
- minWidth: theme.sizes.sidebarWidth,
+ minWidth: theme.spacing[30],
}}
>
<Label>
@@ -407,17 +411,15 @@ export const ShadowContent = ({
</Flex>
</Label>
<CssFragmentEditor
- invalid={intermediateValue?.type === "invalid"}
- autoFocus={layer.type === "var"}
- value={intermediateValue?.value ?? propertyValue ?? ""}
- onChange={handleChange}
- onBlur={handleComplete}
- onKeyDown={(event) => {
- if (event.key === "Enter") {
- handleComplete();
- event.preventDefault();
- }
- }}
+ content={
+ <CssFragmentEditorContent
+ invalid={intermediateValue?.type === "invalid"}
+ autoFocus={layer.type === "var"}
+ value={intermediateValue?.value ?? propertyValue ?? ""}
+ onChange={handleChange}
+ onChangeComplete={handleComplete}
+ />
+ }
/>
</Flex>
</>
diff --git a/apps/builder/app/builder/features/topbar/topbar.tsx b/apps/builder/app/builder/features/topbar/topbar.tsx
index ff97a85037..2015df68f4 100644
--- a/apps/builder/app/builder/features/topbar/topbar.tsx
+++ b/apps/builder/app/builder/features/topbar/topbar.tsx
@@ -119,7 +119,7 @@ export const Topbar = ({ project, hasProPlan, css, loading }: TopbarProps) => {
isolation: "isolate",
justifyContent: "flex-end",
gap: theme.spacing[5],
- width: theme.sizes.sidebarWidth,
+ width: theme.spacing[30],
}}
>
<ViewMode />
diff --git a/apps/builder/app/builder/shared/binding-popover.tsx b/apps/builder/app/builder/shared/binding-popover.tsx
index b00f1e3deb..cb7c9cb3dd 100644
--- a/apps/builder/app/builder/shared/binding-popover.tsx
+++ b/apps/builder/app/builder/shared/binding-popover.tsx
@@ -111,7 +111,7 @@ const BindingPanel = ({
css={{
display: "flex",
flexDirection: "column",
- width: theme.sizes.sidebarWidth,
+ width: theme.spacing[30],
}}
>
<Box css={{ paddingBottom: theme.spacing[5] }}>
@@ -196,7 +196,7 @@ const BindingPanel = ({
updateExpression(value);
setTouched(false);
}}
- onBlur={() => {
+ onChangeComplete={() => {
onSave(expression, errorsCount > 0);
setTouched(true);
}}
diff --git a/apps/builder/app/builder/shared/code-editor-base.tsx b/apps/builder/app/builder/shared/code-editor-base.tsx
index ab120fa66d..bfd6faa5d3 100644
--- a/apps/builder/app/builder/shared/code-editor-base.tsx
+++ b/apps/builder/app/builder/shared/code-editor-base.tsx
@@ -42,6 +42,8 @@ import {
Flex,
rawTheme,
globalCss,
+ Kbd,
+ Text,
} from "@webstudio-is/design-system";
import { CrossIcon, MaximizeIcon, MinimizeIcon } from "@webstudio-is/icons";
import { solarizedLight } from "./code-highlight";
@@ -56,6 +58,7 @@ const ExternalChange = Annotation.define<boolean>();
const minHeightVar = "--ws-code-editor-min-height";
const maxHeightVar = "--ws-code-editor-max-height";
+const maximizeIconVisibilityVar = "--ws-code-editor-maximize-icon-visibility";
export const getMinMaxHeightVars = ({
minHeight,
@@ -78,14 +81,15 @@ const editorContentStyle = css({
...textVariants.mono,
// fit editor into parent if stretched
display: "flex",
+ position: "relative",
minHeight: 0,
boxSizing: "border-box",
color: theme.colors.foregroundMain,
borderRadius: theme.borderRadius[4],
border: `1px solid ${theme.colors.borderMain}`,
background: theme.colors.backgroundControls,
- paddingTop: 6,
- paddingBottom: 4,
+ paddingTop: 4,
+ paddingBottom: 2,
paddingRight: theme.spacing[2],
paddingLeft: theme.spacing[3],
// required to support copying selected text
@@ -125,6 +129,17 @@ const editorContentStyle = css({
},
});
+const shortcutStyle = css({
+ position: "absolute",
+ left: 0,
+ bottom: 0,
+ width: "100%",
+ paddingInline: theme.spacing[3],
+ background: "oklch(100% 0 0 / 50%)",
+ zIndex: 1,
+ pointerEvents: "none",
+});
+
const autocompletionTooltipTheme = EditorView.theme({
".cm-tooltip.cm-tooltip-autocomplete": {
...textVariants.mono,
@@ -170,8 +185,18 @@ const autocompletionTooltipTheme = EditorView.theme({
},
});
+const keyBindings = [
+ ...defaultKeymap.filter((binding) => {
+ // We are redefining it later and CodeMirror won't take an override
+ return binding.key !== "Mod-Enter";
+ }),
+ ...historyKeymap,
+ indentWithTab,
+];
+
export type EditorApi = {
replaceSelection: (string: string) => void;
+ focus: () => void;
};
type EditorContentProps = {
@@ -180,9 +205,10 @@ type EditorContentProps = {
readOnly?: boolean;
autoFocus?: boolean;
invalid?: boolean;
+ showShortcuts?: boolean;
value: string;
- onChange: (newValue: string) => void;
- onBlur?: (event: FocusEvent) => void;
+ onChange: (value: string) => void;
+ onChangeComplete: (value: string) => void;
};
export const EditorContent = ({
@@ -191,9 +217,10 @@ export const EditorContent = ({
readOnly = false,
autoFocus = false,
invalid = false,
+ showShortcuts = false,
value,
onChange,
- onBlur,
+ onChangeComplete,
}: EditorContentProps) => {
globalStyles();
@@ -202,8 +229,8 @@ export const EditorContent = ({
const onChangeRef = useRef(onChange);
onChangeRef.current = onChange;
- const onBlurRef = useRef(onBlur);
- onBlurRef.current = onBlur;
+ const onChangeCompleteRef = useRef(onChangeComplete);
+ onChangeCompleteRef.current = onChangeComplete;
// setup editor
@@ -243,7 +270,23 @@ export const EditorContent = ({
drawSelection(),
dropCursor(),
syntaxHighlighting(solarizedLight, { fallback: true }),
- keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]),
+ keymap.of([
+ ...keyBindings,
+ {
+ key: "Mod-Enter",
+ run(view) {
+ onChangeCompleteRef.current(view.state.doc.toString());
+ return true;
+ },
+ },
+ {
+ key: "Mod-s",
+ run(view) {
+ onChangeCompleteRef.current(view.state.doc.toString());
+ return true;
+ },
+ },
+ ]),
EditorView.lineWrapping,
EditorView.editable.of(readOnly === false),
EditorState.readOnly.of(readOnly === true),
@@ -261,8 +304,8 @@ export const EditorContent = ({
}
}),
EditorView.domEventHandlers({
- blur(event) {
- onBlurRef.current?.(event);
+ blur() {
+ onChangeCompleteRef.current(view.state.doc.toString());
},
cut(event) {
// prevent catching cut by global copy paste
@@ -301,6 +344,9 @@ export const EditorContent = ({
view.dispatch(view.state.replaceSelection(string));
view.focus();
},
+ focus() {
+ viewRef.current?.focus();
+ },
}));
return (
@@ -308,14 +354,21 @@ export const EditorContent = ({
className={editorContentStyle()}
data-invalid={invalid}
ref={editorRef}
- />
+ >
+ {showShortcuts && (
+ <Flex align="center" justify="end" gap="1" className={shortcutStyle()}>
+ <Text variant="small">Submit</Text>
+ <Kbd value={["cmd", "enter"]} />
+ </Flex>
+ )}
+ </div>
);
};
const editorDialogControlStyle = css({
position: "relative",
"&:hover": {
- "--ws-code-editor-maximize-icon-visibility": "visible",
+ [maximizeIconVisibilityVar]: "visible",
},
});
@@ -334,9 +387,10 @@ export const EditorDialogButton = forwardRef<
icon={<MaximizeIcon />}
css={{
position: "absolute",
- top: 6,
+ top: 4,
right: 4,
- visibility: `var(--ws-code-editor-maximize-icon-visibility, hidden)`,
+ visibility: `var(${maximizeIconVisibilityVar}, hidden)`,
+ background: "oklch(100% 0 0 / 50%)",
}}
/>
);
@@ -349,12 +403,20 @@ export const EditorDialog = ({
title,
content,
children,
+ width = 640,
+ height = 480,
+ x,
+ y,
}: {
open?: boolean;
onOpenChange?: (newOpen: boolean) => void;
title?: ReactNode;
content: ReactNode;
children: ReactNode;
+ x?: number;
+ y?: number;
+ width?: number;
+ height?: number;
}) => {
const [isMaximized, setIsMaximized] = useState(false);
return (
@@ -362,8 +424,10 @@ export const EditorDialog = ({
<DialogTrigger asChild>{children}</DialogTrigger>
<DialogContent
resize="auto"
- width={640}
- height={480}
+ width={width}
+ height={height}
+ x={x}
+ y={y}
minHeight={240}
isMaximized={isMaximized}
onInteractOutside={(event) => {
@@ -416,29 +480,3 @@ export const EditorDialog = ({
</Dialog>
);
};
-
-export const CodeEditorBase = ({
- title,
- open,
- onOpenChange,
- ...editorContentProps
-}: EditorContentProps & {
- title?: ReactNode;
- open?: boolean;
- onOpenChange?: (newOpen: boolean) => void;
-}) => {
- const content = <EditorContent {...editorContentProps} />;
- return (
- <EditorDialogControl>
- {content}
- <EditorDialog
- open={open}
- onOpenChange={onOpenChange}
- title={title}
- content={content}
- >
- <EditorDialogButton />
- </EditorDialog>
- </EditorDialogControl>
- );
-};
diff --git a/apps/builder/app/builder/shared/code-editor.stories.tsx b/apps/builder/app/builder/shared/code-editor.stories.tsx
index 715c83dc8f..a153f51038 100644
--- a/apps/builder/app/builder/shared/code-editor.stories.tsx
+++ b/apps/builder/app/builder/shared/code-editor.stories.tsx
@@ -18,10 +18,23 @@ const initialHtml = `
export const BaseEditor = () => {
const [value, setValue] = useState(initialHtml);
- return <CodeEditorComponent value={value} onChange={setValue} />;
+ return (
+ <CodeEditorComponent
+ value={value}
+ onChange={setValue}
+ onChangeComplete={setValue}
+ />
+ );
};
export const HtmlEditor = () => {
const [value, setValue] = useState(initialHtml);
- return <CodeEditorComponent value={value} onChange={setValue} lang="html" />;
+ return (
+ <CodeEditorComponent
+ value={value}
+ onChange={setValue}
+ onChangeComplete={setValue}
+ lang="html"
+ />
+ );
};
diff --git a/apps/builder/app/builder/shared/code-editor.tsx b/apps/builder/app/builder/shared/code-editor.tsx
index eddc6d5b73..9820f7ee6a 100644
--- a/apps/builder/app/builder/shared/code-editor.tsx
+++ b/apps/builder/app/builder/shared/code-editor.tsx
@@ -1,4 +1,10 @@
-import { forwardRef, useMemo, type ComponentProps, useEffect } from "react";
+import {
+ forwardRef,
+ useMemo,
+ type ComponentProps,
+ useEffect,
+ type ReactNode,
+} from "react";
import { styleTags, tags } from "@lezer/highlight";
import {
keymap,
@@ -16,7 +22,13 @@ import {
import { html } from "@codemirror/lang-html";
import { markdown } from "@codemirror/lang-markdown";
import { css } from "@webstudio-is/design-system";
-import { CodeEditorBase, getMinMaxHeightVars } from "./code-editor-base";
+import {
+ EditorContent,
+ EditorDialog,
+ EditorDialogButton,
+ EditorDialogControl,
+ getMinMaxHeightVars,
+} from "./code-editor-base";
const wrapperStyle = css({
position: "relative",
@@ -69,10 +81,11 @@ const getMarkdownExtensions = () => [
export const CodeEditor = forwardRef<
HTMLDivElement,
- Omit<ComponentProps<typeof CodeEditorBase>, "extensions"> & {
+ Omit<ComponentProps<typeof EditorContent>, "extensions"> & {
lang?: "html" | "markdown";
+ title?: ReactNode;
}
->(({ lang, ...props }, ref) => {
+>(({ lang, title, ...editorContentProps }, ref) => {
const extensions = useMemo(() => {
if (lang === "html") {
return getHtmlExtensions();
@@ -100,10 +113,17 @@ export const CodeEditor = forwardRef<
document.removeEventListener("pointerdown", handlePointerDown, options);
};
}, []);
-
+ const content = (
+ <EditorContent {...editorContentProps} extensions={extensions} />
+ );
return (
<div className={wrapperStyle()} ref={ref}>
- <CodeEditorBase {...props} extensions={extensions} />
+ <EditorDialogControl>
+ {content}
+ <EditorDialog title={title} content={content}>
+ <EditorDialogButton />
+ </EditorDialog>
+ </EditorDialogControl>
</div>
);
});
diff --git a/apps/builder/app/builder/shared/expression-editor.stories.tsx b/apps/builder/app/builder/shared/expression-editor.stories.tsx
index 9336f4b52e..90166c335c 100644
--- a/apps/builder/app/builder/shared/expression-editor.stories.tsx
+++ b/apps/builder/app/builder/shared/expression-editor.stories.tsx
@@ -46,6 +46,7 @@ const ExpressionStory = () => {
aliases={aliases}
value={value}
onChange={setValue}
+ onChangeComplete={setValue}
/>
);
};
diff --git a/apps/builder/app/builder/shared/expression-editor.tsx b/apps/builder/app/builder/shared/expression-editor.tsx
index 03c1e11ea0..74597cc677 100644
--- a/apps/builder/app/builder/shared/expression-editor.tsx
+++ b/apps/builder/app/builder/shared/expression-editor.tsx
@@ -35,9 +35,10 @@ import {
} from "@webstudio-is/sdk";
import { mapGroupBy } from "~/shared/shim";
import {
- CodeEditorBase,
EditorContent,
EditorDialog,
+ EditorDialogButton,
+ EditorDialogControl,
type EditorApi,
} from "./code-editor-base";
@@ -430,7 +431,7 @@ export const ExpressionEditor = ({
readOnly = false,
value,
onChange,
- onBlur,
+ onChangeComplete,
}: {
editorApiRef?: RefObject<undefined | EditorApi>;
/**
@@ -445,8 +446,8 @@ export const ExpressionEditor = ({
autoFocus?: boolean;
readOnly?: boolean;
value: string;
- onChange: (newValue: string) => void;
- onBlur?: () => void;
+ onChange: (value: string) => void;
+ onChangeComplete: (value: string) => void;
}) => {
const extensions = useMemo(
() => [
@@ -488,18 +489,27 @@ export const ExpressionEditor = ({
};
}, []);
+ const content = (
+ <EditorContent
+ editorApiRef={editorApiRef}
+ extensions={extensions}
+ invalid={color === "error"}
+ readOnly={readOnly}
+ autoFocus={autoFocus}
+ value={value}
+ onChange={onChange}
+ onChangeComplete={onChangeComplete}
+ />
+ );
+
return (
<div className={wrapperStyle.toString()}>
- <CodeEditorBase
- editorApiRef={editorApiRef}
- extensions={extensions}
- invalid={color === "error"}
- readOnly={readOnly}
- autoFocus={autoFocus}
- value={value}
- onChange={onChange}
- onBlur={onBlur}
- />
+ <EditorDialogControl>
+ {content}
+ <EditorDialog content={content}>
+ <EditorDialogButton />
+ </EditorDialog>
+ </EditorDialogControl>
</div>
);
};
@@ -515,6 +525,7 @@ const ValuePreviewEditor = ({ value }: { value: unknown }) => {
extensions={extensions}
value={JSON.stringify(value, null, 2)}
onChange={() => {}}
+ onChangeComplete={() => {}}
/>
);
};
diff --git a/apps/builder/app/builder/sidebar-left/sidebar-left.tsx b/apps/builder/app/builder/sidebar-left/sidebar-left.tsx
index f1132119da..86e6e6ee64 100644
--- a/apps/builder/app/builder/sidebar-left/sidebar-left.tsx
+++ b/apps/builder/app/builder/sidebar-left/sidebar-left.tsx
@@ -278,7 +278,7 @@ export const SidebarLeft = ({ publish }: SidebarLeftProps) => {
}
}}
css={{
- width: theme.sizes.sidebarWidth,
+ width: theme.spacing[30],
// We need the node to be rendered but hidden
// to keep receiving the drag events.
visibility:
diff --git a/packages/design-system/src/components/button.tsx b/packages/design-system/src/components/button.tsx
index a0125991c2..631a2fc260 100644
--- a/packages/design-system/src/components/button.tsx
+++ b/packages/design-system/src/components/button.tsx
@@ -116,7 +116,7 @@ export const buttonStyle = css({
alignItems: "center",
justifyContent: "center",
gap: theme.spacing[2],
- padding: `0 ${theme.spacing[4]}`,
+ padding: `0 ${theme.spacing[3]}`,
height: theme.spacing[11],
borderRadius: theme.borderRadius[4],
whiteSpace: "nowrap",
diff --git a/packages/design-system/src/components/card.tsx b/packages/design-system/src/components/card.tsx
index d909e0282c..bce4d5d5bf 100644
--- a/packages/design-system/src/components/card.tsx
+++ b/packages/design-system/src/components/card.tsx
@@ -35,7 +35,7 @@ export const Card = styled("div", {
variants: {
size: {
1: {
- width: theme.sizes.sidebarWidth,
+ width: theme.spacing[30],
padding: theme.spacing[11],
},
},
diff --git a/packages/design-system/src/components/css-value-list-item.stories.tsx b/packages/design-system/src/components/css-value-list-item.stories.tsx
index 64a2c4b641..82667c027c 100644
--- a/packages/design-system/src/components/css-value-list-item.stories.tsx
+++ b/packages/design-system/src/components/css-value-list-item.stories.tsx
@@ -41,7 +41,7 @@ const Thumbnail = styled("div", {
});
const Panel = styled("div", {
- width: theme.sizes.sidebarWidth,
+ width: theme.spacing[30],
});
const ListItem = (props: {
diff --git a/packages/design-system/src/components/dialog.tsx b/packages/design-system/src/components/dialog.tsx
index 2ccd2b770e..f698ae3042 100644
--- a/packages/design-system/src/components/dialog.tsx
+++ b/packages/design-system/src/components/dialog.tsx
@@ -7,7 +7,7 @@ import {
type DragEventHandler,
} from "react";
import * as Primitive from "@radix-ui/react-dialog";
-import { css, theme, keyframes, type CSS } from "../stitches.config";
+import { css, theme, type CSS } from "../stitches.config";
import { PanelTitle } from "./panel-title";
import { floatingPanelStyle, CloseButton, TitleSlot } from "./floating-panel";
import { Flex } from "./flex";
@@ -34,16 +34,20 @@ if (placeholderImage) {
"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";
}
+type Point = { x: number; y: number };
+type Size = { width: number; height: number };
+type Rect = Point & Size;
+
type UseDraggableProps = {
isMaximized?: boolean;
- width?: number;
- height?: number;
minWidth?: number;
minHeight?: number;
-};
+} & Partial<Rect>;
const useDraggable = ({
isMaximized = false,
+ x,
+ y,
width,
height,
minHeight,
@@ -52,8 +56,8 @@ const useDraggable = ({
const initialDataRef = useRef<
| undefined
| {
- point: { x: number; y: number };
- rect: DOMRect;
+ point: Point;
+ rect: Rect;
}
>(undefined);
const { enableCanvasPointerEvents, disableCanvasPointerEvents } =
@@ -69,9 +73,10 @@ const useDraggable = ({
if (placeholderImage) {
event.dataTransfer.setDragImage(placeholderImage, 0, 0);
}
+
const rect = target.getBoundingClientRect();
- target.style.left = `${rect.left}px`;
- target.style.top = `${rect.top}px`;
+ target.style.left = `${rect.x}px`;
+ target.style.top = `${rect.y}px`;
target.style.transform = "none";
initialDataRef.current = {
point: { x: event.pageX, y: event.pageY },
@@ -109,6 +114,7 @@ const useDraggable = ({
height: "100vh",
}
: {
+ ...centeredContent,
width,
height,
};
@@ -119,7 +125,16 @@ const useDraggable = ({
if (minHeight !== undefined) {
style.minHeight = minHeight;
}
-
+ if (isMaximized === false) {
+ if (x !== undefined) {
+ style.left = x;
+ delete style.transform;
+ }
+ if (y !== undefined) {
+ style.top = y;
+ delete style.transform;
+ }
+ }
return {
onDragStart: handleDragStart,
onDrag: handleDrag,
@@ -139,6 +154,8 @@ export const DialogContent = forwardRef(
isMaximized,
width,
height,
+ x,
+ y,
minWidth,
minHeight,
...props
@@ -152,10 +169,13 @@ export const DialogContent = forwardRef(
const { draggableRef, ...draggableProps } = useDraggable({
width,
height,
+ x,
+ y,
minWidth,
minHeight,
isMaximized,
});
+
return (
<Primitive.Portal>
<Primitive.Overlay className={overlayStyle()} />
@@ -215,21 +235,10 @@ export const DialogActions = ({ children }: { children: ReactNode }) => {
// Styles specific to dialog
// (as opposed to be common for all floating panels)
-
-const overlayShow = keyframes({
- from: { opacity: 0 },
- to: { opacity: 1 },
-});
const overlayStyle = css({
backgroundColor: "rgba(17, 24, 28, 0.66)",
position: "fixed",
inset: 0,
- animation: `${overlayShow} 150ms ${theme.easing.easeOut}`,
-});
-
-const contentShow = keyframes({
- from: { opacity: 0, transform: "translate(-50%, -48%) scale(0.96)" },
- to: { opacity: 1, transform: "translate(-50%, -50%) scale(1)" },
});
const centeredContent: CSSProperties = {
@@ -239,14 +248,12 @@ const centeredContent: CSSProperties = {
};
const contentStyle = css(floatingPanelStyle, {
- ...centeredContent,
position: "fixed",
width: "min-content",
minWidth: theme.sizes.sidebarWidth,
maxWidth: "calc(100vw - 40px)",
maxHeight: "calc(100vh - 40px)",
userSelect: "none",
- animation: `${contentShow} 150ms ${theme.easing.easeOut}`,
overflow: "hidden",
variants: {
diff --git a/packages/design-system/src/components/nested-input-button.tsx b/packages/design-system/src/components/nested-input-button.tsx
index 9e557dafd9..0284789f23 100644
--- a/packages/design-system/src/components/nested-input-button.tsx
+++ b/packages/design-system/src/components/nested-input-button.tsx
@@ -45,7 +45,7 @@ const style = css({
hasChildren: {
true: {
"&:where(:has(svg))": {
- width: theme.spacing[11],
+ paddingInline: theme.spacing[2],
},
},
},