Skip to content

Commit

Permalink
fix: Styling
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Jan 15, 2025
1 parent 3d97138 commit c06a1d5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 32 deletions.
3 changes: 1 addition & 2 deletions src/components/Banner/Banner.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ const LoadingContainer = styled(Box)({
})

const BannerContainer = styled(Box, {
shouldForwardProp: (prop) =>
prop !== "background"
shouldForwardProp: (prop) => prop !== "background",
})<{
background: string
}>((props) => {
Expand Down
52 changes: 26 additions & 26 deletions src/components/Banner/Banner.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { documentToReactComponents } from "@contentful/rich-text-react-renderer"
import CircularProgress from "@mui/material/CircularProgress"
import type { Property } from "csstype"
import { Locales, getAssetUrl } from "../../hooks/contentful"
import { useTabletAndBelowMediaQuery } from "../Media"
import { BannerProps, LowercasedAlignment } from "./Banner.types"
import {
BannerContainer,
Expand All @@ -13,7 +13,7 @@ import {
Text,
Title,
} from "./Banner.styled"
import { useTabletAndBelowMediaQuery } from "../Media"
import type { Property } from "csstype"

const convertAlignmentToFlex = (alignment: Property.TextAlign) => {
switch (alignment) {
Expand Down Expand Up @@ -49,48 +49,48 @@ export const Banner: React.FC<BannerProps> = (props: BannerProps) => {
const bannerBackgroundImage = getAssetUrl(
assets,
Locales.enUS,
isMobileOrTablet ? fields.mobileBackground[Locales.enUS] : fields.fullSizeBackground[Locales.enUS]
isMobileOrTablet
? fields.mobileBackground[Locales.enUS]
: fields.fullSizeBackground[Locales.enUS]
)
const title = isMobileOrTablet
? fields.mobileTitle[locale]
: fields.desktopTitle[locale]
const titleAlignment = (isMobileOrTablet
? fields.mobileTitleAlignment[Locales.enUS]
: fields.desktopTitleAlignment[Locales.enUS])?.toLowerCase() as LowercasedAlignment
const titleAlignment = (
isMobileOrTablet
? fields.mobileTitleAlignment[Locales.enUS]
: fields.desktopTitleAlignment[Locales.enUS]
)?.toLowerCase() as LowercasedAlignment
const text = isMobileOrTablet
? fields.mobileText[locale]
: fields.desktopText[locale]
const textAlignment = (isMobileOrTablet
? fields.mobileTextAlignment[Locales.enUS]
: fields.desktopTextAlignment[Locales.enUS])?.toLowerCase() as LowercasedAlignment
const buttonAlignment = convertAlignmentToFlex((isMobileOrTablet
? fields.mobileButtonAlignment[Locales.enUS]
: fields.desktopButtonAlignment[Locales.enUS])?.toLowerCase() as LowercasedAlignment)
const textAlignment = (
isMobileOrTablet
? fields.mobileTextAlignment[Locales.enUS]
: fields.desktopTextAlignment[Locales.enUS]
)?.toLowerCase() as LowercasedAlignment
const buttonAlignment = convertAlignmentToFlex(
(isMobileOrTablet
? fields.mobileButtonAlignment[Locales.enUS]
: fields.desktopButtonAlignment[Locales.enUS]
)?.toLowerCase() as LowercasedAlignment
)

return (
<BannerContainer
background={bannerBackgroundImage}
>
<BannerContainer background={bannerBackgroundImage}>
<Content>
<Title
variant="h1"
textAlign={titleAlignment}
>
{title}
<Title variant="h1" textAlign={titleAlignment}>
{title}
</Title>

<Text
textAlign={textAlignment}
>
<Text textAlign={textAlignment}>
{text ? documentToReactComponents(text) : null}
</Text>

{fields.showButton[Locales.enUS] &&
fields.buttonLink?.[Locales.enUS] &&
fields.buttonsText?.[locale] ? (
<ButtonContainer
justifyContent={buttonAlignment}
>
<ButtonContainer justifyContent={buttonAlignment}>
<Button
href={fields.buttonLink[Locales.enUS]}
variant="contained"
Expand Down
2 changes: 1 addition & 1 deletion src/components/MarketingBanner/MarketingBanner.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react"
import { MarketingBanner } from "./MarketingBanner"
import { Locales } from "../../hooks/contentful"
import type { Meta, StoryObj } from "@storybook/react"

const meta = {
title: "Decentraland UI/MarketingBanner",
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/contentful/contentful.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ enum ContentfulLocale {
}

type LocalizedField<T> = {
[ContentfulLocale.enUS]: T;
[ContentfulLocale.es]?: T;
[ContentfulLocale.zh]?: T;
[ContentfulLocale.enUS]: T
[ContentfulLocale.es]?: T
[ContentfulLocale.zh]?: T
}

type SysAssetLink = {
Expand Down

0 comments on commit c06a1d5

Please sign in to comment.