From 889b4c7a91f1a9b95c9fd7d4b3cdb20b2ee4946b Mon Sep 17 00:00:00 2001 From: monospaced Date: Thu, 16 Nov 2023 11:58:05 +0000 Subject: [PATCH] feat: improve responsive behaviour --- .../core/components/ComponentList/index.tsx | 2 +- .../ComponentList/styles.module.css | 7 +- .../fields/ArrayField/styles.module.css | 9 +- .../components/InputOrGroup/styles.module.css | 2 +- packages/core/components/LayerTree/index.tsx | 2 +- .../components/LayerTree/styles.module.css | 19 ++- .../components/OutlineList/styles.module.css | 3 +- packages/core/components/Puck/index.tsx | 154 +++++------------- .../core/components/Puck/styles.module.css | 151 +++++++++++++++++ .../SidebarSection/styles.module.css | 4 + .../src/HeadingAnalyzer.tsx | 2 +- 11 files changed, 221 insertions(+), 134 deletions(-) create mode 100644 packages/core/components/Puck/styles.module.css diff --git a/packages/core/components/ComponentList/index.tsx b/packages/core/components/ComponentList/index.tsx index 7c3d06afed..e1fd9de623 100644 --- a/packages/core/components/ComponentList/index.tsx +++ b/packages/core/components/ComponentList/index.tsx @@ -31,7 +31,7 @@ const ComponentListItem = ({ > {() => ( <> - {component} +
{component}
diff --git a/packages/core/components/ComponentList/styles.module.css b/packages/core/components/ComponentList/styles.module.css index 83d3e2758e..b3760fef22 100644 --- a/packages/core/components/ComponentList/styles.module.css +++ b/packages/core/components/ComponentList/styles.module.css @@ -53,13 +53,14 @@ font-size: var(--puck-font-size-xxs); justify-content: space-between; align-items: center; - gap: 12px; cursor: grab; margin-bottom: 12px; } -.ComponentListItemIcon { - color: var(--puck-color-grey-4); +.ComponentListItem-name { + overflow-x: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .ComponentList:not(.ComponentList--isDraggingFrom) diff --git a/packages/core/components/InputOrGroup/fields/ArrayField/styles.module.css b/packages/core/components/InputOrGroup/fields/ArrayField/styles.module.css index e5aa7ae580..71101d946e 100644 --- a/packages/core/components/InputOrGroup/fields/ArrayField/styles.module.css +++ b/packages/core/components/InputOrGroup/fields/ArrayField/styles.module.css @@ -73,10 +73,11 @@ color: var(--puck-color-grey-3); display: flex; align-items: center; + gap: 2px; justify-content: space-between; font-size: var(--puck-font-size-xxs); list-style: none; - padding: 12px 16px; + padding: 12px 15px; position: relative; overflow: hidden; } @@ -114,18 +115,18 @@ border: none; border-top: 1px solid var(--puck-color-grey-8); margin: 0; - padding: 16px; + padding: 16px 15px; } .ArrayFieldItem-rhs { display: flex; - gap: 8px; + gap: 4px; align-items: center; } .ArrayFieldItem-actions { display: flex; - gap: 8px; + gap: 4px; opacity: 0; } diff --git a/packages/core/components/InputOrGroup/styles.module.css b/packages/core/components/InputOrGroup/styles.module.css index 402569f867..e5ee010b94 100644 --- a/packages/core/components/InputOrGroup/styles.module.css +++ b/packages/core/components/InputOrGroup/styles.module.css @@ -48,7 +48,7 @@ border-color: var(--puck-color-grey-8); border-radius: 4px; font-family: inherit; - padding: 12px 16px; + padding: 12px 15px; width: 100%; } diff --git a/packages/core/components/LayerTree/index.tsx b/packages/core/components/LayerTree/index.tsx index a42f73b4e9..9f332249f8 100644 --- a/packages/core/components/LayerTree/index.tsx +++ b/packages/core/components/LayerTree/index.tsx @@ -128,7 +128,7 @@ export const LayerTree = ({ )} - {item.type} +
{item.type}
diff --git a/packages/core/components/LayerTree/styles.module.css b/packages/core/components/LayerTree/styles.module.css index 522f3cde1e..bce29ad38c 100644 --- a/packages/core/components/LayerTree/styles.module.css +++ b/packages/core/components/LayerTree/styles.module.css @@ -27,13 +27,13 @@ } .Layer-inner { - padding-left: 20px; - padding-right: 8px; - border-radius: 3px; + padding-left: 12px; + padding-right: 4px; + border-radius: 4px; } .Layer--containsZone > .Layer-inner { - padding-left: 8px; + padding-left: 0; } .Layer-clickable { @@ -69,7 +69,7 @@ .Layer-zones { display: none; - margin-left: 20px; + margin-left: 12px; } .Layer--isSelected > .Layer-zones, @@ -78,7 +78,7 @@ } .Layer-zones > .LayerTree { - margin-left: 16px; + margin-left: 12px; } .Layer-title, @@ -87,6 +87,13 @@ gap: 8px; align-items: center; margin: 8px 4px; + overflow-x: hidden; +} + +.Layer-name { + overflow-x: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .Layer-icon { diff --git a/packages/core/components/OutlineList/styles.module.css b/packages/core/components/OutlineList/styles.module.css index d434b43054..40619e44b9 100644 --- a/packages/core/components/OutlineList/styles.module.css +++ b/packages/core/components/OutlineList/styles.module.css @@ -2,7 +2,6 @@ color: var(--puck-color-grey-2); font-family: var(--puck-font-stack); margin: 0; - margin-left: 16px; padding-left: 16px; position: relative; list-style: none; @@ -39,5 +38,5 @@ } .OutlineListItem > .OutlineList { - margin: 8px; + margin: 8px 0; } diff --git a/packages/core/components/Puck/index.tsx b/packages/core/components/Puck/index.tsx index e68e7054db..f1e14391e7 100644 --- a/packages/core/components/Puck/index.tsx +++ b/packages/core/components/Puck/index.tsx @@ -33,10 +33,14 @@ import { LayerTree } from "../LayerTree"; import { findZonesForArea } from "../../lib/find-zones-for-area"; import { areaContainsZones } from "../../lib/area-contains-zones"; import { flushZones } from "../../lib/flush-zones"; +import getClassNameFactory from "../../lib/get-class-name-factory"; import { usePuckHistory } from "../../lib/use-puck-history"; import { AppProvider, defaultAppState } from "./context"; import { useComponentList } from "../../lib/use-component-list"; import { useResolvedData } from "../../lib/use-resolved-data"; +import styles from "./styles.module.css"; + +const getClassName = getClassNameFactory("Puck", styles); const Field = () => {}; @@ -270,7 +274,7 @@ export function Puck({ }, []); return ( -
+
@@ -354,31 +358,8 @@ export function Puck({ {(ctx) => { return ( -
-
+
+
{renderHeader ? ( renderHeader({ children: ( @@ -395,21 +376,8 @@ export function Puck({ state: appState, }) ) : ( -
-
+
+
dispatch({ @@ -424,31 +392,20 @@ export function Puck({
-
+
{headerTitle || rootProps.title || "Page"} {headerPath && ( - - {headerPath} - + <> + {" "} + + {headerPath} + + )}
-
+
- {renderHeaderActions && - renderHeaderActions({ - state: appState, - dispatch, - })} - +
+ {renderHeaderActions && + renderHeaderActions({ + state: appState, + dispatch, + })} +
+
+ +
)}
-
+
{componentList ? ( @@ -549,30 +501,12 @@ export function Puck({
setItemSelector(null)} id="puck-frame" > -
-
+
+
-
+
{ const headings = window.document - .querySelector(".puck-root")! + .querySelector("#puck-frame")! .querySelectorAll("h1,h2,h3,h4,h5,h6"); const _outline: { rank: number; text: string; analyzeId: string }[] = [];