Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
ajyey committed Jun 15, 2024
2 parents 2962225 + 600b7f9 commit ab72929
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 49 deletions.
6 changes: 6 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,12 @@ third_party_libraries:
url:
js: "https://cdn.jsdelivr.net/npm/mermaid@{{version}}/dist/mermaid.min.js"
version: "10.7.0"
particles-js:
integrity:
js: "sha256-4CVKTLmrkrCVvcp7cJhhBq7+PUdDjbXA3x3HI/cudR0="
url:
js: "https://cdn.jsdelivr.net/npm/particles.js@{{version}}/particles.min.js"
version: "2.0.0"
polyfill:
url:
js: "https://cdnjs.cloudflare.com/polyfill/v{{version}}/polyfill.min.js?features=es6"
Expand Down
9 changes: 0 additions & 9 deletions _includes/scripts/search.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -584,15 +584,6 @@
setThemeSetting("dark");
},
},
{
id: 'system-theme',
title: 'Use system default theme',
description: 'Change the theme of the site to System Default',
section: 'Theme',
handler: () => {
setThemeSetting("system");
},
},
{%- endif -%}
];
</script>
Expand Down
22 changes: 22 additions & 0 deletions _layouts/default.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

<!-- Body -->
<body class="{% if site.navbar_fixed %}fixed-top-nav{% endif %} {% unless site.footer_fixed %}sticky-bottom-footer{% endunless %}">
<!-- Particles Container -->
<div id="particles-js"></div>

<!-- Header -->
{% include header.liquid %}

Expand Down Expand Up @@ -74,5 +77,24 @@
{% include scripts/back_to_top.liquid %}
{% include scripts/search.liquid %}
<script src="{{ '/assets/js/shortcut-key.js' | relative_url }}"></script>
<!-- Particles JS -->
<script src="{{ site.third_party_libraries.particles-js.url.js }}"></script>
<!-- Initialize Particles.js -->
<script>
function loadParticlesConfig() {
const theme = document.documentElement.getAttribute('data-theme');
const configPath =
theme === 'dark' ? '{{ "particles-config-dark.json" | relative_url }}' : '{{ "particles-config-light.json" | relative_url }}';
particlesJS.load('particles-js', configPath);
}
// Load particles config on page load
loadParticlesConfig();
// Re-load particles config when theme changes
const observer = new MutationObserver(loadParticlesConfig);
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
</script>
</body>
</html>
11 changes: 10 additions & 1 deletion _sass/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ figure.highlight {

pre {
color: var(--global-theme-color);
background-color: var(--global-code-bg-color);
background-color: var(--global-code-bg-color) !important;
border-radius: 6px;
padding: 6px 12px;

Expand Down Expand Up @@ -1133,3 +1133,12 @@ ninja-keys::part(ninja-input) {
ninja-keys::part(ninja-input-wrapper) {
background: var(--global-bg-color);
}

#particles-js {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: -1;
}
3 changes: 2 additions & 1 deletion _sass/_themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ html[data-theme="dark"] {
--global-distill-app-color: #{$grey-color-light};
--global-divider-color: #424246;
--global-card-bg-color: #{$grey-900};
--global-back-to-top-bg-color: rgba(#{red($white-color)}, #{green($white-color)}, #{blue($white-color)}, 0.5);
// --global-back-to-top-bg-color: rgba(#{red($white-color)}, #{green($white-color)}, #{blue($white-color)}, 0.5);
--global-back-to-top-bg-color: rgba(198, 120, 221, 0.85); // #c678dd
--global-back-to-top-text-color: #{$black-color};

--global-tip-block: #42b983;
Expand Down
8 changes: 4 additions & 4 deletions _sass/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $red-color-dark: #b71c1c !default;
$orange-color: #f29105 !default;
$blue-color: #0076df !default;
$blue-color-dark: #00369f !default;
$cyan-color: #2698ba !default;
$cyan-color: #61afef !default;
$light-cyan-color: lighten($cyan-color, 25%);
$green-color: #00ab37 !default;
$green-color-lime: #b7d12a !default;
Expand All @@ -24,16 +24,16 @@ $yellow-color: #efcc00 !default;

$grey-color: #828282 !default;
$grey-color-light: lighten($grey-color, 40%);
$grey-color-dark: #1c1c1d;
$grey-color-dark: #1e2227;
$grey-900: #212529;

$white-color: #ffffff !default;
$white-color: #f4f3f2 !default;
$black-color: #000000 !default;

// Theme colors

$code-bg-color-light: rgba($purple-color, 0.05);
$code-bg-color-dark: #2c3237 !default;
$code-bg-color-dark: #23272e !default;

// Font awesome location
$fa-font-path: "../webfonts";
Expand Down
42 changes: 8 additions & 34 deletions assets/js/theme.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
// Has to be in the head tag, otherwise a flicker effect will occur.

// Toggle through light, dark, and system theme settings.
// Toggle between light and dark theme settings.
let toggleThemeSetting = () => {
let themeSetting = determineThemeSetting();
if (themeSetting == "system") {
setThemeSetting("light");
} else if (themeSetting == "light") {
if (themeSetting == "light") {
setThemeSetting("dark");
} else {
setThemeSetting("system");
setThemeSetting("light");
}
};

// Change the theme setting and apply the theme.
let setThemeSetting = (themeSetting) => {
localStorage.setItem("theme", themeSetting);

document.documentElement.setAttribute("data-theme-setting", themeSetting);

applyTheme();
};

// Apply the computed dark or light theme to the website.
let applyTheme = () => {
let theme = determineComputedTheme();
let theme = determineThemeSetting();

transTheme();
setHighlight(theme);
Expand Down Expand Up @@ -78,7 +74,7 @@ let applyTheme = () => {
// Updates the background of medium-zoom overlay.
if (typeof medium_zoom !== "undefined") {
medium_zoom.update({
background: getComputedStyle(document.documentElement).getPropertyValue("--global-bg-color") + "ee", // + 'ee' for trasparency.
background: getComputedStyle(document.documentElement).getPropertyValue("--global-bg-color") + "ee", // + 'ee' for transparency.
});
}
};
Expand Down Expand Up @@ -205,32 +201,15 @@ let transTheme = () => {
}, 500);
};

// Determine the expected state of the theme toggle, which can be "dark", "light", or
// "system". Default is "system".
// Determine the expected state of the theme toggle, which can be "dark" or "light". Default is "light".
let determineThemeSetting = () => {
let themeSetting = localStorage.getItem("theme");
if (themeSetting != "dark" && themeSetting != "light" && themeSetting != "system") {
themeSetting = "system";
if (themeSetting != "dark" && themeSetting != "light") {
themeSetting = "light";
}
return themeSetting;
};

// Determine the computed theme, which can be "dark" or "light". If the theme setting is
// "system", the computed theme is determined based on the user's system preference.
let determineComputedTheme = () => {
let themeSetting = determineThemeSetting();
if (themeSetting == "system") {
const userPref = window.matchMedia;
if (userPref && userPref("(prefers-color-scheme: dark)").matches) {
return "dark";
} else {
return "light";
}
} else {
return themeSetting;
}
};

let initTheme = () => {
let themeSetting = determineThemeSetting();

Expand All @@ -244,9 +223,4 @@ let initTheme = () => {
toggleThemeSetting();
});
});

// Add event listener to the system theme preference change.
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", ({ matches }) => {
applyTheme();
});
};
110 changes: 110 additions & 0 deletions particles-config-dark.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"particles": {
"number": {
"value": 50,
"density": {
"enable": true,
"value_area": 800
}
},
"color": {
"value": "#ffffff"
},
"shape": {
"type": "circle",
"stroke": {
"width": 0,
"color": "#000000"
},
"polygon": {
"nb_sides": 5
},
"image": {
"src": "img/github.svg",
"width": 100,
"height": 100
}
},
"opacity": {
"value": 0.25,
"random": false,
"anim": {
"enable": false,
"speed": 1,
"opacity_min": 0.1,
"sync": false
}
},
"size": {
"value": 2,
"random": true,
"anim": {
"enable": false,
"speed": 40,
"size_min": 0.1,
"sync": false
}
},
"line_linked": {
"enable": true,
"distance": 125,
"color": "#ffffff",
"opacity": 0.2,
"width": 1
},
"move": {
"enable": true,
"speed": 0.25,
"direction": "none",
"random": false,
"straight": false,
"out_mode": "out",
"bounce": false,
"attract": {
"enable": false,
"rotateX": 600,
"rotateY": 1200
}
}
},
"interactivity": {
"detect_on": "canvas",
"events": {
"onhover": {
"enable": false,
"mode": "repulse"
},
"onclick": {
"enable": false,
"mode": "push"
},
"resize": true
},
"modes": {
"grab": {
"distance": 400,
"line_linked": {
"opacity": 1
}
},
"bubble": {
"distance": 400,
"size": 40,
"duration": 2,
"opacity": 8,
"speed": 3
},
"repulse": {
"distance": 200,
"duration": 0.4
},
"push": {
"particles_nb": 4
},
"remove": {
"particles_nb": 2
}
}
},
"retina_detect": true
}
Loading

0 comments on commit ab72929

Please sign in to comment.