From c36d66558c7ddcff03397c07c89f0b819aa2f446 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 26 Mar 2022 22:33:49 +0200 Subject: Added changing page width setting --- src/_header.html | 4 ++- src/img/viewport-narrow-tabler.svg | 61 ++++++++++++++++++++++++++++++++++++++ src/img/viewport-wide-tabler.svg | 61 ++++++++++++++++++++++++++++++++++++++ src/regarding-js.md | 2 ++ src/scripts/page-width.js | 20 +++++++++++++ src/styles.css | 6 +++- 6 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 src/img/viewport-narrow-tabler.svg create mode 100644 src/img/viewport-wide-tabler.svg create mode 100644 src/scripts/page-width.js (limited to 'src') diff --git a/src/_header.html b/src/_header.html index 4b45a0c..4579e4b 100644 --- a/src/_header.html +++ b/src/_header.html @@ -37,9 +37,11 @@ Tutorials - || Light + || Light +
+ diff --git a/src/img/viewport-narrow-tabler.svg b/src/img/viewport-narrow-tabler.svg new file mode 100644 index 0000000..1511836 --- /dev/null +++ b/src/img/viewport-narrow-tabler.svg @@ -0,0 +1,61 @@ + + + + + + + + + + diff --git a/src/img/viewport-wide-tabler.svg b/src/img/viewport-wide-tabler.svg new file mode 100644 index 0000000..93694ea --- /dev/null +++ b/src/img/viewport-wide-tabler.svg @@ -0,0 +1,61 @@ + + + + + + + + + + diff --git a/src/regarding-js.md b/src/regarding-js.md index 13dee23..702038f 100644 --- a/src/regarding-js.md +++ b/src/regarding-js.md @@ -16,6 +16,7 @@ Any user data that might be saved isn't, and never will be, used for purposes no |[back-to-top.js](/scripts/back-to-top.js)|Automatically appearing button to scroll to top|[Link](https://gitlab.com/Syndamia/syndamiadotcom/-/tree/master/src/scripts/back-to-top.js)| |[theme-changer-preload.js](/scripts/theme-changer-preload.js)   [theme-changer.js](/scripts/theme-changer.js)|Change theme between light and dark (split in two files)|[Link 1](https://gitlab.com/Syndamia/syndamiadotcom/-/tree/master/src/scripts/theme-changer-preload.js)   [Link 2](https://gitlab.com/Syndamia/syndamiadotcom/-/tree/master/src/scripts/theme-changer.js)| |[js-styling-preload.js](/scripts/js-styling-preload.js)|Un-disables hiding of elements, used by the scripts listed here|[Link](https://gitlab.com/Syndamia/syndamiadotcom/-/tree/master/src/scripts/js-styling-preload.js)| +|[page-width.js](/scripts/page-width.js)|Change whether text covers the whole width of the page or only the middle (applicable to wide screens)|[Link](https://gitlab.com/Syndamia/syndamiadotcom/-/tree/master/src/scripts/page-width.js)| ## Data in browser storage [![🔗](/img/link-tabler.svg)](#data-in-browser-storage) @@ -28,5 +29,6 @@ Any user data that might be saved isn't, and never will be, used for purposes no |Key|Values|Description| |---|---|---| |`theme`|`dark`\|`light`|Saves which theme should be loaded| +|`width`|`norm`\|`wide`|Saves in which width pages should be shown|

diff --git a/src/scripts/page-width.js b/src/scripts/page-width.js new file mode 100644 index 0000000..577c590 --- /dev/null +++ b/src/scripts/page-width.js @@ -0,0 +1,20 @@ +const widthBtn = document.getElementById('changeWidthBtn'); +const articleElem = document.getElementsByTagName('article')[0]; + +if (localStorage.getItem('width') === 'wide') { + widthBtn.src = '/img/viewport-narrow-tabler.svg'; + articleElem.classList.add('noMaxWidth'); +} + +widthBtn.onclick = function() { + articleElem.classList.toggle('noMaxWidth'); + + if (localStorage.getItem('width') !== 'norm') { + widthBtn.src = '/img/viewport-wide-tabler.svg'; + localStorage.setItem('width', 'norm'); + } + else { + widthBtn.src = '/img/viewport-narrow-tabler.svg'; + localStorage.setItem('width', 'wide'); + } +} diff --git a/src/styles.css b/src/styles.css index c3048da..1559964 100644 --- a/src/styles.css +++ b/src/styles.css @@ -148,6 +148,10 @@ article { overflow: auto; } +.noMaxWidth { + max-width: initial; +} + ul, ol { padding-inline-start: 30px; } @@ -488,7 +492,7 @@ blockquote > :last-child { padding: 0.3em; } -#changeThemeBtn { +.setting-btn { vertical-align: middle; margin-top: -0.2em; border: none !important; -- cgit v1.3.1-26-gb76a