From 53f895ba5e29a9115395c200eeffe0eb96643d6e Mon Sep 17 00:00:00 2001 From: Jason Robbins Date: Mon, 9 Nov 2020 16:17:14 -0500 Subject: [PATCH] Addressed review comments --- static/elements/chromedash-accordion.js | 7 ++++++- static/js-src/feature-page.js | 10 ++++++++++ templates/feature.html | 6 ++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/static/elements/chromedash-accordion.js b/static/elements/chromedash-accordion.js index c916b0cc..e8053418 100644 --- a/static/elements/chromedash-accordion.js +++ b/static/elements/chromedash-accordion.js @@ -26,6 +26,7 @@ class ChromedashAccordion extends LitElement { border-radius: var(--accordion-border-radius); padding: var(--content-padding-quarter); width: var(--max-content-width); + cursor: pointer; } `]; } @@ -37,11 +38,15 @@ class ChromedashAccordion extends LitElement { toggle() { this.opened = !this.opened; + if (this.id) { + const anchor = this.opened ? this.id : ''; + history.replaceState(null, null, '#' + anchor); + } } render() { return html` -

+

diff --git a/static/js-src/feature-page.js b/static/js-src/feature-page.js index bcdf13af..48f632b3 100644 --- a/static/js-src/feature-page.js +++ b/static/js-src/feature-page.js @@ -61,6 +61,16 @@ if (SHOW_TOAST) { }, 500); } +// Open an accordion that was bookmarked open +if (location.hash) { + const targetId = decodeURIComponent(location.hash.substr(1)); + const targetEl = document.getElementById(targetId); + if (targetEl && targetEl.tagName == 'CHROMEDASH-ACCORDION') { + targetEl.opened = true; + } +} + + exports.subscribeToFeature = subscribeToFeature; exports.shareFeature = shareFeature; })(window); diff --git a/templates/feature.html b/templates/feature.html index f1cef214..6812a286 100644 --- a/templates/feature.html +++ b/templates/feature.html @@ -241,12 +241,14 @@ - + + dismissedcues='{{ user.dismissed_cues|default:"[]" }}'>