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

feat(homepage): add floating variant #1498

Merged
merged 2 commits into from
Sep 20, 2023
Merged
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
4 changes: 4 additions & 0 deletions src/constants/homepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ export const HERO_LAYOUTS = {
value: "side",
label: "Side section",
},
FLOATING_SECTION: {
value: "floating",
label: "Floating section",
},
} as const
4 changes: 4 additions & 0 deletions src/layouts/components/Homepage/HeroBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ export const HeroBody = ({
return <HeroSideSectionLayout {...rest} />
}

if (currentSelectedOption === HERO_LAYOUTS.FLOATING_SECTION.value) {
return <HeroSideSectionLayout {...rest} />
}

const unmatchedOption: never = currentSelectedOption
throw new Error(`Unmatched option for layout: ${unmatchedOption}`)
}}
Expand Down
6 changes: 6 additions & 0 deletions src/styles/templates/components/hero.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@
.with-padding {
padding: 3rem 1.5rem;
}

@media screen and (min-width: 1024px) {
.hero-floating {
padding: 3rem;
}
}
23 changes: 23 additions & 0 deletions src/templates/homepage/HeroSection/HeroButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import editorStyles from "styles/isomer-cms/pages/Editor.module.scss"

import { getClassNames } from "templates/utils/stylingUtils"

interface HeroButtonProps {
button?: string
}
export const HeroButton = ({ button }: HeroButtonProps) => (
<>
{button ? (
<div
className={getClassNames(editorStyles, [
"bp-button",
"is-uppercase",
"search-button",
"is-secondary",
])}
>
{button}
</div>
) : null}
</>
)
22 changes: 1 addition & 21 deletions src/templates/homepage/HeroSection/HeroCenteredLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,9 @@ import { getClassNames } from "templates/utils/stylingUtils"

import { EditorHeroDropdownSection } from "types/homepage"

import { HeroButton } from "./HeroButton"
import { HeroDropdown } from "./HeroDropdown"

interface HeroButtonProps {
button?: string
}
const HeroButton = ({ button }: HeroButtonProps) => (
<>
{button ? (
<div
className={getClassNames(editorStyles, [
"bp-button",
"is-uppercase",
"search-button",
"default",
"is-secondary",
])}
>
{button}
</div>
) : null}
</>
)

interface HeroCenteredLayoutProps {
hero: {
background?: string
Expand Down
10 changes: 10 additions & 0 deletions src/templates/homepage/HeroSection/HeroSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ export const TemplateHeroSection = forwardRef<
toggleDropdown={toggleDropdown}
/>
)}
{variant === "floating" && (
<div className={getClassNames(editorStyles, ["hero-floating"])}>
<HeroSideLayout
{...hero}
title={hero.title || ""}
dropdownIsActive={dropdownIsActive}
toggleDropdown={toggleDropdown}
/>
</div>
)}
</section>
{/* Key highlights */}
{!hero.dropdown && hero.key_highlights ? (
Expand Down
56 changes: 22 additions & 34 deletions src/templates/homepage/HeroSection/HeroSideLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getClassNames } from "templates/utils/stylingUtils"
import { SectionBackgroundColor, SectionSize } from "types/hero"
import { EditorHeroDropdownSection } from "types/homepage"

import { HeroButton } from "./HeroButton"
import { HeroDropdown } from "./HeroDropdown"

const TRANSLUCENT_GRAY = "#00000080"
Expand Down Expand Up @@ -72,41 +73,28 @@ const HeroInfoboxDesktop = ({
{subtitle}
</p>
)}

{dropdown ? (
<div
className={getClassNames(editorStyles, ["is-flex"])}
style={{
justifyContent: "center",
alignContent: "center",
}}
>
<HeroDropdown
title={dropdown.title}
options={dropdown.options}
isActive={dropdownIsActive}
toggleDropdown={toggleDropdown}
/>
</div>
) : (
// NOTE: This is to mirror the template structure
// as closely as possible.
url &&
button && (
<a
href="/"
className={getClassNames(editorStyles, [
"bp-button",
"is-secondary",
"is-uppercase",
"search-button",
])}
>
{button}
</a>
)
)}
</div>

{dropdown ? (
<div
className={getClassNames(editorStyles, ["is-flex"])}
style={{
justifyContent: "center",
alignContent: "center",
}}
>
<HeroDropdown
title={dropdown.title}
options={dropdown.options}
isActive={dropdownIsActive}
toggleDropdown={toggleDropdown}
/>
</div>
) : (
// NOTE: This is to mirror the template structure
// as closely as possible.
url && button && <HeroButton button={button} />
)}
</div>
</div>
)
Expand Down
Loading