From dc296dde681b6ad8204c8f078afa25e6ddbb9505 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Fri, 6 May 2022 15:51:26 +0100 Subject: [PATCH] Fix header styling for Wagtail 3.0 (#560) --- .../common/components/Header/index.tsx | 55 ++++++++++++++-- .../common/components/Tabs/index.tsx | 66 +++++++++++++++++-- 2 files changed, 109 insertions(+), 12 deletions(-) diff --git a/wagtail_localize/static_src/common/components/Header/index.tsx b/wagtail_localize/static_src/common/components/Header/index.tsx index e540e1a3..bb6fdbcd 100644 --- a/wagtail_localize/static_src/common/components/Header/index.tsx +++ b/wagtail_localize/static_src/common/components/Header/index.tsx @@ -1,6 +1,47 @@ import React, { FunctionComponent } from 'react'; import Icon from '../Icon'; import gettext from 'gettext'; +import styled from 'styled-components'; + +const StyledHeader = styled.header` + padding-inline-end: 20px; + padding-inline-start: 20px; + background-color: var(--color-primary); + color: #fff; + + @media screen and (min-width: 50em) { + padding-inline-end: 50px; + padding-inline-start: 50px; + } + + a { + text-decoration: none; + } +`; + +const StyledHeaderTitle = styled.h1` + color: #fff; + font-weight: 700; +`; + +const StyledButtonLink = styled.a` + &.button--live { + background-color: #fff; + color: var(--color-primary); + border-radius: 2px; + font-size: 14px; + font-weight: 600; + line-height: 2.3em; + padding: 0 0.75em; + + .icon { + width: 1.25em; + height: 1.25em; + vertical-align: text-top; + margin-right: 0.25em; + } + } +`; interface HeaderButtonActionProps { label: string; @@ -56,7 +97,7 @@ export const HeaderLinkAction: FunctionComponent = ({ } return ( - = ({ title={title} > {icon && } {label} - + ); }; @@ -254,22 +295,22 @@ const Header: FunctionComponent = ({ } return ( -
+ {breadcrumbRendered}
-

{' '} {/* TODO: Move style */} {icon && } {title} {subtitleWrapped} -

+
{actions}
    {meta}
-
+ ); }; diff --git a/wagtail_localize/static_src/common/components/Tabs/index.tsx b/wagtail_localize/static_src/common/components/Tabs/index.tsx index b5ac79ce..f3548e6e 100644 --- a/wagtail_localize/static_src/common/components/Tabs/index.tsx +++ b/wagtail_localize/static_src/common/components/Tabs/index.tsx @@ -15,8 +15,63 @@ export interface TabsProps { // Remove bottom margin that Wagtail adds by default // This makes it tricky to align the toolbox consistently when there are both tabs and no tabs -const ULWithoutMargin = styled.ul` +const StyledTabs = styled.ul` margin-bottom: 0; + margin-top: 0; + background-color: var(--color-primary); + + > li { + list-style-type: none; + width: 33%; + float: left; + padding: 0; + position: relative; + margin-right: 2px; + + @media screen and (min-width: 50em) { + width: auto; + padding: 0; + } + + &:first-of-type { + margin-left: 0; + } + + > a { + background-color: var(--color-primary-darker); + text-transform: uppercase; + font-weight: 600; + text-decoration: none; + display: block; + padding: 0.6em 0.7em 0.8em; + color: #fff; + border-top: 0.3em solid var(--color-primary-darker); + max-height: 1.44em; + overflow: hidden; + + @media screen and (min-width: 50em) { + padding-left: 20px; + padding-right: 20px; + } + } + + &.active > a { + box-shadow: none; + color: #333; + background-color: #fff; + border-top: 0.3em solid #333; + } + } + + &:before, + &:after { + content: ' '; + display: table; + } + + &:after { + clear: both; + } `; export const Tabs: FunctionComponent = ({ tabs, children }) => { @@ -24,7 +79,7 @@ export const Tabs: FunctionComponent = ({ tabs, children }) => { return ( <> - + {tabs.map(tab => { const onClick = ( e: React.MouseEvent @@ -35,7 +90,7 @@ export const Tabs: FunctionComponent = ({ tabs, children }) => { const classNames = []; - if (tab.slug == currentTab) { + if (tab.slug === currentTab) { classNames.push('active'); } @@ -61,7 +116,7 @@ export const Tabs: FunctionComponent = ({ tabs, children }) => { ); })} - +
{children} @@ -83,7 +138,8 @@ export const TabContent: FunctionComponent = ({ slug, children }) => { return (