Skip to content

Commit d0326f7

Browse files
authored
ENG-6637: replace color_mode_cond with dark: utility for images (#1475)
* replace color_mode_cond with dark: utility * add missing f
1 parent 2263aca commit d0326f7

File tree

13 files changed

+140
-94
lines changed

13 files changed

+140
-94
lines changed

pcweb/components/hosting_banner.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import reflex as rx
22

3-
from pcweb.constants import REFLEX_BUILD_URL
4-
53

64
def glow() -> rx.Component:
75
return rx.box(
8-
class_name="absolute w-[120rem] h-[23.75rem] flex-shrink-0 rounded-[120rem] left-1/2 -translate-x-1/2 z-[0] top-[-16rem]",
9-
background_image=rx.color_mode_cond(
10-
"radial-gradient(50% 50% at 50% 50%, rgba(235, 228, 255, 0.95) 0%, rgba(252, 252, 253, 0.00) 100%)",
11-
"radial-gradient(50% 50% at 50% 50%, rgba(58, 45, 118, 1) 0%, rgba(21, 22, 24, 0.00) 100%)",
12-
),
6+
class_name="absolute w-[120rem] h-[23.75rem] flex-shrink-0 rounded-[120rem] left-1/2 -translate-x-1/2 z-[0] top-[-16rem] dark:[background-image:radial-gradient(50%_50%_at_50%_50%,_rgba(58,45,118,1)_0%,_rgba(21,22,24,0.00)_100%)] [background-image:radial-gradient(50%_50%_at_50%_50%,_rgba(235,228,255,0.95)_0%,_rgba(252,252,253,0.00)_100%)]",
137
)
148

159

pcweb/components/icons/patterns.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,23 @@ def landing_patterns() -> rx.Component:
7777
def hosting_patterns() -> rx.Component:
7878
return [
7979
rx.image(
80-
src=rx.color_mode_cond(
81-
light="/hosting/light/hosting_patterns.svg",
82-
dark="/hosting/dark/hosting_patterns.svg",
80+
src="/hosting/light/hosting_patterns.svg",
81+
alt="Reflex Hosting Patterns",
82+
class_name="dark:hidden desktop-only absolute top-0 z-[-1] w-[1028px] h-[478px] pointer-events-none shrink-0 left-1/2 transform -translate-x-1/2 -translate-y-1/2"
83+
+ rx.cond(
84+
HostingBannerState.show_banner,
85+
" lg:mt-[24rem] mt-[3.5rem]",
86+
" lg:mt-[19rem] mt-[8.5rem]",
8387
),
88+
),
89+
rx.image(
90+
src="/hosting/dark/hosting_patterns.svg",
8491
alt="Reflex Hosting Patterns",
85-
class_name="desktop-only absolute top-0 z-[-1] w-[1028px] h-[478px] pointer-events-none shrink-0 left-1/2 transform -translate-x-1/2 -translate-y-1/2"
92+
class_name="dark:flex hidden desktop-only absolute top-0 z-[-1] w-[1028px] h-[478px] pointer-events-none shrink-0 left-1/2 transform -translate-x-1/2 -translate-y-1/2"
8693
+ rx.cond(
8794
HostingBannerState.show_banner,
8895
" lg:mt-[24rem] mt-[3.5rem]",
8996
" lg:mt-[19rem] mt-[8.5rem]",
9097
),
91-
)
98+
),
9299
]

pcweb/pages/customers/views/bento_cards.py

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,34 @@
44
def card(company: str, text: str, class_name: str = "") -> rx.Component:
55
return rx.link(
66
# Top-Left corner company logo
7+
# Light
78
rx.image(
8-
src=rx.color_mode_cond(
9-
light=f"/customers/light/{company}/{company}_top.svg",
10-
dark=f"/customers/dark/{company}/{company}_top.svg",
11-
),
9+
src=f"/customers/light/{company}/{company}_top.svg",
10+
alt=f"{company} logo",
11+
loading="lazy",
12+
class_name="absolute top-10 left-10 z-[2] max-h-[32px] dark:hidden",
13+
),
14+
# Dark
15+
rx.image(
16+
src=f"/customers/dark/{company}/{company}_top.svg",
1217
alt=f"{company} logo",
1318
loading="lazy",
14-
class_name="absolute top-10 left-10 z-[2] max-h-[32px]",
19+
class_name="absolute top-10 left-10 z-[2] max-h-[32px] dark:block hidden",
1520
),
1621
# Center company logo
22+
# Light
1723
rx.image(
18-
rx.color_mode_cond(
19-
light=f"/customers/light/{company}/{company}_middle.svg",
20-
dark=f"/customers/dark/{company}/{company}_middle.svg",
21-
),
24+
src=f"/customers/light/{company}/{company}_middle.svg",
2225
alt=f"{company} small logo",
2326
loading="lazy",
24-
class_name="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-[2] max-h-[88px]",
27+
class_name="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-[2] max-h-[88px] dark:hidden",
28+
),
29+
# Dark
30+
rx.image(
31+
src=f"/customers/dark/{company}/{company}_middle.svg",
32+
alt=f"{company} small logo",
33+
loading="lazy",
34+
class_name="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-[2] max-h-[88px] dark:block hidden",
2535
),
2636
# Wave pattern
2737
rx.html(
@@ -102,14 +112,19 @@ def _card(company: str, is_company: bool = True, **kwarg) -> rx.Component:
102112
# Center company logo
103113
rx.cond(
104114
is_company,
105-
rx.image(
106-
rx.color_mode_cond(
107-
light=f"/customers/light/{company}/{company}_middle.svg",
108-
dark=f"/customers/dark/{company}/{company}_middle.svg",
115+
rx.fragment(
116+
rx.image(
117+
f"/customers/light/{company}/{company}_middle.svg",
118+
alt=f"{company} small logo",
119+
loading="lazy",
120+
class_name="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-[2] max-h-[88px] dark:hidden",
121+
),
122+
rx.image(
123+
f"/customers/dark/{company}/{company}_middle.svg",
124+
alt=f"{company} small logo",
125+
loading="lazy",
126+
class_name="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-[2] max-h-[88px] dark:block hidden",
109127
),
110-
alt=f"{company} small logo",
111-
loading="lazy",
112-
class_name="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-[2] max-h-[88px]",
113128
),
114129
rx.image(
115130
**kwarg,

pcweb/pages/customers/views/customers_list.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,16 @@ def customers_list_item(
9191
return rx.link(
9292
rx.box(
9393
rx.image(
94-
src=rx.color_mode_cond(
95-
light=f"/customers/light/{company.lower()}/{company.lower()}_small.svg",
96-
dark=f"/customers/dark/{company.lower()}/{company.lower()}_small.svg",
97-
),
94+
src=f"/customers/light/{company.lower()}/{company.lower()}_small.svg",
95+
alt=f"{company} logo",
96+
loading="lazy",
97+
class_name="dark:hidden h-5 w-auto shrink-0",
98+
),
99+
rx.image(
100+
src=f"/customers/dark/{company.lower()}/{company.lower()}_small.svg",
98101
alt=f"{company} logo",
99102
loading="lazy",
100-
class_name="h-5 w-auto shrink-0",
103+
class_name="dark:block hidden h-5 w-auto shrink-0",
101104
),
102105
rx.text(company, class_name="font-base font-semibold text-slate-12"),
103106
class_name="flex flex-row items-center gap-2.5 flex-1 justify-start",

pcweb/pages/framework/views/companies.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,19 @@
33

44
def logo(path: str, height: str) -> rx.Component:
55
return rx.fragment(
6-
rx.color_mode_cond(
7-
rx.image(
8-
src=f"/companies/light/{path}.svg",
9-
alt=f"{path} logo",
10-
loading="lazy",
11-
height=height,
12-
class_name="shrink-0",
13-
),
14-
rx.image(
15-
src=f"/companies/dark/{path}.svg",
16-
alt=f"{path} logo",
17-
height=height,
18-
loading="lazy",
19-
class_name="shrink-0",
20-
),
6+
rx.image(
7+
src=f"/companies/light/{path}.svg",
8+
alt=f"{path} logo",
9+
loading="lazy",
10+
height=height,
11+
class_name="shrink-0 dark:hidden",
12+
),
13+
rx.image(
14+
src=f"/companies/dark/{path}.svg",
15+
alt=f"{path} logo",
16+
height=height,
17+
loading="lazy",
18+
class_name="shrink-0 dark:block hidden",
2119
),
2220
)
2321

pcweb/pages/framework/views/frontend_features.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@ def frontend_card(
1818
class_name="flex flex-col gap-2 px-10 pt-10",
1919
),
2020
rx.image(
21-
src=rx.color_mode_cond(
22-
light=f"/landing/frontend_features/light/{image}",
23-
dark=f"/landing/frontend_features/dark/{image}",
24-
),
25-
class_name="w-full absolute shrink-0" + " " + image_cn,
21+
src=f"/landing/frontend_features/light/{image}",
22+
class_name="dark:hidden w-full absolute shrink-0" + " " + image_cn,
23+
top=top,
24+
height=height,
25+
loading="lazy",
26+
alt=title + " image",
27+
),
28+
rx.image(
29+
src=f"/landing/frontend_features/dark/{image}",
30+
class_name="dark:block hidden w-full absolute shrink-0" + " " + image_cn,
2631
top=top,
2732
height=height,
2833
loading="lazy",

pcweb/pages/framework/views/hosting_features.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@ def graphic_card() -> rx.Component:
2121
class_name="pointer-events-none w-auto h-auto -rotate-90 shrink-0 absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-[1]",
2222
),
2323
rx.image(
24-
src=rx.color_mode_cond(
25-
light="/landing/hosting_features/light/deploy.svg",
26-
dark="/landing/hosting_features/dark/deploy.svg",
27-
),
24+
src="/landing/hosting_features/light/deploy.svg",
25+
alt="Hosting graphic",
26+
loading="lazy",
27+
class_name="w-[7.875rem] h-[8.5rem] shrink-0 z-[2] dark:hidden",
28+
),
29+
rx.image(
30+
src="/landing/hosting_features/dark/deploy.svg",
2831
alt="Hosting graphic",
2932
loading="lazy",
30-
class_name="w-[7.875rem] h-[8.5rem] shrink-0 z-[2]",
33+
class_name="w-[7.875rem] h-[8.5rem] shrink-0 z-[2] dark:block hidden",
3134
),
3235
class_name="flex justify-center items-center relative pointer-events-none h-full w-full lg:my-0 my-10",
3336
)

pcweb/pages/hosting/views/preview.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@ def preview() -> rx.Component:
2626
return rx.box(
2727
pattern_1(),
2828
rx.image(
29-
src=rx.color_mode_cond(
30-
light="/hosting/light/hosting-preview.jpg",
31-
dark="/hosting/dark/hosting-preview.jpg",
32-
),
29+
src="/hosting/light/hosting-preview.jpg",
3330
alt="Reflex Hosting Preview",
34-
class_name="w-full h-full rounded-lg lg:rounded-2xl object-cover bg-center border border-slate-3",
31+
class_name="dark:hidden w-full h-full rounded-lg lg:rounded-2xl object-cover bg-center border border-slate-3",
32+
loading="lazy",
33+
),
34+
rx.image(
35+
src="/hosting/dark/hosting-preview.jpg",
36+
alt="Reflex Hosting Preview",
37+
class_name="dark:block hidden w-full h-full rounded-lg lg:rounded-2xl object-cover bg-center border border-slate-3",
3538
loading="lazy",
3639
),
3740
class_name="w-full h-full max-w-[71rem] max-h-[41rem] rounded-[2rem] backdrop-blur-[6px] bg-[rgba(26, 27, 29, 0.48)] lg:p-4 lg:border border-slate-3 relative lg:mt-0 mt-[3.5rem]",

pcweb/pages/landing/views/companies.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def quote_badge() -> rx.Component:
138138

139139

140140
@rx.memo
141-
def company_card(image: str, name: str, id: str) -> rx.Component:
141+
def company_card(name: str, id: str) -> rx.Component:
142142
area_x_pos = ClientStateVar.create(
143143
var_name="area_x_pos", default=0, global_ref=False
144144
)
@@ -163,9 +163,18 @@ def company_card(image: str, name: str, id: str) -> rx.Component:
163163
class_name="flex flex-col gap-2.5 w-full h-[10.75rem] justify-between bg-slate-1 border-box p-4 overflow-hidden",
164164
),
165165
rx.box(
166+
# Light
166167
rx.image(
167-
src=image,
168-
class_name="w-[4.75rem] h-auto pointer-events-none group-hover:grayscale-0 grayscale-[1] opacity-50 group-hover:opacity-100 transition-all",
168+
src=f"/landing/companies/light/{name}.svg",
169+
class_name="w-[4.75rem] h-auto pointer-events-none group-hover:grayscale-0 grayscale-[1] opacity-50 group-hover:opacity-100 transition-all dark:hidden",
170+
loading="lazy",
171+
alt=f"{name} logo",
172+
),
173+
# Dark
174+
rx.image(
175+
src=f"/landing/companies/dark/{name}.svg",
176+
class_name="w-[4.75rem] h-auto pointer-events-none group-hover:grayscale-0 grayscale-[1] opacity-50 group-hover:opacity-100 transition-all dark:block hidden",
177+
loading="lazy",
169178
alt=f"{name} logo",
170179
),
171180
class_name=(
@@ -240,7 +249,6 @@ def companies() -> rx.Component:
240249
rx.box(
241250
*[
242251
company_card(
243-
image=f"/landing/companies/{rx.color_mode_cond(light='light', dark='dark')}/{company}.svg",
244252
name=company,
245253
id=f"landing-company-card-{company}",
246254
)

pcweb/pages/landing/views/hosting_section.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ def content() -> rx.Component:
7777
),
7878
rx.box(
7979
rx.image(
80-
src=f"/landing/hosting_features/{rx.color_mode_cond(light='light', dark='dark')}/card.webp",
81-
class_name="absolute top-0 left-0 w-full h-full object-cover pointer-events-none",
80+
src=f"/landing/hosting_features/light/card.webp",
81+
class_name="absolute top-0 left-0 w-full h-full object-cover pointer-events-none dark:hidden",
82+
),
83+
rx.image(
84+
src=f"/landing/hosting_features/dark/card.webp",
85+
class_name="absolute top-0 left-0 w-full h-full object-cover pointer-events-none dark:block hidden",
8286
),
8387
class_name="justify-center items-center relative overflow-hidden w-full lg:flex hidden",
8488
),

0 commit comments

Comments
 (0)