From 3df190e056138e7187c68c505c67d32094ec78a7 Mon Sep 17 00:00:00 2001 From: Garry Ing Date: Sun, 11 Apr 2021 14:54:57 -0400 Subject: [PATCH] persist expand state --- assets/js/scripts.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/assets/js/scripts.js b/assets/js/scripts.js index 4389c87..332d610 100644 --- a/assets/js/scripts.js +++ b/assets/js/scripts.js @@ -372,10 +372,20 @@ if (typeof window.graphData !== 'undefined') { // Note expander const noteExpander = document.querySelector('#note-expand') +const noteContainer = document.querySelector('#note-container') if (noteExpander) { + if (window.localStorage.getItem('noteExpanded') === 'true') { + noteExpander.classList.add('rotate-180') + noteContainer.classList.add('w-two-thirds') + } noteExpander.addEventListener('click', (event) => { - document.querySelector('#note-container').classList.toggle('w-two-thirds') + noteContainer.classList.toggle('w-two-thirds') event.target.classList.toggle('rotate-180') + if (window.localStorage.getItem('noteExpanded') === 'true') { + window.localStorage.setItem('noteExpanded', 'false') + } else { + window.localStorage.setItem('noteExpanded', 'true') + } }) }