Skip to content

Commit ad23000

Browse files
Fix a BannerPage background issue (#2651)
* do not double up on url(...) * turn off image opt locally by default
1 parent 0429047 commit ad23000

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

env/frontend.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
NODE_ENV=development
22
PORT=8062
33
SENTRY_ENV=dev # Re-enable sentry
4-
NEXT_PUBLIC_OPTIMIZE_IMAGES="true"
4+
NEXT_PUBLIC_OPTIMIZE_IMAGES="false"
55

66
# Environment variables with `NEXT_PUBLIC_` prefix are exposed to the client side
77
NEXT_PUBLIC_ORIGIN=${MITOL_APP_BASE_URL}

frontends/ol-components/src/components/Banner/Banner.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,21 @@ const SubHeader = styled(Typography)({
1111
})
1212

1313
type BannerBackgroundProps = {
14+
/**
15+
* Background image src, url(...), or image-set(...).
16+
*/
1417
backgroundUrl?: string
1518
backgroundSize?: string
1619
backgroundDim?: number
1720
}
1821

22+
const standardizeBackgroundUrl = (url: string) => {
23+
if (url.startsWith("url(") || url.startsWith("image-set(")) {
24+
return url
25+
}
26+
return url.startsWith("image-set(") ? url : `url('${url}')`
27+
}
28+
1929
/**
2030
* This is a full-width banner component that takes a background image URL.
2131
*/
@@ -26,9 +36,7 @@ const BannerBackground = styled.div<BannerBackgroundProps>(
2636
backgroundSize = "cover",
2737
backgroundDim = 0,
2838
}) => {
29-
const backgroundUrlFn = backgroundUrl.startsWith("image-set(")
30-
? backgroundUrl
31-
: `url('${backgroundUrl}')`
39+
const backgroundUrlFn = standardizeBackgroundUrl(backgroundUrl)
3240

3341
return {
3442
backgroundAttachment: "fixed",

0 commit comments

Comments
 (0)