Skip to content

Commit

Permalink
refactor(hero): duplicate changes from template (#1551)
Browse files Browse the repository at this point in the history
* refactor(hero): duplicate changes from template

* fix(scss-breakpoints): map.get -> map-get

---------

Co-authored-by: seaerchin <[email protected]>
  • Loading branch information
seaerchin and seaerchin authored Oct 3, 2023
1 parent ec77e97 commit 5fcc930
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 71 deletions.
14 changes: 3 additions & 11 deletions src/styles/isomer-template/components/homepage/_hero.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
padding: 3rem 1.5rem;
}

@media screen and (min-width: map.get($breakpoints, "md")) {
@media screen and (min-width: map-get($breakpoints, "md")) {
.hero-floating {
padding: 3rem;
}
Expand Down Expand Up @@ -60,15 +60,7 @@
width: 50%;
}

.hero-alignment-left {
align-self: flex-end;
}

.hero-alignment-right {
align-self: flex-start;
}

@media screen and (min-width: map.get($breakpoints, "xl")) {
@media screen and (min-width: map-get($breakpoints, "xl")) {
.hero-side-sm {
width: 50%;
}
Expand All @@ -88,7 +80,7 @@
}
}

@media screen and ((max-width: map.get($breakpoints, "xl") - 1)) {
@media screen and ((max-width: (map-get($breakpoints, "xl") - 1))) {
.hero-side-sm {
width: 33%;
}
Expand Down
2 changes: 1 addition & 1 deletion src/styles/isomer-template/theme/_breakpoints.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ $breakpoints: (
);

// Maximum width of site contents
$container-max-width: map.get($breakpoints, "xl");
$container-max-width: map-get($breakpoints, "xl");
4 changes: 2 additions & 2 deletions src/styles/isomer-template/theme/_display.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@use "sass:map";

@media screen and (min-width: map.get($breakpoints, "lg")),
screen and (max-width: (map.get($breakpoints, "md") - 1)) {
@media screen and (min-width: map-get($breakpoints, "lg")),
screen and (max-width: (map-get($breakpoints, "md") - 1)) {
.is-visible-tablet-only {
display: none !important;
}
Expand Down
4 changes: 4 additions & 0 deletions src/styles/isomer-template/theme/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
justify-content: flex-end;
}

.flex-start {
justify-content: flex-start;
}

.w-100 {
width: 100%;
}
Expand Down
104 changes: 49 additions & 55 deletions src/templates/homepage/HeroSection/HeroInfoboxDesktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import { EditorHeroDropdownSection } from "types/homepage"
import { HeroButton } from "./HeroButton"
import { HeroDropdown } from "./HeroDropdown"

const getButtonStyling = (alignment: SectionAlignment = "left") => {
return `hero-alignment-${alignment}`
}

interface HeroInfoboxDesktopProps {
alignment: SectionAlignment

Expand All @@ -31,8 +27,6 @@ interface HeroInfoboxDesktopProps {
variant: "side" | "floating"
}

const BASE_TITLE_CONTAINER_STYLES = ["mb-8", "is-flex"]

export const HeroInfoboxDesktop = ({
variant,
alignment = "left",
Expand All @@ -46,11 +40,6 @@ export const HeroInfoboxDesktop = ({
url,
button,
}: HeroInfoboxDesktopProps) => {
const SIDE_SECTION_TITLE_CONTAINER_STYLES = [
"side-section-infobox-container",
`side-section-container-${alignment}`,
]

return (
<div
className={getClassNames(editorStyles, [
Expand All @@ -70,66 +59,71 @@ export const HeroInfoboxDesktop = ({
}}
>
<div
className={getClassNames(editorStyles, [
...BASE_TITLE_CONTAINER_STYLES,
...(variant === "side" ? SIDE_SECTION_TITLE_CONTAINER_STYLES : []),
])}
className={getClassNames(
editorStyles,
variant === "side" ? ["side-section-infobox-container"] : []
)}
style={{
display: "flex",
flexDirection: "column",
alignSelf: alignment === "right" ? "flex-start" : "flex-end",
}}
>
<h1
className={getClassNames(editorStyles, [
"h1",
"mb-4",
"hero-text-color",
])}
<div
className={getClassNames(editorStyles, ["mb-8", "is-flex"])}
style={{ flexDirection: "column" }}
>
<b>{title}</b>
</h1>

{subtitle && (
<p
<h1
className={getClassNames(editorStyles, [
"is-hidden-touch",
"body-2",
"h1",
"mb-4",
"hero-text-color",
])}
>
{subtitle}
</p>
)}
</div>
<b>{title}</b>
</h1>

{dropdown?.title ? (
<div
className={getClassNames(editorStyles, ["is-flex"])}
style={{
justifyContent: "center",
alignContent: "center",
}}
>
<HeroDropdown
title={dropdown.title}
options={dropdown.options}
isActive={dropdownIsActive}
toggleDropdown={toggleDropdown}
/>
{subtitle && (
<p
className={getClassNames(editorStyles, [
"is-hidden-touch",
"body-2",
"hero-text-color",
])}
>
{subtitle}
</p>
)}
</div>
) : (
// NOTE: This is to mirror the template structure
// as closely as possible.
url &&
button && (
{dropdown?.title ? (
<div
className={getClassNames(editorStyles, [
`${variant === "side" ? getButtonStyling(alignment) : ""}`,
"is-flex",
"is-full-width",
])}
style={{
justifyContent: "center",
alignContent: "center",
}}
>
<HeroButton button={button} />
<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 && (
<div>
<HeroButton button={button} />
</div>
)
)}
</div>
</div>
</div>
)
Expand Down
4 changes: 2 additions & 2 deletions src/templates/homepage/HeroSection/HeroInfoboxMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export const HeroInfoboxMobile = ({
style={{
paddingTop: "106px",
paddingBottom: "106px",
paddingLeft: "84px",
paddingRight: "84px",
paddingLeft: "48px",
paddingRight: "48px",
}}
>
<div
Expand Down

0 comments on commit 5fcc930

Please sign in to comment.