feat: init
This commit is contained in:
32
src/components/Card.astro
Normal file
32
src/components/Card.astro
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
interface Props {
|
||||
url: string;
|
||||
image: string;
|
||||
title: string;
|
||||
body: string;
|
||||
}
|
||||
|
||||
const { url, image, title, body } = Astro.props;
|
||||
---
|
||||
|
||||
<li class="card">
|
||||
<a class="card__link" href={url}>
|
||||
<div class="center">
|
||||
<img
|
||||
class="card__img"
|
||||
src={image}
|
||||
role="presentation"
|
||||
width="226"
|
||||
height="127"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
/>
|
||||
</div>
|
||||
<h3 class="card__title">
|
||||
{title}
|
||||
</h3>
|
||||
<p class="card__txt">
|
||||
{body}
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
29
src/components/CardPost.astro
Normal file
29
src/components/CardPost.astro
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
interface Props {
|
||||
url: string;
|
||||
image: string;
|
||||
title: string;
|
||||
date: string;
|
||||
}
|
||||
|
||||
const { url, image, title, date } = Astro.props;
|
||||
---
|
||||
|
||||
<li class="card">
|
||||
<a class="card__link" href={url}>
|
||||
<div class="center">
|
||||
<img
|
||||
class="card__img"
|
||||
src={image}
|
||||
role="presentation"
|
||||
width="226"
|
||||
height="127"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
/>
|
||||
</div>
|
||||
<h3 class="card__title">
|
||||
{title}
|
||||
</h3>
|
||||
</a>
|
||||
</li>
|
||||
14
src/components/Footer.astro
Normal file
14
src/components/Footer.astro
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
const year = new Date().getFullYear();
|
||||
---
|
||||
<footer>
|
||||
<div class="center">
|
||||
<ul class="footer">
|
||||
<li class="icon__btn"><a class="icon__link" href="#" target="_blank"><span class="git-icon">GitHub</span></a></li>
|
||||
<li class="icon__btn"><a class="icon__link" href="mailto: #@gmail.com"><span class="mail-icon">Email</span></a></li>
|
||||
<li class="icon__btn"><a class="icon__link" href="#" target="_blank"><span class="linked-in">LinkedIn</span></a></li>
|
||||
</ul>
|
||||
<small>© {year} Milky-Way by <a class="footer__link" href="https://github.com/ttomczak3">ttomczak</a>. All Rights Reserved.</small>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
9
src/components/Header.astro
Normal file
9
src/components/Header.astro
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
import Navigation from './Navigation.astro';
|
||||
---
|
||||
<header>
|
||||
<nav transition:persist >
|
||||
<Navigation />
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
15
src/components/Navigation.astro
Normal file
15
src/components/Navigation.astro
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
import ThemeIcon from './ThemeIcon.astro';
|
||||
---
|
||||
<div class="navbar">
|
||||
<div class="navbar__title">
|
||||
<a href="/">Milky-Way</a>
|
||||
</div>
|
||||
<div class="navbar__menu">
|
||||
<a href="/works/">Works</a>
|
||||
<a href="/posts/">Posts</a>
|
||||
<a href="https://github.com/ttomczak3/Milky-Way" target="_blank">GitHub</a>
|
||||
<ThemeIcon />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
55
src/components/ThemeIcon.astro
Normal file
55
src/components/ThemeIcon.astro
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
---
|
||||
<button id="themeToggle" title="Theme Toggle">
|
||||
<svg width="30px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||
<path class="sun" fill-rule="evenodd" d="M12 17.5a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11zm0 1.5a7 7 0 1 0 0-14 7 7 0 0 0 0 14zm12-7a.8.8 0 0 1-.8.8h-2.4a.8.8 0 0 1 0-1.6h2.4a.8.8 0 0 1 .8.8zM4 12a.8.8 0 0 1-.8.8H.8a.8.8 0 0 1 0-1.6h2.5a.8.8 0 0 1 .8.8zm16.5-8.5a.8.8 0 0 1 0 1l-1.8 1.8a.8.8 0 0 1-1-1l1.7-1.8a.8.8 0 0 1 1 0zM6.3 17.7a.8.8 0 0 1 0 1l-1.7 1.8a.8.8 0 1 1-1-1l1.7-1.8a.8.8 0 0 1 1 0zM12 0a.8.8 0 0 1 .8.8v2.5a.8.8 0 0 1-1.6 0V.8A.8.8 0 0 1 12 0zm0 20a.8.8 0 0 1 .8.8v2.4a.8.8 0 0 1-1.6 0v-2.4a.8.8 0 0 1 .8-.8zM3.5 3.5a.8.8 0 0 1 1 0l1.8 1.8a.8.8 0 1 1-1 1L3.5 4.6a.8.8 0 0 1 0-1zm14.2 14.2a.8.8 0 0 1 1 0l1.8 1.7a.8.8 0 0 1-1 1l-1.8-1.7a.8.8 0 0 1 0-1z"/>
|
||||
<path class="moon" 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"/>
|
||||
</svg>
|
||||
</button>
|
||||
<style>
|
||||
#themeToggle {
|
||||
border: 0;
|
||||
background: none;
|
||||
}
|
||||
|
||||
#themeToggle:hover {
|
||||
cursor: pointer;
|
||||
rotate: 10deg;
|
||||
}
|
||||
|
||||
.moon { fill: #eff1f5; }
|
||||
.sun { fill: transparent; }
|
||||
|
||||
:global(.light) .moon { fill: transparent; }
|
||||
:global(.light) .sun { fill: #1e1e2e; }
|
||||
</style>
|
||||
<script is:inline >
|
||||
const theme = (() => {
|
||||
if (typeof localStorage !== 'undefined' && localStorage.getItem('theme')) {
|
||||
return localStorage.getItem('theme');
|
||||
}
|
||||
if (window.matchMedia('(prefers-color-scheme: light)').matches) {
|
||||
return 'light';
|
||||
}
|
||||
return 'dark';
|
||||
})();
|
||||
|
||||
if (theme === 'dark') {
|
||||
document.documentElement.classList.remove('light');
|
||||
} else {
|
||||
document.documentElement.classList.add('light');
|
||||
}
|
||||
|
||||
window.localStorage.setItem('theme', theme);
|
||||
|
||||
const handleToggleClick = () => {
|
||||
const element = document.documentElement;
|
||||
element.classList.toggle("light");
|
||||
|
||||
const isLight = element.classList.contains("light");
|
||||
localStorage.setItem("theme", isLight ? "light" : "dark");
|
||||
}
|
||||
|
||||
document.getElementById("themeToggle").addEventListener("click", handleToggleClick);
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user