Skip to content

Commit

Permalink
chore: refactor detection of christmas theme
Browse files Browse the repository at this point in the history
  • Loading branch information
anxolin committed Dec 17, 2024
1 parent c46858d commit 57f809b
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import { CowSwapTheme, Media } from '@cowprotocol/ui'
import * as CSS from 'csstype'
import styled from 'styled-components/macro'

function isChristmasTheme(theme?: CowSwapTheme) {
if (!theme) {
return false
}

return ['darkChristmas', 'lightChristmas'].includes(theme)
}

export const AppWrapper = styled.div<Partial<CSS.Properties>>`
display: flex;
flex-flow: column;
Expand Down Expand Up @@ -50,7 +58,7 @@ export const BodyWrapper = styled.div<{ customTheme?: CowSwapTheme }>`
if (customTheme === 'darkHalloween') {
backgroundImage = `url(${IMAGE_BACKGROUND_DARK_HALLOWEEN})`
} else if (customTheme === 'darkChristmas' || customTheme === 'lightChristmas') {
} else if (isChristmasTheme(customTheme)) {
backgroundImage = theme.darkMode
? `url(${IMAGE_BACKGROUND_DARK_CHRISTMAS})`
: `url(${IMAGE_BACKGROUND_LIGHT_CHRISTMAS})`
Expand All @@ -75,7 +83,7 @@ export const BodyWrapper = styled.div<{ customTheme?: CowSwapTheme }>`
`}
${({ customTheme, theme }) =>
(customTheme === 'darkChristmas' || customTheme === 'lightChristmas') &&
isChristmasTheme(customTheme) &&
`
background-image: url(${theme.darkMode ? IMAGE_BACKGROUND_DARK_CHRISTMAS_MEDIUM : IMAGE_BACKGROUND_LIGHT_CHRISTMAS_MEDIUM});
`}
Expand All @@ -92,7 +100,7 @@ export const BodyWrapper = styled.div<{ customTheme?: CowSwapTheme }>`
`}
${({ customTheme, theme }) =>
(customTheme === 'darkChristmas' || customTheme === 'lightChristmas') &&
isChristmasTheme(customTheme) &&
`
background-image: url(${theme.darkMode ? IMAGE_BACKGROUND_DARK_CHRISTMAS_SMALL : IMAGE_BACKGROUND_LIGHT_CHRISTMAS_SMALL});
`}
Expand Down

0 comments on commit 57f809b

Please sign in to comment.