Skip to content

Commit a66c4fe

Browse files
Fix license display when it overflows parent menu width
1 parent c1f9de8 commit a66c4fe

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

crates/bin/docs_rs_web/templates/rustdoc/topbar.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
</script>
1414
{%- if krate is defined -%}
15-
<li class="pure-menu-item pure-menu-has-children">
15+
<li class="pure-menu-item pure-menu-has-children crate-dropdown">
1616
<a href="#" class="pure-menu-link crate-name" title="{{ metadata.description.as_deref().unwrap_or_default() }}">
1717
{{ crate::icons::IconCube.render_solid(false, false, "") }}
1818
<span class="title">{{ metadata.name }}-{{ metadata.version }}</span>
@@ -43,7 +43,7 @@
4343

4444
{%- if let Some(parsed_licenses) = krate.parsed_license -%}
4545
<li class="pure-menu-item">
46-
<span class="pure-menu-link description">
46+
<span class="pure-menu-link description license">
4747
{{- crate::icons::IconScaleUnbalancedFlip.render_solid(false, false, "") }}
4848
{%+ for item in parsed_licenses -%}
4949
{%- match item -%}

crates/bin/docs_rs_web/templates/style/_navbar.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ div.nav-container {
7373
&.description {
7474
font-size: 14.4px;
7575
}
76+
77+
&.description.license {
78+
white-space: normal;
79+
}
7680
}
7781
a.pure-menu-sublink {
7882
color: var(--color-navbar-standard);

gui-tests/long-license-text.goml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Checks that the links have the expected color.
2+
3+
go-to: |DOC_PATH| + "/sysinfo"
4+
store-value: (menu_selector, '.crate-dropdown')
5+
store-value: (sub_menu_selector, |menu_selector| + ' .pure-menu-children')
6+
store-value: (license_selector, |sub_menu_selector| + ' .license')
7+
click: |menu_selector|
8+
wait-for-css: (|sub_menu_selector|, {"display": "block"})
9+
store-size: (
10+
|license_selector|,
11+
{"height": original_height, "width": original_width},
12+
)
13+
store-size: (|sub_menu_selector|, {"width": menu_width})
14+
// Menu has a border of 1px, so both sides makes it 2px total.
15+
assert: (|menu_width| - 2) == |original_width|
16+
17+
// Now we change the content of the license to make it overflow the menu's width.
18+
store-property: (|license_selector|, {"innerHTML": html})
19+
set-property: (
20+
|license_selector|,
21+
{"innerHTML": |html| + "OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 OR blablablablabla"},
22+
)
23+
// And now, the height should have increased while the width should remain the same.
24+
store-size: (
25+
|license_selector|,
26+
{"height": new_height, "width": new_width},
27+
)
28+
assert: |new_width| == |original_width| && |new_height| > |original_height|

0 commit comments

Comments
 (0)