Skip to content

Commit

Permalink
feature, add darkmode and change original colorpalette
Browse files Browse the repository at this point in the history
  • Loading branch information
beuleubeuleu committed Oct 23, 2023
1 parent d688043 commit 519f334
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 95 deletions.
15 changes: 6 additions & 9 deletions src/components/Hero.astro
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@
.titre {
font-size : 3em;
font-weight : 600;
color : #444;
}

.sous-titre {
font-size : 2em;
color : #444;
color : var(--accentTextColor);
}

.desc {
Expand All @@ -61,26 +60,24 @@

.cta a {
width : 100%;
color : #FFF;
color : var(--backgroundColor);
font-weight : 600;
font-size : 1.2em;
background : #555;
background : var(--backgroundUI);
padding : .8em 1.6em;
border-radius : 3px;
box-shadow : rgba(99, 99, 99, 0.2) 0 2px 8px 0;
transition : all .1s linear;
}

.cta a:hover {
background : #F6F6F6;
background : var(--backgroundColor);
box-shadow : rgba(0, 0, 0, 0.25) 0 54px 55px, rgba(0, 0, 0, 0.12) 0 -12px 30px, rgba(0, 0, 0, 0.12) 0 4px 6px, rgba(0, 0, 0, 0.17) 0 12px 13px, rgba(0, 0, 0, 0.09) 0 -3px 5px;
color : #333;
color : var(--textColor);
}

.cta a:active {
box-shadow : rgba(0, 0, 0, 0.35) 0 5px 15px;
background : #676767;
color : #FFF
transform: translate(2px, -2px);
}

@media screen and (min-width : 450px) {
Expand Down
5 changes: 3 additions & 2 deletions src/components/projets/ProjetCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const {
.card {
display : flex;
flex-direction : column;
border : 1px solid black;
border : 1px solid var(--accentTextColor);
border-radius : 3px;
max-width : 60ch;
min-height : 100%;
Expand All @@ -56,7 +56,8 @@ const {
}

.card:focus-within {
outline : 1px solid #000000EB;
outline : 1px solid var(--contrastTextColor2);
border: transparent;
}

.card:focus-within a:focus {
Expand Down
80 changes: 40 additions & 40 deletions src/components/shared/Footer.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import Socials from "../Socials.astro";
const menuItems = [
{
title: "Mon CV",
path: "/cv",
path: "/cv"
}
];
---

<hr />
<hr/>
<footer transition:name="footer">

{ 0===1 &&
<ul class="list-inline">
{ 0 === 1 &&
<ul class="list-inline">
{
menuItems.map((item) => (
<li class="list-inline-item">
<a href={ item.path }>{ item.title }</a>
</li>
))
menuItems.map((item) => (
<li class="list-inline-item">
<a href={ item.path }>{ item.title }</a>
</li>
))
}
</ul> }
</ul> }

<section class="footer-cards">

Expand All @@ -38,67 +38,67 @@ const menuItems = [
</section>



</footer>

<style>
footer {
max-width: 1196px;
margin : auto auto 1rem;
max-width : 1196px;
margin : auto auto 1rem;
}

.footer-cards {
display: flex;
flex-direction: column;
gap: 0.5em;
display : flex;
flex-direction : column;
gap : 0.5em;
}

.footer-card {
padding-block: 4em;
background: #F3F3F3;
padding-block : 4em;
background : var(--accentBackgroundColor);

flex-grow: 1;
flex-basis: 0;
flex-grow : 1;
flex-basis : 0;

display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
display : flex;
flex-direction : column;
justify-content : flex-start;
align-items : center;
}

.footer-card__title {
font-size: 1.3em;
margin-block: 0.6em;
font-weight : 600;
font-size : 1.3em;
margin-block : 0.6em;
font-weight : 600;
}

.card-info {
margin-block: 0.1em;
margin-block : 0.1em;
}

footer ul {
padding: 0;
list-style: none;
text-align: center;
margin-block: 4em;
padding : 0;
list-style : none;
text-align : center;
margin-block : 4em;
}

footer li {
padding: 0 0.7em;
margin-block: 0.4em;
padding : 0 0.7em;
margin-block : 0.4em;
}

hr {
width: 95%;
margin: 5em auto 3em;
color: #333333;
width : 95%;
margin : 5em auto 3em;
border : none;
border-top : 1px solid var(--accentBackgroundColor);
}


@media screen and (min-width: 500px) {
@media screen and (min-width : 500px) {
.footer-cards {
display: flex;
flex-direction: row;
display : flex;
flex-direction : row;
}
}
</style>
25 changes: 13 additions & 12 deletions src/components/shared/Header.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
import Socials from "../Socials.astro";
import ThemeIcon from "./ThemeIcon.astro";
const menuItems: {
title: string;
path: string;
Expand Down Expand Up @@ -65,22 +66,23 @@ const menuItems: {
</>
))
}
<ThemeIcon></ThemeIcon>
</nav>
</div>
</header>

<style lang="scss">

.header {
--bgHover: #F3F3F3;
--colorHover: #111;
--bgHover: var(--accentBackgroundColor);
--colorHover: var(--accentTextColor);


box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
position: sticky;
z-index: 5;
top: 0;
background-color: white;
background: var(--backgroundColor);

.container {
display: flex;
Expand All @@ -107,7 +109,7 @@ const menuItems: {

&:hover,
&:focus {
background-color: #f5f5f5;
background-color: var(--accentBackgroundColor);
}
}

Expand All @@ -116,17 +118,16 @@ const menuItems: {
flex-direction: column;
align-items: center;
padding: .5em 0;
border-top: solid 1px #e5e5e5;
border-top: solid 1px var(--accentBackgroundColor);
width: 100%;
}


.header__link {
color: #333;
text-decoration: none;
padding: .5em 1em;
white-space: nowrap;
transition: background-color 0.3s ease-in-out, color 0.3s ease-in-out;
transition: background-color 0.3s ease-in-out;

&:hover,
&:focus {
Expand All @@ -143,10 +144,10 @@ const menuItems: {
display: block;
padding: .25em .5em;
margin-left: 1em;
color: #55626a;
color: var(--accentTextColor);
font-size: 0.875rem;
text-decoration: none;
transition: background-color 0.3s ease-in-out, color 0.3s ease-in-out;
transition: background-color 0.3s ease-in-out;

&:hover,
&:focus {
Expand Down Expand Up @@ -240,14 +241,14 @@ const menuItems: {
top: 54px;
height: 0;
overflow: hidden;
background-color: #F3F3F3;
border-top: solid 1px #e5e5e5;
background-color: var(--accentBackgroundColor);
border-top: solid 1px var(--accentBackgroundColor);
transition: all 0.3s ease-in-out;


> a {
padding: 10px;
margin-left: 0;
color: #333;
font-size: 1rem;
&:hover {
text-decoration: underline;
Expand Down
62 changes: 62 additions & 0 deletions src/components/shared/ThemeIcon.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<button id="themeToggle">
<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;
margin-inline: 20px;
}
.sun { fill: black; }
.moon { fill: transparent; }


:global(.dark) .sun { fill: transparent; }
:global(.dark) .moon { fill: white; }
</style>

<script>
document.addEventListener('astro:page-load', () => {
const theme = (() => {
if (typeof localStorage !== "undefined" && localStorage.getItem("theme")) {
return localStorage.getItem("theme");
}
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
return "dark";
}
return "light";
})();

if (theme === "light") {
document.documentElement.classList.remove("dark");
} else {
document.documentElement.classList.add("dark");
}

window.localStorage.setItem("theme", theme);

const handleToggleClick = () => {
const element = document.documentElement;
element.classList.toggle("dark");

const isDark = element.classList.contains("dark");
localStorage.setItem("theme", isDark ? "dark" : "light");
};

document
.getElementById("themeToggle")
.addEventListener("click", handleToggleClick);
});
</script>

<script>
document.addEventListener('astro:after-swap', () => {
localStorage.theme === 'dark'
? document.documentElement.classList.add("dark")
: document.documentElement.classList.remove("dark");
});
</script>
Loading

0 comments on commit 519f334

Please sign in to comment.