Skip to content

Commit 1444dc8

Browse files
authored
Merge pull request #67 from felipebalbi/tier3-refactor
Tier 3 readability + responsiveness refactor
2 parents 33f7217 + 9cfc44c commit 1444dc8

14 files changed

Lines changed: 161 additions & 155 deletions

src/components/community_teams.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ pub fn CommunityTeams() -> impl IntoView {
3636
let steering_committee = create_steering_committee();
3737

3838
view! {
39-
<section class="background_primary px-4 py-6 md:px-32">
39+
<section class="background_primary px-4 py-6 md:px-16 lg:px-32">
4040
<div class="flex flex-col md:flex-row gap-16 mb-20">
41-
<div class="w-full md:w-[950px]">
41+
<div class="flex flex-col items-start w-full md:flex-1">
4242
<span class="h1 break-words w-full block text-left">
4343
{"How ODP is built by its community"}
4444
</span>
4545
</div>
46-
<div class="flex flex-col justify-start w-full md:max-w-[900px]" style="flex: 1;">
46+
<div class="flex flex-col justify-start w-full md:flex-1">
4747
<span class="p2 break-words w-full block text-left">
4848

4949
{"The Open Device Partnership (ODP) is a collaborative open-source initiative designed to promote cooperative innovation in firmware development through contribution and transparency."}

src/components/documentation_training.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub const DEFAULT_DOC_LINKS: &[DocLink] = &[
4444
#[component]
4545
pub fn DocumentationTraining(#[prop(default = DEFAULT_DOC_LINKS.to_vec())] links: Vec<DocLink>) -> impl IntoView {
4646
view! {
47-
<section class="flex flex-col md:flex-row items-start background_primary w-full overflow-x-hidden px-4 py-8 md:py-16 md:px-32">
47+
<section class="flex flex-col md:flex-row items-start background_primary w-full overflow-x-hidden px-4 py-8 md:py-16 md:px-16 lg:px-32">
4848
<div class="flex flex-col items-start w-full" style="align-items: flex-start;">
4949
<ThemedIcon
5050
name="documentation"

src/components/header.rs

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,47 @@
11
use crate::components::themed_icon::ThemedIcon;
2+
use leptos::ev;
23
use leptos::prelude::RwSignal;
34
use leptos::prelude::*;
45
use leptos_router::components::A;
56

67
#[component]
78
pub fn Header(#[prop(optional, default = "header_background")] background_class: &'static str) -> impl IntoView {
89
let menu_open = RwSignal::new(false);
10+
let close_menu = move || menu_open.set(false);
11+
12+
// ESC closes the mobile menu when it is open.
13+
window_event_listener(ev::keydown, move |e| {
14+
if e.key() == "Escape" && menu_open.get_untracked() {
15+
menu_open.set(false);
16+
}
17+
});
18+
919
view! {
1020
<header class=format!(
11-
"w-full h-[80px] md:h-[160px] px-2 md:px-32 {} flex items-center justify-between z-50 m-0 p-0 relative",
21+
"w-full h-[80px] lg:h-[160px] px-4 sm:px-8 md:px-16 {} flex items-center justify-between z-50 m-0 p-0 relative",
1222
background_class,
1323
)>
14-
<div class="flex items-center space-x-6">
24+
<div class="flex items-center space-x-6 flex-shrink-0">
1525
<ThemedIcon
1626
name="odplogo"
1727
alt="ODP Logo"
18-
class="w-[100px] h-[34.5px] md:w-[149px] md:h-[51.43px] object-contain"
28+
class="w-[120px] h-[41px] sm:w-[140px] sm:h-[48px] lg:w-[180px] lg:h-[62px] object-contain"
1929
/>
2030
</div>
2131

2232
<button
23-
class="md:hidden flex flex-col justify-center items-center w-10 h-10 p-2 focus:outline-none"
24-
aria-label="Open menu"
33+
class="lg:hidden flex flex-col justify-center items-center w-10 h-10 p-2 focus:outline-none"
34+
aria-label=move || if menu_open.get() { "Close menu" } else { "Open menu" }
35+
aria-expanded=move || if menu_open.get() { "true" } else { "false" }
36+
aria-controls="primary-mobile-nav"
2537
on:click=move |_| menu_open.update(|v| *v = !*v)
2638
>
2739
<span class="block w-6 h-0.5 bg-black dark:bg-white mb-1"></span>
2840
<span class="block w-6 h-0.5 bg-black dark:bg-white mb-1"></span>
2941
<span class="block w-6 h-0.5 bg-black dark:bg-white"></span>
3042
</button>
3143

32-
<nav class="hidden md:flex [column-gap:25px]">
44+
<nav class="hidden lg:flex [column-gap:25px]" aria-label="Primary">
3345
<NavButton href="/getting-started" label="Getting Started" />
3446
<NavButton href="/projects" label="Projects" />
3547
<ExternalNavButton
@@ -40,26 +52,47 @@ pub fn Header(#[prop(optional, default = "header_background")] background_class:
4052
<NavButton href="/home" label="Home" />
4153
</nav>
4254

55+
// Backdrop: catches clicks outside the open mobile menu and dismisses it.
56+
<div
57+
class="fixed inset-0 z-40 lg:hidden"
58+
style=move || { if menu_open.get() { "display: block;" } else { "display: none;" } }
59+
on:click=move |_| close_menu()
60+
aria-hidden="true"
61+
></div>
62+
4363
<nav
44-
class="absolute right-0 top-full w-[80vw] max-w-xs background_primary flex-col items-end px-4 py-4 space-y-2 shadow-lg md:hidden transition-all duration-200"
64+
id="primary-mobile-nav"
65+
aria-label="Primary"
66+
class="absolute right-0 top-full w-[80vw] max-w-xs background_primary flex-col items-end px-4 py-4 space-y-2 shadow-lg lg:hidden transition-all duration-200 z-50"
4567
style=move || if menu_open.get() { "display: flex;" } else { "display: none;" }
4668
>
47-
<NavButton href="/getting-started" label="Getting Started" mobile=true />
48-
<NavButton href="/projects" label="Projects" mobile=true />
69+
<NavButton
70+
href="/getting-started"
71+
label="Getting Started"
72+
mobile=true
73+
on_navigate=close_menu
74+
/>
75+
<NavButton href="/projects" label="Projects" mobile=true on_navigate=close_menu />
4976
<ExternalNavButton
5077
href="https://opendevicepartnership.github.io/documentation/"
5178
label="Library"
5279
mobile=true
80+
on_navigate=close_menu
5381
/>
54-
<NavButton href="/community" label="Community" mobile=true />
55-
<NavButton href="/home" label="Home" mobile=true />
82+
<NavButton href="/community" label="Community" mobile=true on_navigate=close_menu />
83+
<NavButton href="/home" label="Home" mobile=true on_navigate=close_menu />
5684
</nav>
5785
</header>
5886
}
5987
}
6088

6189
#[component]
62-
fn NavButton(href: &'static str, label: &'static str, #[prop(optional)] mobile: bool) -> impl IntoView {
90+
fn NavButton(
91+
href: &'static str,
92+
label: &'static str,
93+
#[prop(optional)] mobile: bool,
94+
#[prop(optional, into)] on_navigate: Option<Callback<()>>,
95+
) -> impl IntoView {
6396
let location = leptos_router::hooks::use_location();
6497
let is_active = move || location.pathname.get().starts_with(href);
6598

@@ -71,14 +104,25 @@ fn NavButton(href: &'static str, label: &'static str, #[prop(optional)] mobile:
71104
class:odp-header-btn-active=is_active
72105
class:odp-header-btn-active-text=is_active
73106
class:w-full=mobile
107+
attr:aria-current=move || if is_active() { Some("page") } else { None }
108+
on:click=move |_| {
109+
if let Some(cb) = on_navigate {
110+
cb.run(());
111+
}
112+
}
74113
>
75114
{label}
76115
</A>
77116
}
78117
}
79118

80119
#[component]
81-
fn ExternalNavButton(href: &'static str, label: &'static str, #[prop(optional)] mobile: bool) -> impl IntoView {
120+
fn ExternalNavButton(
121+
href: &'static str,
122+
label: &'static str,
123+
#[prop(optional)] mobile: bool,
124+
#[prop(optional, into)] on_navigate: Option<Callback<()>>,
125+
) -> impl IntoView {
82126
view! {
83127
<a
84128
href=href
@@ -87,6 +131,12 @@ fn ExternalNavButton(href: &'static str, label: &'static str, #[prop(optional)]
87131
if mobile { " w-full" } else { "" },
88132
)
89133
target="_blank"
134+
rel="noopener noreferrer"
135+
on:click=move |_| {
136+
if let Some(cb) = on_navigate {
137+
cb.run(());
138+
}
139+
}
90140
>
91141
{label}
92142
</a>

src/components/image_button.rs

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,23 @@
11
use leptos::prelude::*;
22

3+
/// Rounded image rendered as a link.
4+
///
5+
/// Sizing is purely declarative via Tailwind utilities passed in `class`.
6+
/// The default `aspect-square max-w-[350px]` matches the landing-page
7+
/// tiles; call sites override the cap when the surrounding layout calls
8+
/// for a larger image. There is no per-instance `<style>` injection --
9+
/// the image scales fluidly with the viewport up to the cap and the
10+
/// aspect-ratio utility keeps the rendered shape square.
311
#[component]
412
pub fn ImageButton(
513
#[prop(into)] href: String,
614
#[prop(into)] img_src: String,
715
#[prop(into, default = String::from("Button Image"))] alt: String,
8-
#[prop(default = 350)] width: u32,
9-
#[prop(default = 320)] height: u32,
10-
#[prop(default = None)] mobile_width: Option<u32>,
11-
#[prop(default = None)] mobile_height: Option<u32>,
16+
#[prop(into, default = String::from("aspect-square max-w-[350px]"))] class: String,
1217
) -> impl IntoView {
1318
view! {
14-
<a
15-
href=href
16-
style="
17-
display: inline-block;
18-
border: none;
19-
background: none;
20-
padding: 0;
21-
cursor: pointer;
22-
text-decoration: none;
23-
"
24-
>
25-
<style>
26-
{if let (Some(mw), Some(mh)) = (mobile_width, mobile_height) {
27-
format!(
28-
"@media (max-width: 767px) {{ img[alt='{}'] {{ width: {}px !important; height: {}px !important; }} }}",
29-
alt,
30-
mw,
31-
mh,
32-
)
33-
} else {
34-
String::new()
35-
}}
36-
</style>
37-
<img
38-
src=img_src
39-
alt=alt
40-
style=format!(
41-
"
42-
width: {}px;
43-
height: {}px;
44-
border-radius: 45.7px;
45-
object-fit: cover;
46-
display: block;
47-
",
48-
width,
49-
height,
50-
)
51-
/>
19+
<a href=href class=format!("inline-block w-full overflow-hidden rounded-3xl {}", class)>
20+
<img src=img_src alt=alt class="w-full h-full object-cover block" />
5221
</a>
5322
}
54-
}
23+
}

src/components/landing_page.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ use leptos::prelude::*;
55
#[component]
66
pub fn LandingPage() -> impl IntoView {
77
view! {
8-
<div class="background_primary px-2 md:px-32" style="width: auto; height: auto;">
8+
<div
9+
class="background_primary px-4 sm:px-8 md:px-16 lg:px-32"
10+
style="width: auto; height: auto;"
11+
>
912
<div class="flex flex-col md:flex-row gap-20 items-start">
10-
<div class="flex flex-col items-start flex-shrink-0 w-full md:w-[800px]">
13+
<div class="flex flex-col items-start min-w-0 w-full md:flex-1">
1114
<span class="h1 break-words w-full block text-left">
1215
{"An Open Collaboration for Secure, Modern Devices"}
1316
</span>
1417
</div>
15-
<div class="flex flex-col items-start flex-shrink min-w-0 w-full md:w-[650px]">
18+
<div class="flex flex-col items-start min-w-0 w-full md:flex-1">
1619
<span class="p1 break-words w-full block text-left">
1720
{"The Open Device Partnership (ODP) is a global initiative to make it easier for developers and device makers to build secure, efficient, and reliable client devices for cross-platform needs and certified environments."}
1821
<br /><br />
@@ -21,11 +24,11 @@ pub fn LandingPage() -> impl IntoView {
2124
</div>
2225
</div>
2326
</div>
24-
<section class="background_secondary px-2 md:px-32 py-20">
27+
<section class="background_secondary px-4 sm:px-8 md:px-16 lg:px-32 py-20">
2528
<div>
2629
<h2 class="h2 text-left">{"Value Proposition"}</h2>
2730
<div class="flex flex-col md:flex-row gap-16">
28-
<div class="flex flex-col items-start w-full md:w-[400px]">
31+
<div class="flex flex-col items-start w-full md:flex-1">
2932
<ThemedIcon name="lock" alt="Security Icon" class="icon" />
3033
<span class="h3 break-words w-full block text-left">
3134
{"Enhanced Security"}
@@ -34,7 +37,7 @@ pub fn LandingPage() -> impl IntoView {
3437
{"Security threats continue to evolve. ODP takes a proactive approach: reducing attack surfaces, using secure hardware features, leveraging the memory-safe Rust language, and designing every component with security-first principles."}
3538
</span>
3639
</div>
37-
<div class="flex flex-col items-start w-full md:w-[400px]">
40+
<div class="flex flex-col items-start w-full md:flex-1">
3841
<ThemedIcon name="checkcircle" alt="Interoperability Icon" class="icon" />
3942
<span class="h3 break-words w-full block text-left">
4043
{"Standardization"}
@@ -43,7 +46,7 @@ pub fn LandingPage() -> impl IntoView {
4346
{"Many device firmware components are 'invisible plumbing' - necessary but costly to build and maintain. ODP's standards-based approach simplifies this infrastructure, maximizing reuse across devices, architectures (x86 and ARM), and generations."}
4447
</span>
4548
</div>
46-
<div class="flex flex-col items-start w-full md:w-[400px]">
49+
<div class="flex flex-col items-start w-full md:flex-1">
4750
<ThemedIcon name="fastforward" alt="Innovation Icon" class="icon" />
4851
<span class="h3 break-words w-full block text-left">
4952
{"Accelerated Development"}
@@ -57,7 +60,7 @@ pub fn LandingPage() -> impl IntoView {
5760
</section>
5861

5962
// ODP Projects Section
60-
<section class="background_primary px-2 md:px-32 py-32">
63+
<section class="background_primary px-4 sm:px-8 md:px-16 lg:px-32 py-32">
6164
<div style="max-width: 960px;">
6265
<h2 class="h2 text-left">{"ODP Projects"}</h2>
6366
<p class="p2" style="text-align: left; max-width: 100%;">
@@ -69,7 +72,7 @@ pub fn LandingPage() -> impl IntoView {
6972
</section>
7073

7174
// Boot Firmware Buttons Section
72-
<section class="background_primary px-2 md:px-32 pb-32">
75+
<section class="background_primary px-4 sm:px-8 md:px-16 lg:px-32 pb-32">
7376
<div class="flex flex-col md:flex-row gap-16 justify-start">
7477
<ImageButton
7578
href="/boot-firmware"
@@ -90,7 +93,7 @@ pub fn LandingPage() -> impl IntoView {
9093
</section>
9194

9295
// Two Columns Section
93-
<section class="background_primary px-2 md:px-32 py-20">
96+
<section class="background_primary px-4 sm:px-8 md:px-16 lg:px-32 py-20">
9497
<div class="flex flex-col md:flex-row gap-16">
9598
<div class="flex flex-col items-start" style="flex: 1;">
9699
<span class="h3 block text-left">{"Partner-Oriented Vision"}</span>

src/components/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use leptos_router::components::A;
66
pub fn Main() -> impl IntoView {
77
view! {
88
<main class="background_primary">
9-
<div class="mx-auto flex flex-col md:flex-row items-start justify-between w-full px-2 sm:px-4">
10-
<div class="pl-0 md:pl-32 flex flex-col gap-6 w-full md:w-auto">
9+
<div class="mx-auto flex flex-col lg:flex-row items-start justify-between w-full px-2 sm:px-4">
10+
<div class="pl-0 lg:pl-32 flex flex-col gap-6 w-full lg:w-auto">
1111
<h1 class="h1 py-4 w-full max-w-full text-left break-words">
1212
"Building the Future of Trusted System Software Together"
1313
</h1>
@@ -16,10 +16,10 @@ pub fn Main() -> impl IntoView {
1616
</p>
1717
</div>
1818

19-
<div class="flex flex-col w-full md:w-auto mt-4 md:mt-0">
19+
<div class="flex flex-col w-full lg:w-auto mt-4 lg:mt-0">
2020
<div
2121
style="border: none; text-decoration: none;"
22-
class="flex background_secondary w-full md:w-[478px] h-[120px] md:h-[176px] items-center justify-center px-4 md:px-16"
22+
class="flex background_secondary w-full lg:w-[478px] h-[120px] lg:h-[176px] items-center justify-center px-4 lg:px-16"
2323
>
2424
<A href="/getting-started">
2525
<div class="flex flex-row items-center justify-center gap-4 w-full max-w-full">
@@ -31,7 +31,7 @@ pub fn Main() -> impl IntoView {
3131

3232
<div
3333
style="border: none; text-decoration: none;"
34-
class="flex background_tertiary w-full md:w-[478px] h-[120px] md:h-[176px] items-center justify-center px-4 md:px-16"
34+
class="flex background_tertiary w-full lg:w-[478px] h-[120px] lg:h-[176px] items-center justify-center px-4 lg:px-16"
3535
>
3636
<A href="/projects">
3737
<div class="flex flex-row items-center justify-center gap-4 w-full max-w-full">
@@ -45,7 +45,7 @@ pub fn Main() -> impl IntoView {
4545

4646
<div class="flex flex-col pt-10 px-2 sm:px-4 md:pl-[117px] w-full">
4747
<div class="flex flex-col lg:flex-row items-start w-full gap-4">
48-
<div class="flex flex-col items-start w-full lg:w-[423px] mr-0 lg:mr-16 mb-6 lg:mb-0">
48+
<div class="flex flex-col items-start w-full lg:flex-1 mr-0 lg:mr-16 mb-6 lg:mb-0">
4949
<ThemedIcon
5050
name="video"
5151
alt="Video Icon"
@@ -67,7 +67,7 @@ pub fn Main() -> impl IntoView {
6767
</span>
6868
</div>
6969
<div
70-
class="w-full lg:w-[1200px] aspect-video rounded-lg overflow-hidden"
70+
class="w-full lg:flex-[2] aspect-video rounded-lg overflow-hidden"
7171
style="max-width:100vw;"
7272
>
7373
<iframe

src/components/partners_grid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const PARTNERS: &[PartnerInfo] = &[
3434
#[component]
3535
pub fn PartnersGrid() -> impl IntoView {
3636
view! {
37-
<section class="background_primary px-4 md:px-32 py-20">
37+
<section class="background_primary px-4 sm:px-8 md:px-16 lg:px-32 py-20">
3838
<div class="mb-16">
3939
<span class="h1 break-words w-full block text-left">{"Our Partners"}</span>
4040
</div>

0 commit comments

Comments
 (0)