From 223a23e0ce2d964a91567c61a23aadf6a520a3b0 Mon Sep 17 00:00:00 2001 From: David Maciejewski Date: Wed, 20 Mar 2024 15:35:07 +0100 Subject: [PATCH] Feat: Added System theme for switcher --- astro.config.mjs | 1 + src/components/Header.astro | 70 ++++++++- src/components/Navigation.astro | 2 +- src/components/ThemeButton.astro | 64 ++++++--- src/components/ThemeSwitch.astro | 237 +++++++++++++++++-------------- src/styles/base/_variables.scss | 2 - 6 files changed, 245 insertions(+), 131 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index 38c1322..955d3d1 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -90,6 +90,7 @@ export default defineConfig({ materialSymbols: [ 'menu', 'close', + 'monitor-outline', 'arrow-upward-rounded', 'keyboard-double-arrow-left', 'keyboard-double-arrow-right', diff --git a/src/components/Header.astro b/src/components/Header.astro index 03f61eb..d39e4d7 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -56,7 +56,7 @@ import { SITE_CONST } from '../const.ts' aria-label='Weiterführende Links' > @@ -117,7 +117,7 @@ import { SITE_CONST } from '../const.ts' padding-inline: var(--sp-content); background-color: var(--clr-bg); - border-bottom: 1px solid var(--nav-border); + border-bottom: 1px solid var(--clr-line); box-shadow: 1.5rem 0 4rem -0.5rem var(--nav-shadow); transition: all var(--transition-theme); @@ -147,6 +147,7 @@ import { SITE_CONST } from '../const.ts' @include mixins.respond('l') { display: flex; + align-items: center; flex: 0 1 auto; } } @@ -260,4 +261,63 @@ import { SITE_CONST } from '../const.ts' fill: #15232d; } } + + @media (hover: hover) { + [data-hint] { + position: relative; + z-index: 500; + cursor: pointer; + + &::before, + &::after { + position: absolute; + left: 50%; + bottom: 0.25rem; + transition: + opacity 0.2s, + transform 0.2s; + + opacity: 0; + pointer-events: none; + } + + &::before { + padding: 0.5em 1em 0.7em; + border-radius: var(--radius); + color: var(--clr-text); + background-color: var(--clr-bg-card); + border: 1px solid var(--clr-line); + content: attr(data-hint); + + font-size: var(--fs-s); + line-height: 1.2em; + white-space: nowrap; + text-align: center; + box-shadow: 0 0.5rem 0.5rem -0.5rem rgb(0 0 0 / 0.2); + transform: translate(-50%, 0%); + } + + &::after { + width: 0; + border: 5px solid transparent; + border-bottom-color: var(--clr-line); + content: ''; + font-size: 0; + line-height: 0; + transform: translate(-50%, -100%); + } + + &:hover { + &::before { + opacity: 1; + transform: translate(-50%, 100%); + } + + &::after { + opacity: 1; + transform: translate(-50%, 0); + } + } + } + } diff --git a/src/components/Navigation.astro b/src/components/Navigation.astro index 8c65cee..d26a67e 100644 --- a/src/components/Navigation.astro +++ b/src/components/Navigation.astro @@ -178,7 +178,7 @@ const filteredPages = pages text-decoration: none; &:hover, - &:focus { + &:focus-visible { background-color: transparent; color: var(--clr-primary); } diff --git a/src/components/ThemeButton.astro b/src/components/ThemeButton.astro index 800aaf1..d0a5a3b 100644 --- a/src/components/ThemeButton.astro +++ b/src/components/ThemeButton.astro @@ -23,9 +23,14 @@ fill-rule='evenodd' d='M16.5 6A10.5 10.5 0 0 1 4.7 16.4 8.5 8.5 0 1 0 16.4 4.7l.1 1.3zm-1.7-2a9 9 0 0 1 .2 2 9 9 0 0 1-11 8.8 9.4 9.4 0 0 1-.8-.3c-.4 0-.8.3-.7.7a10 10 0 0 0 .3.8 10 10 0 0 0 9.2 6 10 10 0 0 0 4-19.2 9.7 9.7 0 0 0-.9-.3c-.3-.1-.7.3-.6.7a9 9 0 0 1 .3.8z' > + - Themen umschalten +Themen umschalten diff --git a/src/components/ThemeSwitch.astro b/src/components/ThemeSwitch.astro index 9a5da9d..eb37058 100644 --- a/src/components/ThemeSwitch.astro +++ b/src/components/ThemeSwitch.astro @@ -3,112 +3,105 @@ import { Icon } from 'astro-icon/components' --- -