aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-09-29 17:12:25 +0200
committerGitHub <noreply@github.com>2021-09-29 17:12:25 +0200
commit16552790069070c6a5435f37523173b1be6a4652 (patch)
tree74e6c50b0f8c56f7e2fb7cd166e7ad7d8de69a41
parent78f25296ad967cba3cfd5bc28a3fd4f5950f5ca0 (diff)
downloaddokka-16552790069070c6a5435f37523173b1be6a4652.tar.gz
dokka-16552790069070c6a5435f37523173b1be6a4652.tar.bz2
dokka-16552790069070c6a5435f37523173b1be6a4652.zip
Display a meaningful error when all sourcesets are filtered (#2161)
-rw-r--r--plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js25
-rw-r--r--plugins/base/src/main/resources/dokka/styles/style.css6
2 files changed, 24 insertions, 7 deletions
diff --git a/plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js b/plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js
index 64a1ce53..de5c6b15 100644
--- a/plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js
+++ b/plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js
@@ -6,6 +6,7 @@ filteringContext = {
let highlightedAnchor;
let topNavbarOffset;
let instances = [];
+let sourcesetNotification;
const samplesDarkThemeName = 'darcula'
const samplesLightThemeName = 'idea'
@@ -201,10 +202,6 @@ function initializeFiltering() {
let cached = window.localStorage.getItem('inactive-filters')
if (cached) {
let parsed = JSON.parse(cached)
- //Events are used by react to get values in 'on this page'
- const event = new CustomEvent('sourceset-filter-change', {detail: parsed});
- window.dispatchEvent(event);
-
filteringContext.activeFilters = filteringContext.restrictedDependencies
.filter(q => parsed.indexOf(q) == -1)
} else {
@@ -304,11 +301,25 @@ function refreshFiltering() {
elem.setAttribute("data-filterable-current", platformList.join(' '))
}
)
- const event = new CustomEvent('sourceset-filter-change', {detail: sourcesetList});
- window.dispatchEvent(event);
-
refreshFilterButtons()
refreshPlatformTabs()
+ refreshNoContentNotification()
+}
+
+function refreshNoContentNotification() {
+ const element = document.getElementsByClassName("main-content")[0]
+ if(filteringContext.activeFilters.length === 0){
+ element.style.display = "none";
+
+ const appended = document.createElement("div")
+ appended.className = "filtered-message"
+ appended.innerText = "All documentation is filtered, please adjust your source set filters in top-right corner of the screen"
+ sourcesetNotification = appended
+ element.parentNode.prepend(appended)
+ } else {
+ if(sourcesetNotification) sourcesetNotification.remove()
+ element.style.display = "block"
+ }
}
function refreshPlatformTabs() {
diff --git a/plugins/base/src/main/resources/dokka/styles/style.css b/plugins/base/src/main/resources/dokka/styles/style.css
index 65a76042..2e69c3ee 100644
--- a/plugins/base/src/main/resources/dokka/styles/style.css
+++ b/plugins/base/src/main/resources/dokka/styles/style.css
@@ -1071,6 +1071,12 @@ div.runnablesample {
background: var(--white-10);
}
+.filtered-message {
+ margin: 25px;
+ font-size: 20px;
+ font-weight: bolder;
+}
+
@media screen and (max-width: 1119px) {
h1.cover {
font-size: 48px;