Skip to content

Commit

Permalink
Fixed mobile styling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurt Bruns committed Jul 21, 2023
1 parent 8e4c3ae commit cee2687
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
4 changes: 4 additions & 0 deletions assets/scss/components/_syntax.scss
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ pre.block {
border: 1px solid var(--border-color);
}

pre {
overflow: auto;
}

/* Background */ .chroma { color: var(--syntax-foreground); background-color: var(--syntax-background) }
/* Other */ .chroma .x { }
/* Error */ .chroma .err { color: var(--syntax-error); background-color: var(--syntax-background) }
Expand Down
8 changes: 7 additions & 1 deletion assets/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@


section.copyright {
margin-bottom: 50rem;
margin-bottom: 10rem;
}

@include small-breakpoint {
section.copyright {
margin-bottom: 50rem;
}
}

img.center {
Expand Down
40 changes: 20 additions & 20 deletions assets/typescript/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/


function updateTheme(isDark:boolean) {
function updateTheme(isDark: boolean) {
document.documentElement.classList.toggle('light-theme', !isDark);
sessionStorage.setItem('theme', isDark ? 'dark' : 'light');
}
Expand All @@ -15,25 +15,25 @@ function initializeTheme() {
let theme = sessionStorage.getItem('theme');
let isDark = true;
if (theme !== null && theme === 'light') {
isDark = false;
isDark = false;
}

// Use user's default theme if one is not specified
if (theme === null && window.matchMedia) {
const darkSchemeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
darkSchemeMediaQuery.addEventListener('change', (e) => updateTheme(e.matches));
updateTheme(darkSchemeMediaQuery.matches);
} else {
} else {
updateTheme(isDark)
}
}

let toggle: HTMLDivElement = document.querySelector('.nav-theme');
toggle.onclick = (event) => {
let toggle: HTMLDivElement = document.querySelector('.nav-theme');
toggle.onclick = (event) => {
updateTheme(!(sessionStorage.getItem('theme') === 'dark'));
event.preventDefault();
event.stopPropagation();
};
};

}

/*
Expand All @@ -45,13 +45,13 @@ window.addEventListener('load', (event) => {

// Initialize nav elements and get a handle on headings
let nav = document.querySelectorAll(".aside-li") as unknown as HTMLElement[];
let headings : HTMLElement[] = [];
for( let i = 0; i < nav.length; i++) {
let li= nav[i] as HTMLElement;
let headings: HTMLElement[] = [];
for (let i = 0; i < nav.length; i++) {
let li = nav[i] as HTMLElement;
headings.push(document.getElementById(li.dataset["anchor"]));
}

let active : HTMLElement = null;
let active: HTMLElement = null;
let margin = 24

function scrollHandler() {
Expand All @@ -60,7 +60,7 @@ window.addEventListener('load', (event) => {
if (Math.ceil(window.innerHeight + window.scrollY) >= document.body.scrollHeight) {

// remove active stylings
if( active != null ) {
if (active != null) {
active.classList.remove('active')
}

Expand All @@ -73,23 +73,23 @@ window.addEventListener('load', (event) => {
let i = 0;
let position = -1;
let heading = null;

// loop through the headings
for( i = 0; i < headings.length; i++ ) {
for (i = 0; i < headings.length; i++) {
heading = headings[i];
position = heading.getBoundingClientRect().top;
if( position >= margin ) {
if (position >= margin) {
break;
}
}

// remove active styling
if( active != null ) {
if (active != null) {
active.classList.remove('active')
}
// check if we are at the top of the document
if( i <= 0 ) {

// check if we are at the top of the document
if (i <= 0) {
active = undefined;
} else {
active = nav[i - 1];
Expand Down

0 comments on commit cee2687

Please sign in to comment.