Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Full theme switcher/feat/1 #9

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions demo/src/components/ThemeSwitcher/ThemeSwitcher.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
import { Picture } from 'astro-imagetools/components';
---

<div class='theme-switcher'>
<strong aria-hidden='true'>Themes:</strong>
<ul class='list' role='none' aria-label='Theme switcher'>
<li>
<div
data-theme-switch='default'
class='button'
role='button'
tabindex={0}
>
👩‍🚀&nbsp;Terraformers&nbsp;👨‍🚀
</div>
</li>

<li>
<div data-theme-switch='hacker' class='button' role='button' tabindex={0}>
<div class='normal'>
<!-- <Picture src='/graphics/exports/elite-hacker.png' alt='' height={100}
/> -->
<div aria-hidden='true'>
3|_337<br />&nbsp;&nbsp;<strong>|-|4XØȐ</strong>
</div>
<span class='visually-hidden'>Elite Hacker</span>
</div>
<div class='revealed' aria-hidden='true'>
<!-- <Picture
src='/graphics/exports/elite-hacker-yes.png'
alt=''
height={100}
/> -->
<strong>&lt;&nbsp;¥€$.</strong>
</div>
</div>
</li>
</ul>
</div>

<script>
const switches = document.querySelectorAll('[data-theme-switch]');
const root = document.documentElement;

switches.forEach((sw) => {
const attr = sw.getAttribute('data-theme-switch');
sw.addEventListener('click', () => {
// console.log(attr);
root.setAttribute('data-theme', attr);
});
});
</script>

<style lang='scss'>
@import './style.scss';
</style>
107 changes: 107 additions & 0 deletions demo/src/components/ThemeSwitcher/ThemeSwitcher.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
.theme-switcher {
display: flex;
align-items: center;
padding: 0 2rem;
}

// @include theme(default) {
// box-shadow: 2px 2px 12px color.adjust($fiery-rose, $alpha: -0.5) inset,
// 2px 2px 2px color.adjust($raisin-black, $alpha: -0.9) inset;
// }
// @include theme(default, light) {
// background-color: color.adjust($lavender-blush, $lightness: 2%);
// }
// }

// .list {
// display: flex;
// align-items: center;
// }

.button {
display: flex;
align-items: center;
// padding: 0 2rem;
margin: 0 2vw;
// font-weight: 700;
cursor: pointer;

// @include theme(default) {
// font-variant: small-caps;
// font-weight: 700;
// font-size: 1.15rem;
// }
}

// [data-theme-switch="default"] {
// padding: 0.3334rem 0.6667rem 0.2334rem 0.6667rem;
// border-radius: 1rem;
// color: color.adjust($rosewood, $alpha: -0.1);
// @include default-font-main;
// // background-color: color.adjust($fiery-rose, $alpha: -0.8);
// box-shadow: 2px 2px 12px color.adjust($fiery-rose, $alpha: -0.2),
// 2px 2px 2px color.adjust($raisin-black, $alpha: -0.8) inset;

// &:hover {
// color: color.adjust($raisin-black, $alpha: 0);
// background-color: color.adjust($fiery-rose, $alpha: -0.5);
// }
// @include theme(default, light) {
// pointer-events: none;
// }
// }

[data-theme-switch="hacker"] {
// // cursor: ne-resize;
// @include hacker-font-main;
// // font-weight: 700;

.normal,
.revealed {
// bottom: -0.3334rem;
// left: -0.6667rem;
padding-top: 0.5rem;
display: flex;
align-items: center;
filter: drop-shadow(1px 1px 3px color.adjust(lightgreen, $alpha: -0.4));
transition: opacity 0.15s;
}

.revealed {
position: absolute;
opacity: 0;
}

// &:hover {
// .normal {
// opacity: 0;
// }

// .revealed {
// opacity: 1;
// }
// }
// @include theme(default, light) {
// &:hover {
// // color: color.adjust(lightgreen, $alpha: -0.1);
// // background-color: color.adjust($fiery-rose, $alpha: -0.8);
// box-shadow: 2px 2px 12px color.adjust(lightgreen, $alpha: -0.4),
// 2px 2px 2px color.adjust($raisin-black, $alpha: -0.9) inset;
// color: color.adjust($raisin-black, $alpha: 0);
// background-color: color.adjust(lightgreen, $alpha: -0.5);
// }
// }
// @include theme(default, dark) {
// &:hover {
// // color: color.adjust(lightgreen, $alpha: -0.1);
// // background-color: color.adjust($fiery-rose, $alpha: -0.8);
// box-shadow: 2px 2px 12px color.adjust(lightgreen, $alpha: -0.4),
// 2px 2px 2px color.adjust($raisin-black, $alpha: -0.9) inset;
// color: color.adjust($raisin-black, $alpha: 0);
// background-color: color.adjust(lightgreen, $alpha: -0.5);
// }
// }

// @include theme(hacker) {
// pointer-events: none;
}