Skip to content

Commit

Permalink
Merge pull request #442 from Gankra/do-thing
Browse files Browse the repository at this point in the history
fix: make the installer widget show up more
  • Loading branch information
ashleygwilliams committed Jun 23, 2023
2 parents 4d4111b + 0119aea commit eb2abeb
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 31 deletions.
12 changes: 8 additions & 4 deletions oranda-css/css/pages/artifacts.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}

.artifacts {
@apply flex gap-2 items-center flex-col mb-16 p-5;
@apply flex items-center flex-col mb-8 p-0;
color: var(--light-highlight-fg-color);
background-color: var(--light-highlight-bg-color);
}
Expand Down Expand Up @@ -76,6 +76,13 @@ ul.tabs li.selected {
@apply hover:no-underline;
}

.bottom-options {
@apply flex flex-row w-full justify-between;
}
.bottom-options.one {
@apply justify-center;
}

.install-code-wrapper {
@apply flex items-stretch;
}
Expand Down Expand Up @@ -103,9 +110,6 @@ ul.tabs li.selected {
@apply block mb-2;
}

.arch-select {
@apply self-end;
}

.arch {
@apply p-0 m-0 pt-4;
Expand Down
66 changes: 40 additions & 26 deletions src/site/artifacts/installers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ pub fn build_header(release: &Release, config: &Config) -> Result<Box<div<String
let downloads_href = link::generate(&config.build.path_prefix, "artifacts/");
let tag = release.source.version_tag();
let platforms_we_want = filter_platforms(release);
if platforms_we_want.is_empty() {
return Ok(html!(<div></div>));
}
let one_platform = platforms_we_want.len() == 1;

let simple_platforms = platforms_we_want.len() <= 1;

let date_html = release.source.formatted_date().map(|date| {
html!(<div><small class="published-date">{text!("Published on {}", date)}</small></div>)
Expand All @@ -39,71 +37,87 @@ pub fn build_header(release: &Release, config: &Config) -> Result<Box<div<String
</div>
);

// If there's only one platform we don't need scripts
let noscript = if one_platform {
// If there aren't multiple platform we don't need scripts
let noscript = if simple_platforms {
None
} else {
Some(
html!(<noscript><a href=&downloads_href class="backup-download primary">{text!("View all installation options")}</a></noscript>),
)
};
// If there's only one platform we don't need dropdowns
let selector = if one_platform {
let target = platforms_we_want.keys().next().unwrap();
if target == "all" {
// If we think this is a universal setup, don't mention platforms
None
let selector = if simple_platforms {
let target = platforms_we_want.keys().next();
if let Some(target) = target {
if target == "all" {
// If we think this is a universal setup, don't mention platforms
None
} else {
// Otherwise mention the platform
let os_name = triple_to_display_name(target).unwrap();
let desc = format!("Platform: {os_name}");
Some(html!(<div class="arch-select">{text!(desc)}</div>))
}
} else {
// Otherwise mention the platform
let os_name = triple_to_display_name(target).unwrap();
let desc = format!("Platform: {os_name}");
Some(html!(<div class="arch-select">{text!(desc)}</div>))
None
}
} else {
Some(html!(<div class="arch-select hidden">
{text!("Platform: ")} {selector}
</div>))
};
let no_autodetect = if one_platform {
let no_autodetect = if simple_platforms {
None
} else {
Some(html!(
<div class="no-autodetect hidden">
<span class="no-autodetect-details">{text!("We weren't able to detect your OS. ")}</span>
<a href=&downloads_href class="backup-download primary">{text!("View all installation options.")}</a>
</div>
))
};

let bottom_classes = if selector.is_none() {
"bottom-options one"
} else {
"bottom-options"
};
Ok(html!(
<div class="artifacts" data-tag=tag>
{main_html}
{no_autodetect}
{selector}
{noscript}
<div class=bottom_classes>
<a href=&downloads_href class="backup-download primary">{text!("View all installation options")}</a>
{selector}
</div>
</div>
))
}

/// Build the tab and content HTML for all arches.
fn build_arches(platforms: &Platforms, release: &Release, config: &Config) -> Vec<Box<li<String>>> {
let mut html = vec![];
let one_platform = platforms.len() == 1;
let simple_platforms = platforms.len() == 1;

for (target, installers) in platforms {
// If there's only one installer, no need for tabs
let tabs = if installers.len() == 1 {
None
} else {
let tabs = tab_list(target, release, installers, one_platform);
let tabs = tab_list(target, release, installers, simple_platforms);
Some(html!(<ul class="tabs">
{tabs}
</ul>))
};

let contents = content_list(target, installers, release, config, one_platform);
let contents = content_list(target, installers, release, config, simple_platforms);

// If there's only one entry, make it visible by default (noscript friendly)
let classes = if one_platform { "arch" } else { "arch hidden" };
let classes = if simple_platforms {
"arch"
} else {
"arch hidden"
};
html.push(html!(
<li class=classes data-arch=target>
{tabs}
Expand All @@ -122,14 +136,14 @@ fn tab_list(
target: &TargetTriple,
release: &Release,
installers: &[InstallerIdx],
one_platform: bool,
simple_platforms: bool,
) -> Vec<Box<li<String>>> {
let mut list = vec![];
let mut is_first = true;
for i in installers.iter() {
let installer = release.artifacts.installer(i.to_owned());
let string_idx = i.0.to_string();
let classes = if one_platform && is_first {
let classes = if simple_platforms && is_first {
"install-tab selected"
} else {
"install-tab"
Expand All @@ -148,7 +162,7 @@ fn content_list(
installers: &Vec<InstallerIdx>,
release: &Release,
config: &Config,
one_platform: bool,
simple_platforms: bool,
) -> Vec<Box<li<String>>> {
let mut list = vec![];
let mut is_first = true;
Expand All @@ -164,7 +178,7 @@ fn content_list(
};

// If there's only one platform, auto-show
let classes = if one_platform && is_first {
let classes = if simple_platforms && is_first {
"install-content"
} else {
"install-content hidden"
Expand Down
8 changes: 7 additions & 1 deletion src/site/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ impl Site {
}
};
// FIXME: change the config so that you can set `artifacts: false` and disable this?
if context.latest().is_some() {
let artifacts_enabled = config
.components
.artifacts
.as_ref()
.map(|a| a.has_some())
.unwrap_or(false);
if context.latest().is_some() && artifacts_enabled {
context
.latest_mut()
.unwrap()
Expand Down

0 comments on commit eb2abeb

Please sign in to comment.