From 2be5e1c2098c7bca510e13f9223e4f65a41b4641 Mon Sep 17 00:00:00 2001 From: Stephen Watkins Date: Thu, 19 Dec 2024 16:27:13 -0500 Subject: [PATCH] fix(ForgeLayout): fix performance/bg attachment (#1551) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📝 Changes - Stick background on scroll - Try to fix some perf issues ## ✅ Checklist Easy UI has certain UX standards that must be met. In general, non-trivial changes should meet the following criteria: - [x] Visuals match Design Specs in Figma - [x] Stories accompany any component changes - [x] Code is in accordance with our style guide - [x] Design tokens are utilized - [x] Unit tests accompany any component changes - [x] TSDoc is written for any API surface area - [x] Specs are up-to-date - [x] Console is free from warnings - [x] No accessibility violations are reported - [x] Cross-browser check is performed (Chrome, Safari, Firefox) - [x] Changeset is added ~Strikethrough~ any items that are not applicable to this pull request. --- .changeset/cyan-goats-promise.md | 5 ++ .../src/ForgeLayout/ForgeLayout.module.scss | 57 ++++++++++--------- .../src/ForgeLayout/ForgeLayout.stories.tsx | 2 +- easy-ui-react/src/ForgeLayout/ForgeLayout.tsx | 16 ++++-- 4 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 .changeset/cyan-goats-promise.md diff --git a/.changeset/cyan-goats-promise.md b/.changeset/cyan-goats-promise.md new file mode 100644 index 00000000..ccf5f8df --- /dev/null +++ b/.changeset/cyan-goats-promise.md @@ -0,0 +1,5 @@ +--- +"@easypost/easy-ui": patch +--- + +fix(ForgeLayout): attach bg diff --git a/easy-ui-react/src/ForgeLayout/ForgeLayout.module.scss b/easy-ui-react/src/ForgeLayout/ForgeLayout.module.scss index 7697b155..544eb8cd 100644 --- a/easy-ui-react/src/ForgeLayout/ForgeLayout.module.scss +++ b/easy-ui-react/src/ForgeLayout/ForgeLayout.module.scss @@ -19,8 +19,8 @@ padding-right: component-token("forge-layout", "shell-gutter"); gap: component-token("forge-layout", "shell-gutter"); min-height: 100svh; - background-color: design-token("color.neutral.025"); position: relative; + overflow-x: clip; } .modeTest { @@ -37,6 +37,15 @@ @include component-token("forge-layout", "header-border-width", 2px); } +.bg { + position: fixed; + top: 0; + left: 0; + width: 100vw; + height: 100vh; + background-color: design-token("color.neutral.025"); +} + .backgroundDecoration01 { background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzA5IiBoZWlnaHQ9IjI5NSIgdmlld0JveD0iMCAwIDMwOSAyOTUiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik00NC4xMTc1IDIyOC41NjdDMzQuNjg2OSAyMjYuOTU3IDI3LjcwMjEgMjE4LjkxOCAyNy40MjQgMjA5LjM1N0wyNS41MDk2IDE0My41NzNDMjUuMzM2NSAxMzcuNTU5IDI3Ljg2OTkgMTMxLjc4IDMyLjQxMTIgMTI3LjgzNEw2MS41MjM5IDEwMi41MzRDNjYuMDY1MiA5OC41ODc5IDcyLjEzOTggOTYuODg0NSA3OC4wNzQ4IDk3Ljg5NzhMMTA2LjE4NCAxMDIuNjk4TDExNi4zNjYgMTU0LjMzNkMxMTcuNzQ0IDE2MS4zMzQgMTIyLjczMyAxNjcuMDc2IDEyOS40NzMgMTY5LjQxN0wxNjEuMTU5IDE4MC40MzdMMTYxLjU1MiAxOTMuOTY3QzE2MS43MjkgMTk5Ljk4MiAxNTkuMTk1IDIwNS43NjEgMTU0LjY1NCAyMDkuNzA3TDEyNS41NDEgMjM1LjAwN0MxMjAuOTk3IDIzOC45NTIgMTE0LjkyMiAyNDAuNjU1IDEwOC45OTEgMjM5LjY0M0w0NC4xMTc1IDIyOC41NjdaIiBmaWxsPSIjRkI1QzU5Ii8+CjxwYXRoIGQ9Ik0yMDQuNjczIDE4NC44ODZDMTk5LjI0NCAxODkuNjAzIDE5MS43MDUgMTkxLjA1NSAxODQuOTEgMTg4LjY5NkwxNjEuMTU5IDE4MC40MzdMMTU5LjYzOCAxMjguMTgzQzE1OS4zNiAxMTguNjIyIDE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4MiAxODUuNjI5QzEzOS43ODkgMjA4LjY2MiAxMTMuNTY5IDIyMi42MjMgODUuMzU3IDIyMi42MjJMODUuMzUzIDIyMi42MjRDNTQuODM2NiAyMjIuNjIzIDI2LjY1MzIgMjA2LjI5NyAxMS40NjgyIDE3OS44MjRDMy45NDI0IDE2Ni43MDMgMC4xNzczMDIgMTUyLjA3NiAwLjE3OTkwMiAxMzcuNDQ1QzAuMTc4ODAyIDEyMi44MTYgMy45NDAyIDEwOC4xOTEgMTEuNDY5MiA5NS4wNjZDMTkuMDgxOCA4MS43OTQgMjkuOTYwMyA3MS4wNzIgNDIuNzY1NiA2My42NzlDNTUuNTcwOCA1Ni4yODYgNzAuMTM2IDUyLjI2OCA4NS4zNTMgNTIuMjdDMTEwLjI1NSA1Mi4yNjkgMTMzLjYwMyA2My4xMzYgMTQ5LjU5OSA4MS41MjVaIiBmaWxsPSIjMDBFNUFFIi8+Cjwvc3ZnPgo="); @@ -53,13 +62,30 @@ } .header { + position: sticky; + top: 0; + height: component-token("forge-layout", "header-height"); + display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; min-width: 0; + border-bottom: 2px solid transparent; - z-index: calc(#{design-token("z-index.nav")} + 1); + z-index: design-token("z-index.nav"); +} + +.headerBg { + position: absolute; + top: 0; + left: -100vw; + width: 300vw; + height: component-token("forge-layout", "header-height"); + + background-color: design-token("color.neutral.025"); + border-bottom: component-token("forge-layout", "header-border-width") solid + component-token("forge-layout", "header-border-color"); } .content { @@ -68,33 +94,8 @@ } .controls { + position: relative; display: flex; align-items: center; gap: design-token("space.2"); } - -.fauxContainer { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - - display: flex; - flex-direction: column; - pointer-events: none; -} - -.fauxHeader { - background-color: design-token("color.neutral.025"); - border-bottom: component-token("forge-layout", "header-border-width") solid - component-token("forge-layout", "header-border-color"); - z-index: design-token("z-index.nav"); -} - -.fauxHeader, -.header { - position: sticky; - top: 0; - height: component-token("forge-layout", "header-height"); -} diff --git a/easy-ui-react/src/ForgeLayout/ForgeLayout.stories.tsx b/easy-ui-react/src/ForgeLayout/ForgeLayout.stories.tsx index 5a165022..232eb171 100644 --- a/easy-ui-react/src/ForgeLayout/ForgeLayout.stories.tsx +++ b/easy-ui-react/src/ForgeLayout/ForgeLayout.stories.tsx @@ -106,7 +106,7 @@ const Template = (args: Partial) => { -
Page Content
+
Page Content
diff --git a/easy-ui-react/src/ForgeLayout/ForgeLayout.tsx b/easy-ui-react/src/ForgeLayout/ForgeLayout.tsx index 9554a0a7..4033c20b 100644 --- a/easy-ui-react/src/ForgeLayout/ForgeLayout.tsx +++ b/easy-ui-react/src/ForgeLayout/ForgeLayout.tsx @@ -168,20 +168,21 @@ export function ForgeLayout(props: ForgeLayoutProps) { } = props; const className = classNames( styles.ForgeLayout, - styles[variationName("backgroundDecoration", backgroundDecoration)], styles[variationName("mode", mode)], styles[variationName("navState", navState)], ); + const bgClassName = classNames( + styles.bg, + styles[variationName("backgroundDecoration", backgroundDecoration)], + ); const context = useMemo(() => { return { mode, navState }; }, [mode, navState]); return ( +
{children} -
-
-
); @@ -189,7 +190,12 @@ export function ForgeLayout(props: ForgeLayoutProps) { function ForgeLayoutHeader(props: ForgeLayoutHeaderProps) { const { children } = props; - return
{children}
; + return ( +
+
+ {children} +
+ ); } function ForgeLayoutControls(props: ForgeLayoutControlsProps) {