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
better abstraction for computed flex icons, grid control skeleton
Sultan816643b4234d
diff --git a/apps/designer/app/designer/features/style-panel/style-section.tsx b/apps/designer/app/designer/features/style-panel/style-section.tsxindex e76554e9c0..c71699dc8e 100644--- a/apps/designer/app/designer/features/style-panel/style-section.tsx+++ b/apps/designer/app/designer/features/style-panel/style-section.tsx@@ -36,7 +36,6 @@ import {} from "./lib/spacing-widget";import { useIsFromCurrentBreakpoint } from "./lib/use-is-from-current-breakpoint";import { propertyNameColorForSelectedBreakpoint } from "./lib/constants";-import camelcase from "lodash.camelcase";const getFinalValue = ({currentStyle,@@ -269,10 +268,9 @@ const ComboiconControl = ({const setValue = setProperty(styleConfig.property);const currentValue = value.value as string;- const currentIconName = camelcase(- `A${styleConfig.label} ${currentValue}`- ).slice(1);- const Icon = (icons as any)[currentIconName] || icons["AlignItemsCenter"];+ const Icon = (icons as any)[styleConfig.property]?.[currentValue];++ if (Icon === undefined) return null;return (<IconButton>@@ -289,7 +287,20 @@ const ComboiconControl = ({// );};-const GridControl = ({ currentStyle }: any) => {+const GridControl = ({ css, currentStyle }: any) => {+ return (+ <Box+ css={{+ border: "2px solid $colors$blue9",+ background: "#FFF",+ borderRadius: "4px",+ textAlign: "center",+ width: "72px",+ height: "72px",+ ...css,+ }}+ ></Box>+ );return <></>;};@@ -349,61 +360,62 @@ export const renderProperty = ({);};+type RenderCategoryProps = {+ currentStyle: Style;+ category: Category;+ styleConfigsByCategory: JSX.Element[];+ moreStyleConfigsByCategory: JSX.Element[];+};// Categories should render themselves because most Categories will not be dump un-ordered lists with// the new designs, refactor ColorControl, SpacingControl if needed.export const renderCategory = ({+ currentStyle,category,styleConfigsByCategory,moreStyleConfigsByCategory,-}: {- category: Category;- styleConfigsByCategory: JSX.Element[];- moreStyleConfigsByCategory: JSX.Element[];-}) => {+}: RenderCategoryProps) => {switch (category) {case "layout": {- styleConfigsByCategory = [- <Box- key="grid"- css={{- gridArea: "grid",- border: "1px solid black",- background: "#CCC",- }}- >- ...- <br />- ...- <br />- ...- </Box>,- <Box key="lock" css={{ gridArea: "lock" }}>- <IconButton>- <LockClosedIcon />- </IconButton>- ,- </Box>,- ...styleConfigsByCategory,- ];- return (- <>- <Grid- css={{- gridTemplateColumns: "repeat(12, 1fr);",- gridTemplateRows: "auto auto auto auto",- gridTemplateAreas: `- "display display display display display display display display display display display display"- "grid grid grid grid grid grid flexDirection flexDirection flexWrap flexWrap . ."- "grid grid grid grid grid grid alignItems alignItems justifyContent justifyContent . ."- "rowGap rowGap rowGap rowGap rowGap lock lock columnGap columnGap columnGap columnGap columnGap"- `,- }}- >- {styleConfigsByCategory}- </Grid>- <ShowMore styleConfigs={moreStyleConfigsByCategory} />- </>- );+ const display = currentStyle.display?.value;+ console.log(display);+ switch (currentStyle.display?.value) {+ case "flex": {+ styleConfigsByCategory = [+ <GridControl+ key="grid"+ css={{ gridArea: "grid" }}+ currentStyle={currentStyle}+ />,+ <Box key="lock" css={{ gridArea: "lock" }}>+ <IconButton>+ <LockClosedIcon />+ </IconButton>+ ,+ </Box>,+ ...styleConfigsByCategory,+ ];+ return (+ <>+ <Grid+ css={{+ alignItems: "center",+ gridTemplateColumns: "repeat(12, 1fr);",+ gridTemplateRows: "auto auto auto auto",+ gridTemplateAreas: `+ "display display display display display display display display display display display display"+ "grid grid grid grid flexDirection flexDirection flexWrap flexWrap . . . ."+ "grid grid grid grid alignItems alignItems justifyContent justifyContent alignContent alignContent . ."+ "rowGap rowGap rowGap rowGap rowGap lock lock columnGap columnGap columnGap columnGap columnGap"+ `,+ }}+ >+ {styleConfigsByCategory}+ </Grid>+ <ShowMore styleConfigs={moreStyleConfigsByCategory} />+ </>+ );+ }+ }}}diff --git a/apps/designer/app/designer/features/style-panel/style-settings.tsx b/apps/designer/app/designer/features/style-panel/style-settings.tsxindex 18c2e8b9eb..c4a0d19a4f 100644--- a/apps/designer/app/designer/features/style-panel/style-settings.tsx+++ b/apps/designer/app/designer/features/style-panel/style-settings.tsx@@ -132,6 +132,7 @@ export const StyleSettings = ({><>{renderCategory({+ currentStyle,category,styleConfigsByCategory,moreStyleConfigsByCategory,diff --git a/apps/designer/app/shared/icons/align-content.tsx b/apps/designer/app/shared/icons/align-content.tsxindex 497f70def1..04d328808a 100644--- a/apps/designer/app/shared/icons/align-content.tsx+++ b/apps/designer/app/shared/icons/align-content.tsx@@ -10,7 +10,17 @@ export const AlignContentStart = React.forwardRef<SVGSVGElement, IconProps>(xmlns="http://www.w3.org/2000/svg"{...props}ref={forwardedRef}- ></svg>+ >+ <path+ d="M0 2C0 0.89543 0.895431 0 2 0H22C23.1046 0 24 0.895431 24 2V22C24 23.1046 23.1046 24 22 24H2C0.89543 24 0 23.1046 0 22V2Z"+ fill="white"+ />+ <path d="M4 6H20V7H4V6Z" fill="#11181C" />+ <path d="M8 9H11V12H8V9Z" fill="#11181C" />+ <path d="M16 9H13V12H16V9Z" fill="#11181C" />+ <path d="M13 14H16V17H13V14Z" fill="#11181C" />+ <path d="M11 14H8V17H11V14Z" fill="#11181C" />+ </svg>);});@@ -24,7 +34,18 @@ export const AlignContentCenter = React.forwardRef<SVGSVGElement, IconProps>(xmlns="http://www.w3.org/2000/svg"{...props}ref={forwardedRef}- ></svg>+ >+ <path+ d="M0 2C0 0.89543 0.895431 0 2 0H22C23.1046 0 24 0.895431 24 2V22C24 23.1046 23.1046 24 22 24H2C0.89543 24 0 23.1046 0 22V2Z"+ fill="white"+ />+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M8 6H11V9H8V6ZM4 11.5H20V12.5H4V11.5ZM16 6H13V9H16V6ZM13 15H16V18H13V15ZM11 15H8V18H11V15Z"+ fill="#11181C"+ />+ </svg>);});@@ -38,7 +59,18 @@ export const AlignContentEnd = React.forwardRef<SVGSVGElement, IconProps>(xmlns="http://www.w3.org/2000/svg"{...props}ref={forwardedRef}- ></svg>+ >+ <path+ d="M0 2C0 0.89543 0.895431 0 2 0H22C23.1046 0 24 0.895431 24 2V22C24 23.1046 23.1046 24 22 24H2C0.89543 24 0 23.1046 0 22V2Z"+ fill="white"+ />+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M8 8H11V11H8V8ZM4 18H20V19H4V18ZM16 8H13V11H16V8ZM13 13H16V16H13V13ZM11 13H8V16H11V13Z"+ fill="#11181C"+ />+ </svg>);});@@ -52,7 +84,18 @@ export const AlignContentStretch = React.forwardRef<SVGSVGElement, IconProps>(xmlns="http://www.w3.org/2000/svg"{...props}ref={forwardedRef}- ></svg>+ >+ <path+ d="M0 2C0 0.89543 0.895431 0 2 0H22C23.1046 0 24 0.895431 24 2V22C24 23.1046 23.1046 24 22 24H2C0.89543 24 0 23.1046 0 22V2Z"+ fill="white"+ />+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M19 5H5V6H19V5ZM19 18H5V19H19V18ZM8 8H11V11H8V8ZM16 8H13V11H16V8ZM13 13H16V16H13V13ZM11 13H8V16H11V13Z"+ fill="#11181C"+ />+ </svg>);});@@ -68,7 +111,18 @@ export const AlignContentSpaceAround = React.forwardRef<xmlns="http://www.w3.org/2000/svg"{...props}ref={forwardedRef}- ></svg>+ >+ <path+ d="M0 2C0 0.89543 0.895431 0 2 0H22C23.1046 0 24 0.895431 24 2V22C24 23.1046 23.1046 24 22 24H2C0.89543 24 0 23.1046 0 22V2Z"+ fill="white"+ />+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M19 5H5V6H19V5ZM19 18H5V19H19V18ZM8 8H11V11H8V8ZM16 8H13V11H16V8ZM13 13H16V16H13V13ZM11 13H8V16H11V13Z"+ fill="#11181C"+ />+ </svg>);});@@ -83,8 +137,27 @@ export const AlignContentSpaceBetween = React.forwardRef<xmlns="http://www.w3.org/2000/svg"{...props}ref={forwardedRef}- ></svg>+ >+ <path+ d="M0 2C0 0.89543 0.895431 0 2 0H22C23.1046 0 24 0.895431 24 2V22C24 23.1046 23.1046 24 22 24H2C0.89543 24 0 23.1046 0 22V2Z"+ fill="white"+ />+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M19 5H5V6H19V5ZM19 18H5V19H19V18ZM8 8H11V11H8V8ZM16 8H13V11H16V8ZM13 13H16V16H13V13ZM11 13H8V16H11V13Z"+ fill="#11181C"+ />+ </svg>);});-export const AlignContentNormal = AlignContentStart;+export const alignContent = {+ normal: AlignContentStart,+ start: AlignContentStart,+ end: AlignContentEnd,+ center: AlignContentCenter,+ stretch: AlignContentStretch,+ spaceAround: AlignContentSpaceAround,+ spaceBetween: AlignContentSpaceBetween,+};diff --git a/apps/designer/app/shared/icons/align-items.tsx b/apps/designer/app/shared/icons/align-items.tsxindex e7ea495363..011a1dd4cd 100644--- a/apps/designer/app/shared/icons/align-items.tsx+++ b/apps/designer/app/shared/icons/align-items.tsx@@ -153,3 +153,12 @@ export const AlignItemsStretch = React.forwardRef<SVGSVGElement, IconProps>();export const AlignItemsNormal = AlignItemsStart;++export const alignItems = {+ normal: AlignItemsStart,+ start: AlignItemsStart,+ end: AlignItemsEnd,+ center: AlignItemsCenter,+ baseline: AlignItemsBaseline,+ stretch: AlignItemsStretch,+};diff --git a/apps/designer/app/shared/icons/flex-direction.tsx b/apps/designer/app/shared/icons/flex-direction.tsxindex 4c5e94b297..e52cd82f6b 100644--- a/apps/designer/app/shared/icons/flex-direction.tsx+++ b/apps/designer/app/shared/icons/flex-direction.tsx@@ -47,4 +47,8 @@ export const FlexDirectionColumn = React.forwardRef<SVGSVGElement, IconProps>(});-export const flexDirectionNormal = FlexDirectionRow;+export const flexDirection = {+ normal: FlexDirectionRow,+ row: FlexDirectionRow,+ column: FlexDirectionColumn,+};diff --git a/apps/designer/app/shared/icons/flex-wrap.tsx b/apps/designer/app/shared/icons/flex-wrap.tsxindex 242ddf2fc0..a5fce7ac80 100644--- a/apps/designer/app/shared/icons/flex-wrap.tsx+++ b/apps/designer/app/shared/icons/flex-wrap.tsx@@ -54,4 +54,8 @@ export const FlexWrapNowrap = React.forwardRef<SVGSVGElement, IconProps>(});-export const FlexWrapNormal = FlexWrapNowrap;+export const flexWrap = {+ normal: FlexWrapNowrap,+ nowrap: FlexWrapNowrap,+ wrap: FlexWrapWrap,+};diff --git a/apps/designer/app/shared/icons/justify-content.tsx b/apps/designer/app/shared/icons/justify-content.tsxindex 4d2d7f0416..3caf0f7cf4 100644--- a/apps/designer/app/shared/icons/justify-content.tsx+++ b/apps/designer/app/shared/icons/justify-content.tsx@@ -124,4 +124,11 @@ export const JustifyContentSpaceAround = React.forwardRef<);});-export const JustifyContentNormal = JustifyContentStart;+export const justifyContent = {+ normal: JustifyContentStart,+ start: JustifyContentStart,+ end: JustifyContentEnd,+ center: JustifyContentCenter,+ spaceBetween: JustifyContentSpaceBetween,+ spaceAround: JustifyContentSpaceAround,+};diff --git a/apps/designer/package.json b/apps/designer/package.jsonindex 40f1af94af..0fb673a6ff 100644--- a/apps/designer/package.json+++ b/apps/designer/package.json@@ -69,7 +69,6 @@"lodash.merge": "^4.6.2","lodash.noop": "^3.0.1","lodash.snakecase": "^4.1.1",- "lodash.camelcase": "^4.3.0","mitt": "^3.0.0","nanoid": "^3.2.0","react": "^17.0.2",diff --git a/packages/webstudio-react-sdk/src/css/categories.ts b/packages/webstudio-react-sdk/src/css/categories.tsindex 85c1f13773..2b1e46467e 100644--- a/packages/webstudio-react-sdk/src/css/categories.ts+++ b/packages/webstudio-react-sdk/src/css/categories.ts@@ -8,10 +8,10 @@ const layout = [// Flex or grid"alignItems","justifyContent",+ "alignContent",// Grid"placeContent","justifyItems",- "alignContent","rowGap","columnGap","gridAutoFlow",diff --git a/packages/webstudio-react-sdk/src/css/properties.ts b/packages/webstudio-react-sdk/src/css/properties.tsindex 57d1f255bf..832e5d1fb7 100644--- a/packages/webstudio-react-sdk/src/css/properties.ts+++ b/packages/webstudio-react-sdk/src/css/properties.ts@@ -16,7 +16,7 @@ export const properties = {value: "normal",},popularity: 0.2430101,- appliesTo: "multilineFlexContainers",+ appliesTo: "flexContainers",},alignItems: {inherited: false,