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: add reverse flex directions (#2837)

Bogdan Chadkinf01da8f0a926
diff --git a/apps/builder/app/builder/features/style-panel/controls/menu/menu-control.tsx b/apps/builder/app/builder/features/style-panel/controls/menu/menu-control.tsx
index 5dc266ccbd..63985697dc 100644
--- a/apps/builder/app/builder/features/style-panel/controls/menu/menu-control.tsx
+++ b/apps/builder/app/builder/features/style-panel/controls/menu/menu-control.tsx
@@ -1,4 +1,5 @@
import { toValue } from "@webstudio-is/css-engine";
+import type { IconRecord } from "@webstudio-is/icons";
import {
DropdownMenu,
DropdownMenuArrow,
@@ -19,13 +20,14 @@ import { PropertyTooltip } from "../../shared/property-name";
export const MenuControl = ({
currentStyle,
property,
+ icons,
items: passedItems,
setProperty,
deleteProperty,
}: Pick<
ControlProps,
"currentStyle" | "property" | "items" | "setProperty" | "deleteProperty"
->) => {
+> & { icons?: IconRecord }) => {
const { label, items: defaultItems } = styleConfigByName(property);
const styleValue = currentStyle[property];
const value = styleValue?.value;
@@ -42,7 +44,7 @@ export const MenuControl = ({
const items = (passedItems ?? defaultItems)
.map((item) => {
- const ItemIcon = iconProps[item.name];
+ const ItemIcon = icons?.[item.name] ?? iconProps?.[item.name];
return { ...item, icon: ItemIcon && <ItemIcon /> };
})
.filter((item) => item.icon);
diff --git a/apps/builder/app/builder/features/style-panel/sections/layout/layout.tsx b/apps/builder/app/builder/features/style-panel/sections/layout/layout.tsx
index ecb79ff93e..8338229098 100644
--- a/apps/builder/app/builder/features/style-panel/sections/layout/layout.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/layout/layout.tsx
@@ -14,10 +14,12 @@ import {
Link2UnlinkedIcon,
GapHorizontalIcon,
GapVerticalIcon,
- ArrowRightIcon,
- ArrowDownIcon,
WrapIcon,
NoWrapIcon,
+ ArrowRightIcon,
+ ArrowLeftIcon,
+ ArrowDownIcon,
+ ArrowUpIcon,
} from "@webstudio-is/icons";
import type { RenderCategoryProps } from "../../style-sections";
import { FlexGrid } from "./shared/flex-grid";
@@ -379,12 +381,14 @@ const LayoutSectionFlex = ({
<FlexGrid currentStyle={currentStyle} batchUpdate={batchUpdate} />
<Flex direction="column" justify="between">
<Flex css={{ gap: theme.spacing[7] }}>
- <Toggle
+ <MenuControl
property="flexDirection"
- iconOn={<ArrowDownIcon />}
- iconOff={<ArrowRightIcon />}
- valueOn="column"
- valueOff="row"
+ icons={{
+ row: ArrowRightIcon,
+ "row-reverse": ArrowLeftIcon,
+ column: ArrowDownIcon,
+ "column-reverse": ArrowUpIcon,
+ }}
currentStyle={currentStyle}
setProperty={setProperty}
deleteProperty={deleteProperty}
diff --git a/apps/builder/app/builder/features/style-panel/shared/configs.ts b/apps/builder/app/builder/features/style-panel/shared/configs.ts
index cdc6a957da..76fc7cc5ff 100644
--- a/apps/builder/app/builder/features/style-panel/shared/configs.ts
+++ b/apps/builder/app/builder/features/style-panel/shared/configs.ts
@@ -17,8 +17,6 @@ import {
AICenterIcon,
AIBaselineIcon,
AIStretchIcon,
- ArrowRightIcon,
- ArrowDownIcon,
NoWrapIcon,
WrapIcon,
JCStartIcon,
@@ -114,10 +112,6 @@ export const iconConfigs: IconRecords = {
baseline: AIBaselineIcon,
stretch: AIStretchIcon,
},
- flexDirection: {
- row: ArrowRightIcon,
- column: ArrowDownIcon,
- },
flexWrap: {
nowrap: NoWrapIcon,
wrap: WrapIcon,
diff --git a/packages/icons/icons/arrow-left.svg b/packages/icons/icons/arrow-left.svg
new file mode 100644
index 0000000000..64d9e47f9b
--- /dev/null
+++ b/packages/icons/icons/arrow-left.svg
@@ -0,0 +1,5 @@
+<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g id="icon/arrow left">
+<path id="vector" fill-rule="evenodd" clip-rule="evenodd" d="M7.5657 3.43433C7.87812 3.74675 7.87812 4.25328 7.5657 4.5657L4.93138 7.20001H13C13.4418 7.20001 13.8 7.55818 13.8 8.00001C13.8 8.44184 13.4418 8.80001 13 8.80001H4.93138L7.5657 11.4343C7.87812 11.7467 7.87812 12.2533 7.5657 12.5657C7.25328 12.8781 6.74675 12.8781 6.43433 12.5657L2.43433 8.5657C2.12191 8.25328 2.12191 7.74675 2.43433 7.43433L6.43433 3.43433C6.74675 3.12191 7.25328 3.12191 7.5657 3.43433Z" />
+</g>
+</svg>
diff --git a/packages/icons/icons/arrow-up.svg b/packages/icons/icons/arrow-up.svg
new file mode 100644
index 0000000000..198962a420
--- /dev/null
+++ b/packages/icons/icons/arrow-up.svg
@@ -0,0 +1,5 @@
+<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g id="icon/arrow up">
+<path id="vector" fill-rule="evenodd" clip-rule="evenodd" d="M12.5657 7.5657C12.2533 7.87812 11.7467 7.87812 11.4343 7.5657L8.79999 4.93138L8.79999 13C8.79999 13.4418 8.44181 13.8 7.99999 13.8C7.55816 13.8 7.19999 13.4418 7.19999 13L7.19999 4.93138L4.56567 7.5657C4.25325 7.87812 3.74672 7.87812 3.4343 7.5657C3.12188 7.25328 3.12188 6.74675 3.4343 6.43433L7.4343 2.43433C7.74672 2.12191 8.25325 2.12191 8.56567 2.43433L12.5657 6.43433C12.8781 6.74675 12.8781 7.25328 12.5657 7.5657Z" />
+</g>
+</svg>
diff --git a/packages/icons/src/__generated__/arrow-left.tsx b/packages/icons/src/__generated__/arrow-left.tsx
new file mode 100644
index 0000000000..1bc7c8659f
--- /dev/null
+++ b/packages/icons/src/__generated__/arrow-left.tsx
@@ -0,0 +1,15 @@
+// Generated from icons/arrow-left.svg
+
+import { forwardRef } from "react";
+import type { IconProps } from "../types";
+
+// prettier-ignore
+export const ArrowLeftIcon = forwardRef<SVGSVGElement, IconProps>(
+ ({ color = "currentColor", size = 16, ...props }, forwardedRef) => {
+ return (
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width={size} height={size} fill={color} {...props} ref={forwardedRef}><path fillRule="evenodd" d="M7.566 3.434a.8.8 0 0 1 0 1.132L4.93 7.2H13a.8.8 0 0 1 0 1.6H4.931l2.635 2.634a.8.8 0 0 1-1.132 1.132l-4-4a.8.8 0 0 1 0-1.132l4-4a.8.8 0 0 1 1.132 0Z" clipRule="evenodd" /></svg>
+ );
+ }
+);
+
+ArrowLeftIcon.displayName = "ArrowLeftIcon";
diff --git a/packages/icons/src/__generated__/arrow-up.tsx b/packages/icons/src/__generated__/arrow-up.tsx
new file mode 100644
index 0000000000..2bb613a8ee
--- /dev/null
+++ b/packages/icons/src/__generated__/arrow-up.tsx
@@ -0,0 +1,15 @@
+// Generated from icons/arrow-up.svg
+
+import { forwardRef } from "react";
+import type { IconProps } from "../types";
+
+// prettier-ignore
+export const ArrowUpIcon = forwardRef<SVGSVGElement, IconProps>(
+ ({ color = "currentColor", size = 16, ...props }, forwardedRef) => {
+ return (
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width={size} height={size} fill={color} {...props} ref={forwardedRef}><path fillRule="evenodd" d="M12.566 7.566a.8.8 0 0 1-1.132 0L8.8 4.93V13a.8.8 0 0 1-1.6 0V4.931L4.566 7.566a.8.8 0 1 1-1.132-1.132l4-4a.8.8 0 0 1 1.132 0l4 4a.8.8 0 0 1 0 1.132Z" clipRule="evenodd" /></svg>
+ );
+ }
+);
+
+ArrowUpIcon.displayName = "ArrowUpIcon";
diff --git a/packages/icons/src/__generated__/index.ts b/packages/icons/src/__generated__/index.ts
index d9f2483cf0..8e6fac925e 100644
--- a/packages/icons/src/__generated__/index.ts
+++ b/packages/icons/src/__generated__/index.ts
@@ -21,7 +21,9 @@ export * from "./ai-loading";
export * from "./ai";
export * from "./alert";
export * from "./arrow-down";
+export * from "./arrow-left";
export * from "./arrow-right";
+export * from "./arrow-up";
export * from "./aspect-ratio";
export * from "./attachment";
export * from "./auto-scroll";
diff --git a/packages/icons/src/__generated__/svg/arrow-left.ts b/packages/icons/src/__generated__/svg/arrow-left.ts
new file mode 100644
index 0000000000..6d5aee31de
--- /dev/null
+++ b/packages/icons/src/__generated__/svg/arrow-left.ts
@@ -0,0 +1 @@
+export const ArrowLeftIcon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" width="100%" height="100%" style="display: block;"><path fill-rule="evenodd" d="M7.566 3.434a.8.8 0 0 1 0 1.132L4.93 7.2H13a.8.8 0 0 1 0 1.6H4.931l2.635 2.634a.8.8 0 0 1-1.132 1.132l-4-4a.8.8 0 0 1 0-1.132l4-4a.8.8 0 0 1 1.132 0Z" clip-rule="evenodd"/></svg>`;
diff --git a/packages/icons/src/__generated__/svg/arrow-up.ts b/packages/icons/src/__generated__/svg/arrow-up.ts
new file mode 100644
index 0000000000..97d293eb2d
--- /dev/null
+++ b/packages/icons/src/__generated__/svg/arrow-up.ts
@@ -0,0 +1 @@
+export const ArrowUpIcon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" width="100%" height="100%" style="display: block;"><path fill-rule="evenodd" d="M12.566 7.566a.8.8 0 0 1-1.132 0L8.8 4.93V13a.8.8 0 0 1-1.6 0V4.931L4.566 7.566a.8.8 0 1 1-1.132-1.132l4-4a.8.8 0 0 1 1.132 0l4 4a.8.8 0 0 1 0 1.132Z" clip-rule="evenodd"/></svg>`;
diff --git a/packages/icons/src/__generated__/svg/index.ts b/packages/icons/src/__generated__/svg/index.ts
index dc27f885a6..c195378f7d 100644
--- a/packages/icons/src/__generated__/svg/index.ts
+++ b/packages/icons/src/__generated__/svg/index.ts
@@ -21,7 +21,9 @@ export { AiLoadingIcon } from "./ai-loading";
export { AiIcon } from "./ai";
export { AlertIcon } from "./alert";
export { ArrowDownIcon } from "./arrow-down";
+export { ArrowLeftIcon } from "./arrow-left";
export { ArrowRightIcon } from "./arrow-right";
+export { ArrowUpIcon } from "./arrow-up";
export { AspectRatioIcon } from "./aspect-ratio";
export { AttachmentIcon } from "./attachment";
export { AutoScrollIcon } from "./auto-scroll";