Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) issue #1375 -- header size dynamically adjusted #1380

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions stories/Atom/Typography/Heading/Heading.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import '../../../assets/scss/_typography.scss';
import React from "react";
import "../../../assets/scss/_typography.scss";

export function Heading({
type,
Expand All @@ -14,8 +14,26 @@ export function Heading({
const heading_classes = className ?? '';

return (
<HeadingTag className={heading_classes} tabIndex={tab_index} data-viewport={data_viewport}>
<HeadingTag className={heading_classes} tabIndex={tab_index} data-viewport={data_viewport} style={{ fontSize: `${getSize()}vw` }}>
{label}
</HeadingTag>
);

function getSize() {
const MAX_SIZE = 8;
// there are more words
if (label.indexOf(' ') !== -1) {
return 4; // 4vw
}

// => there is only one word
if (label.length < 5) {
return 8; // 8vw
}

const WORD_LENGTH = label.length;
const WORD_SIZE = WORD_LENGTH * (0.88 ** WORD_LENGTH);
if (WORD_SIZE > MAX_SIZE) return MAX_SIZE;
return WORD_SIZE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function PageHeroOption({
<div className="pagehero-content color-black">
<Breadcrumbcomponent data={data} />
{args.Overline == 'On' && content && <Heading type="4" label={content} dataViewport="true" />}
<Heading type="2" label={title} dataViewport="true" />
<Heading type="2" label={title} className="title" dataViewport="true" />
{args.Subtitle == 'On' && subtitle && <p className="subtitle">{subtitle}</p>}
{args.CTA == 'On' && cta.label && <CtaButton label={cta.label} For_Primary={cta.for_primary} />}
</div>
Expand All @@ -39,7 +39,7 @@ export function PageHeroOption({
) : (
<picture>
<source media="(min-width: 767px)" srcSet={imgsrc} />
<img
<img
src={imgsrc2} alt={imgalt} />
</picture>
)}
Expand Down