Skip to content

Commit 66129df

Browse files
alisinabhpdavies
andcommitted
Add warning for stale version of documentation
Co-Authored-By: Philip Davies <[email protected]>
1 parent 22103e7 commit 66129df

File tree

6 files changed

+28
-4
lines changed

6 files changed

+28
-4
lines changed

assets/css/custom-props/common.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
--black: hsl(0, 0%, 0%);
5353
--black-opacity-10: hsla(0, 0%, 0%, 10%);
5454
--black-opacity-50: hsla(0, 0%, 0%, 50%);
55+
--orangeDark: hsl(30, 80%, 50%);
56+
--orange: hsl(30, 100%, 50%);
5557
}
5658

5759
@media screen and (max-width: 768px) {

assets/css/custom-props/theme-dark.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ body.dark {
8080
--sidebarHover: var(--white);
8181
--sidebarScrollbarThumb: var(--coldGray);
8282
--sidebarScrollbarTrack: var(--sidebarBackground);
83+
--sidebarStaleVersion: var(--orangeDark);
8384
--sidebarSubheadings: var(--gray400);
8485
--sidebarItem: var(--gray200);
8586
--sidebarInactiveItemBorder: var(--gray400);

assets/css/custom-props/theme-light.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
--sidebarHover: var(--black);
8181
--sidebarScrollbarThumb: var(--coldGrayLight);
8282
--sidebarScrollbarTrack: var(--sidebarBackground);
83+
--sidebarStaleVersion: var(--orange);
8384
--sidebarSubheadings: var(--black);
8485
--sidebarItem: var(--black);
8586
--sidebarInactiveItemBorder: var(--gray500);

assets/css/sidebar.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,19 @@
109109
display: none;
110110
}
111111

112+
.sidebar .sidebar-staleVersion {
113+
color: var(--sidebarStaleVersion);
114+
padding-left: 28px;
115+
}
116+
117+
.sidebar .sidebar-staleIcon {
118+
color: var(--sidebarStaleVersion);
119+
position: absolute;
120+
top: 0.5px;
121+
left: 10px;
122+
font-size: 16px;
123+
}
124+
112125
.sidebar .sidebar-list-nav {
113126
display: flex;
114127
margin: 0;

assets/js/handlebars/templates/versions-dropdown.handlebars

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
<label>
33
<span class="sidebar-projectVersionsDropdownCaret" aria-hidden="true">&#x25bc;</span>
44
<span class="sr-only">Project version</span>
5-
<select class="sidebar-projectVersionsDropdown">
5+
{{#if latestVersion}}
6+
<i class="ri-alert-line sidebar-staleIcon" aria-hidden="true"></i>
7+
{{/if}}
8+
<select class="sidebar-projectVersionsDropdown{{#if latestVersion}} sidebar-staleVersion{{/if}}"{{#if latestVersion}} title="This version is not the latest version of the package."{{/if}}>
69
{{#each nodes}}
710
<option translate="no" value="{{url}}"{{#if isCurrentVersion}} selected disabled{{/if}}>
811
{{version}}

assets/js/sidebar/sidebar-version-select.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ export function initialize () {
1515
const versionsContainer = qs(VERSIONS_CONTAINER_SELECTOR)
1616
// Initially the container contains only text with the current version
1717
const currentVersion = versionsContainer.textContent.trim()
18+
19+
const latestVersionNode = versionNodes.find(node => node.latest)
20+
const latestVersion = latestVersionNode?.version !== currentVersion ? latestVersionNode?.version : null
21+
1822
const nodes = decorateVersionNodes(versionNodes, currentVersion)
1923

20-
renderVersionsDropdown({ nodes })
24+
renderVersionsDropdown({ nodes, latestVersion })
2125
}
2226
}
2327

24-
function renderVersionsDropdown ({ nodes }) {
28+
function renderVersionsDropdown ({ nodes, latestVersion }) {
2529
const versionsContainer = qs(VERSIONS_CONTAINER_SELECTOR)
26-
const versionsDropdownHtml = versionsDropdownTemplate({ nodes })
30+
const versionsDropdownHtml = versionsDropdownTemplate({ nodes, latestVersion })
2731
versionsContainer.innerHTML = versionsDropdownHtml
2832

2933
qs(VERSIONS_DROPDOWN_SELECTOR).addEventListener('change', handleVersionSelected)

0 commit comments

Comments
 (0)