From f3653a7104a230b364780c7bc4289da6752121c4 Mon Sep 17 00:00:00 2001 From: Matt Kubej Date: Wed, 19 Jul 2023 20:36:16 +0000 Subject: [PATCH] [TopBar] convert to grid and center align search field --- .changeset/spicy-elephants-clap.md | 5 ++ .../src/components/TopBar/TopBar.scss | 53 ++++++++++--------- .../src/components/TopBar/TopBar.tsx | 10 ++-- .../components/SearchField/SearchField.scss | 1 - 4 files changed, 40 insertions(+), 29 deletions(-) create mode 100644 .changeset/spicy-elephants-clap.md diff --git a/.changeset/spicy-elephants-clap.md b/.changeset/spicy-elephants-clap.md new file mode 100644 index 00000000000..a0a92fbd427 --- /dev/null +++ b/.changeset/spicy-elephants-clap.md @@ -0,0 +1,5 @@ +--- +'@shopify/polaris': patch +--- + +[TopBar] convert to grid and center align search field diff --git a/polaris-react/src/components/TopBar/TopBar.scss b/polaris-react/src/components/TopBar/TopBar.scss index b57ae87c558..606c727b03e 100644 --- a/polaris-react/src/components/TopBar/TopBar.scss +++ b/polaris-react/src/components/TopBar/TopBar.scss @@ -1,18 +1,33 @@ @import '../../styles/common'; @import './variables'; -$icon-size: 20px; +$navigation-column-width: 240px; +$search-column-width: 580px; +$search-column-width-se23: 480px; .TopBar { position: relative; - display: flex; + display: grid; + grid-template-columns: auto 1fr auto; + align-items: center; height: $top-bar-height; box-shadow: var(--p-shadow-sm); background-color: var(--p-color-bg); + @media #{$p-breakpoints-md-up} { + grid-template-columns: $navigation-column-width 1fr auto; + } + @media #{$p-breakpoints-lg-up} { + grid-template-columns: 1fr $search-column-width 1fr; + } + #{$se23} & { background-color: var(--p-color-bg-inverse); box-shadow: var(--p-shadow-xs); + + @media #{$p-breakpoints-lg-up} { + grid-template-columns: 1fr $search-column-width-se23 1fr; + } } &::after { @@ -132,12 +147,16 @@ $icon-size: 20px; // stylelint-enable selector-max-specificity } -.Contents { +.LeftContent { + display: flex; +} + +.Search { z-index: var(--p-z-index-1); display: flex; flex: 1 1 auto; align-items: center; - justify-content: flex-end; + justify-content: center; height: 100%; @media #{$p-breakpoints-md-up} { @@ -145,27 +164,13 @@ $icon-size: 20px; } } -.SearchField { - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - @include page-layout; - position: relative; - width: 100%; - margin: 0; - max-width: none; - margin-right: var(--p-space-1); - - @media #{$p-breakpoints-xl-up} { - // stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY - margin-left: calc((100% - #{$page-max-width}) / 2); - } - - #{$se23} & { - padding: 0; +.RightContent { + display: flex; + justify-content: flex-end; +} - @media #{$p-breakpoints-md-up} { - padding: 0 var(--p-space-6); - } - } +.SecondaryMenu { + margin-left: var(--p-space-2); } .SecondaryMenu svg { diff --git a/polaris-react/src/components/TopBar/TopBar.tsx b/polaris-react/src/components/TopBar/TopBar.tsx index 3cf1ea28ae9..3631f10b4ee 100644 --- a/polaris-react/src/components/TopBar/TopBar.tsx +++ b/polaris-react/src/components/TopBar/TopBar.tsx @@ -142,10 +142,12 @@ export const TopBar: React.FunctionComponent & { return (
- {navigationButtonMarkup} - {contextMarkup} -
-
{searchMarkup}
+
+ {navigationButtonMarkup} + {contextMarkup} +
+
{searchMarkup}
+
{secondaryMenu}
{userMenu}
diff --git a/polaris-react/src/components/TopBar/components/SearchField/SearchField.scss b/polaris-react/src/components/TopBar/components/SearchField/SearchField.scss index 0954c551feb..eb935cc37f8 100644 --- a/polaris-react/src/components/TopBar/components/SearchField/SearchField.scss +++ b/polaris-react/src/components/TopBar/components/SearchField/SearchField.scss @@ -23,7 +23,6 @@ $search-icon-width-se23: calc(#{$icon-size-se23} + var(--p-space-3)); align-items: center; border: var(--p-border-width-1) solid transparent; width: 100%; - max-width: $search-max-width; } // We have both a focused class and a focus pseudo selector here // because we allow "faked" focus for when the search is still