diff --git a/src/components/header/Header.js b/src/components/header/Header.js index 3b0313a3..94b93006 100644 --- a/src/components/header/Header.js +++ b/src/components/header/Header.js @@ -1,12 +1,12 @@ -import { html, LitElement, nothing } from "lit" -import { unsafeHTML } from "lit/directives/unsafe-html.js" +import { html, LitElement } from "lit" import { styleMap } from "lit/directives/style-map.js" +/** @ts-ignore */ import headerStyles from "./header.css" +/** @ts-ignore */ import gridStyles from "../../styles/grid.css" +/** @ts-ignore */ import headingsStyles from "../../styles/headings.css" -import "../chip/leu-chip-link.js" -import "../breadcrumb/leu-breadcrumb.js" // links: // top topics chip: https://www.zh.ch/de/gesundheit.html @@ -34,47 +34,13 @@ export class LeuHeader extends LitElement { static styles = [gridStyles, headingsStyles, headerStyles] static properties = { - pageTitle: { type: String }, - subtitle: { type: String }, - breadcrumb: { type: Array }, - topTopics: { type: Array }, - color: { type: String }, + backgroundColor: { type: String }, } constructor() { super() - /** @type {Array} */ - this.breadcrumb = null - /** @type {string} */ - this.subtitle = null - /** @type {Array} */ - this.topTopics = null - /** @type {string} */ - this.color = "white" - } - - renderTopTopics() { - return html` -
-

Top Themen

- -
- ` - } - - renderLead() { - return html`

${this.subtitle}

` + /** @type {"blue" | "darkblue" | "turquoise" | "green" | "bordeaux" | "magenta" | "violet" | "gray" | "white"} */ + this.backgroundColor = "white" } renderLogo() { @@ -82,7 +48,8 @@ export class LeuHeader extends LitElement { +
@@ -114,14 +81,12 @@ export class LeuHeader extends LitElement {
-
@@ -130,8 +95,8 @@ export class LeuHeader extends LitElement {
- ${this.topTopics ? this.renderTopTopics() : nothing} - ${this.subtitle ? this.renderLead() : nothing} + +
diff --git a/src/components/header/header.css b/src/components/header/header.css index 919f699f..c5876188 100644 --- a/src/components/header/header.css +++ b/src/components/header/header.css @@ -1,3 +1,5 @@ +@import url("../../styles/custom-media.css"); + :host, :host * { box-sizing: border-box; @@ -10,117 +12,127 @@ font-family: var(--header-font-black); } -header { +.header { padding-bottom: 1.5rem; padding-top: 1.5rem; } -.breadcrumb { +.breadcrumbs { font-size: 16px; margin-bottom: 0.75rem; min-height: 1.5em; } -@media (width <= 340px) { - .breadcrumb { - margin-left: -24px; +.title { + word-break: break-word; + font: var(--leu-t-curve-180-black-font); + margin-top: 0; + margin-bottom: 1.5rem; +} + +@media (--viewport-large) { + .title { + margin-bottom: 2rem; } } -.title { - word-break: break-word; +@media (--viewport-xlarge) { + .title { + margin-bottom: 2.5rem; + } } -/* top topics */ -.toptopics { +/* Chips */ +.chips { max-width: 48rem; } -.toptopics h2 { +::slotted(h2[slot="chips"]) { font-size: 0.75rem; line-height: 1.5; margin-bottom: 0.5rem; padding-top: 0; } -.toptopics ul { - font-size: 0; - list-style-type: none; +::slotted(leu-chip-group) { margin-bottom: 0.75rem; - margin-left: -4px; - margin-right: -4px; - max-width: 100%; - padding: 0; +} + +@media (--viewport-regular) { + ::slotted(leu-chip-group) { + margin-left: -1rem; + margin-right: -1rem; + } } @media (width >=20em) and (width <=24.99em) and (width >=20em) and (width <=24.99em) { - .toptopics ul { + .chips ul { margin-left: calc(16.6667% + 0.125rem); } } @media (width >=20em) and (width <=24.99em) and (width >=25em) and (width <=37.49em) { - .toptopics ul { + .chips ul { margin-left: calc(16.6667% + 0.1667rem); } } @media (width >=20em) and (width <=24.99em) and (width >=37.5em) and (width <=52.49em) { - .toptopics ul { + .chips ul { margin-left: calc(10% + 0.1rem); } } @media (width >=20em) and (width <=24.99em) and (width >=52.5em) and (width <=63.99em) { - .toptopics ul { + .chips ul { margin-left: calc(11.1111% + 0.1667rem); } } @media (width >=20em) and (width <=24.99em) and (width >=64em) and (width <=79.99em) { - .toptopics ul { + .chips ul { margin-left: calc(12.5% + 0.1667rem); } } @media (width >=20em) and (width <=24.99em) and (width >=80em) { - .toptopics ul { + .chips ul { margin-left: calc(12.5% + 0.25rem); } } @media (width >= 37.5em) { - .toptopics ul { + .chips ul { margin-left: -12px; margin-right: -12px; } } @media (width >=20em) and (width <=52.49em) { - .toptopics h2 { + .chips h2 { margin-bottom: 0; } } @media (width >=52.5em) { - .toptopics h2 { + .chips h2 { margin-bottom: 0.25rem; } } @media (width >= 20em) and (width <= 24.99em) and (width >= 20em) and (width <= 24.99em) { - .toptopics h2 { + .chips h2 { margin-left: calc(16.6667% + 0.125rem); } } -.toptopics li { +.chips li { display: inline-block; margin-right: 0.25rem; max-width: 100%; } -.toptopics leu-chip-link { +.chips leu-chip-link { font-size: 1.125rem; margin-bottom: 0; margin-top: 0.5rem; @@ -302,7 +314,7 @@ header { } /* lead */ -.lead { +::slotted([slot="lead"]) { font-size: 18px; hyphens: auto; line-height: 1.3; @@ -312,79 +324,79 @@ header { } @media (width >=400px) { - .lead { + ::slotted([slot="lead"]) { font-size: calc(1vw + 14px); } } @media (width >=600px) { - .lead { + ::slotted([slot="lead"]) { font-size: 20px; } } @media (width >=1024px) { - .lead { + ::slotted([slot="lead"]) { font-size: calc(1.5625vw + 4px); } } @media (width >=1280px) { - .lead { + ::slotted([slot="lead"]) { font-size: 24px; } } @media (width >=52.5em) { - .lead { + ::slotted([slot="lead"]) { margin-bottom: 1.25rem; } } @media (width >=80em) { - .lead { + ::slotted([slot="lead"]) { margin-bottom: 1.5rem; } } @media (width >=20em) and (width <=24.99em) and (width >=20em) and (width <=24.99em) { - .lead { + ::slotted([slot="lead"]) { text-indent: calc(16.6667% + 0.125rem); } } @media (width >=20em) and (width <=24.99em) and (width >=25em) and (width <=37.49em) { - .lead { + ::slotted([slot="lead"]) { text-indent: calc(16.6667% + 0.1667rem); } } @media (width >=20em) and (width <=24.99em) and (width >=37.5em) and (width <=52.49em) { - .lead { + ::slotted([slot="lead"]) { text-indent: calc(10% + 0.1rem); } } @media (width >=20em) and (width <=24.99em) and (width >=52.5em) and (width <=63.99em) { - .lead { + ::slotted([slot="lead"]) { text-indent: calc(11.1111% + 0.1667rem); } } @media (width >=20em) and (width <=24.99em) and (width >=64em) and (width <=79.99em) { - .lead { + ::slotted([slot="lead"]) { text-indent: calc(12.5% + 0.1667rem); } } @media (width >=20em) and (width <=24.99em) and (width >=80em) { - .lead { + ::slotted([slot="lead"]) { text-indent: calc(12.5% + 0.25rem); } } @media (width >=25em) { - .lead { + ::slotted([slot="lead"]) { text-indent: 0; } } diff --git a/src/components/header/stories/header.stories.js b/src/components/header/stories/header.stories.js index c7b3be2e..c4308256 100644 --- a/src/components/header/stories/header.stories.js +++ b/src/components/header/stories/header.stories.js @@ -1,21 +1,57 @@ -import { html } from "lit" -import "../leu-header.js" +import { html, nothing } from "lit" +import { unsafeHTML } from "lit/directives/unsafe-html.js" import { HEADER_COLORS } from "../Header.js" +import "../leu-header.js" +import "../../chip/leu-chip-group.js" +import "../../chip/leu-chip-link.js" +import "../../breadcrumb/leu-breadcrumb.js" export default { title: "Header", component: "leu-header", } -function Template({ pageTitle, color, breadcrumb, subtitle, topTopics }) { +function renderBreadcrumbs(breadcrumbs, inverted) { + if (!breadcrumbs) return nothing + return html` + + ` +} + +function renderChips(chips, inverted) { + if (!chips) return nothing + return html`

Top Themen

+ + ${chips.map( + (topic) => html` + + ` + )} + ` +} + +function renderLead(lead) { + if (!lead) return nothing + return html`

${lead}

` +} + +function Template({ pageTitle, color, breadcrumbs, lead, chips }) { + const inverted = color !== "white" return html` - + + ${renderBreadcrumbs(breadcrumbs, inverted)} + ${unsafeHTML(pageTitle)} + ${renderChips(chips, inverted)} ${renderLead(lead)} + ` } @@ -26,7 +62,7 @@ Regular.argTypes = { Regular.args = { pageTitle: "Trinkwasser", color: "blue", - breadcrumb: [ + breadcrumbs: [ { label: "Kanton Zürich", href: "https://www.zh.ch/de.html" }, { label: "Gesundheit", href: "https://www.zh.ch/de/gesundheit.html" }, { @@ -42,25 +78,24 @@ Regular.args = { href: "https://www.zh.ch/de/gesundheit/lebensmittel-gebrauchsgegenstaende/lebensmittel/trinkwasser.html", }, ], - subtitle: - "Im Jahr werden im Kanton Zürich rund 140 Millionen Kubikmeter Trinkwasser verbraucht. Dies entspricht in etwa dem Volumen des Greifensees. Das Trinkwasser kommt zu je 40 Prozent aus dem Zürichsee und aus Grundwasservorkommen. Die restlichen 20 Prozent stammen aus Quellen.", + lead: "Im Jahr werden im Kanton Zürich rund 140 Millionen Kubikmeter Trinkwasser verbraucht. Dies entspricht in etwa dem Volumen des Greifensees. Das Trinkwasser kommt zu je 40 Prozent aus dem Zürichsee und aus Grundwasservorkommen. Die restlichen 20 Prozent stammen aus Quellen.", } Regular.parameters = { layout: "fullscreen", } -export const TopTopics = Template.bind({}) -TopTopics.argTypes = { +export const Chips = Template.bind({}) +Chips.argTypes = { color: { control: "select", options: HEADER_COLORS }, } -TopTopics.args = { +Chips.args = { pageTitle: "Familie", color: "turquoise", - breadcrumb: [ + breadcrumbs: [ { label: "Kanton Zürich", href: "https://www.zh.ch/de.html" }, { label: "Familie", href: "https://www.zh.ch/de/familie.html" }, ], - topTopics: [ + chips: [ { label: "Kinder- und Jugendhilfezentren", href: "https://www.zh.ch/de/familie/angebote-fuer-familien-mit-kindern/kinder-und-jugendhilfezentren.html", @@ -75,10 +110,9 @@ TopTopics.args = { }, { label: "Adoption", href: "https://www.zh.ch/de/familie/adoption.html" }, ], - subtitle: - "Haben Sie Fragen zum Familienalltag oder suchen Sie Unterstützung bei familiären Herausforderungen? Möchten Sie mehr über die Geschichte Ihrer Familie erfahren? Oder steht ein wichtiges Ereignis bevor und Sie suchen Informationen, um Administratives zu erledigen? Hier finden Sie alles, was Familien im Kanton Zürich bewegt und was sie benötigen.", + lead: "Haben Sie Fragen zum Familienalltag oder suchen Sie Unterstützung bei familiären Herausforderungen? Möchten Sie mehr über die Geschichte Ihrer Familie erfahren? Oder steht ein wichtiges Ereignis bevor und Sie suchen Informationen, um Administratives zu erledigen? Hier finden Sie alles, was Familien im Kanton Zürich bewegt und was sie benötigen.", } -TopTopics.parameters = { +Chips.parameters = { layout: "fullscreen", } @@ -94,7 +128,7 @@ White.args = { `, color: "white", - breadcrumb: [ + breadcrumbs: [ { label: "Kanton Zürich", href: "https://www.zh.ch/de.html" }, { label: "Politik & Staat ", @@ -117,7 +151,7 @@ White.args = { href: "https://app.statistik.zh.ch/wahlen_abstimmungen/prod/Archive/Det/1_1_20231119/250107/Majorz/Resultate/Candidate/1/Tiana_Angelina%20Moser", }, ], - subtitle: "Ständeratswahl 2023 - 2. Wahlgang", + lead: "Ständeratswahl 2023 - 2. Wahlgang", } White.parameters = { layout: "fullscreen",