Skip to content

Commit

Permalink
composable css
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy-zhening-luo committed Jul 21, 2024
1 parent a2f563c commit 297e84b
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 117 deletions.
2 changes: 1 addition & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
strictEvents>
// import "../app.css";
import "./styles.css";
import "./site.css";
import Header from "./Header.svelte";
import Footer from "./Footer.svelte";
Expand Down
18 changes: 18 additions & 0 deletions src/routes/Footer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
footer {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
gap: 1rem;
padding: 12px 12px 85px 12px;
}

footer p {
font-size: 0.8rem;
}

@media (min-width: 480px) {
footer {
padding: 12px 0 85px 0;
}
}
30 changes: 7 additions & 23 deletions src/routes/Footer.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<script
lang="ts"
strictEvents>
</script>

<footer>
<span
class="copyright">
Expand All @@ -13,32 +18,11 @@
</span>
</footer>

<script
lang="ts"
strictEvents></script>

<style
lang="css">
footer {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
gap: 1rem;
padding: 12px 12px 85px 12px;
}
footer p {
font-size: 0.8rem;
}
@import "Footer.css";
footer .copyright p {
.copyright p {
font-weight: 600;
}
@media (min-width: 480px) {
footer {
padding: 12px 0 85px 0;
}
}
</style>
68 changes: 68 additions & 0 deletions src/routes/Header.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
header {
display: flex;
justify-content: space-between;
}

nav {
display: flex;
justify-content: center;
--background: rgba(255, 255, 255, 0.7);
}

svg {
display: block;
width: 2em;
height: 3em;
}

path {
fill: var(--background);
}

ul {
list-style: none;
position: relative;
display: flex;
justify-content: center;
align-items: center;
margin: 0;
padding: 0;
height: 3em;
background-size: contain;
background: var(--background);
}

li {
position: relative;
height: 100%;
}

li[aria-current="page"]::before {
position: absolute;
top: 0;
left: calc(50% - var(--size));
--size: 6px;
width: 0;
height: 0;
border: var(--size) solid transparent;
border-top: var(--size) solid var(--color-theme-1);
content: "";
}

nav a {
display: flex;
align-items: center;
padding: 0 0.5rem;
height: 100%;
font-size: 0.8rem;
font-weight: 700;
letter-spacing: 0.1em;
text-decoration: none;
text-transform: uppercase;
color: var(--color-text);
transition: color 0.2s linear;
}

a:hover {
color: var(--color-theme-1);
}
69 changes: 1 addition & 68 deletions src/routes/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,77 +44,10 @@

<style
lang="css">
header {
display: flex;
justify-content: space-between;
}
@import "Header.css";
.corner {
width: 6em;
height: 6em;
}
nav {
display: flex;
justify-content: center;
--background: rgba(255, 255, 255, 0.7);
}
svg {
display: block;
width: 2em;
height: 3em;
}
path {
fill: var(--background);
}
ul {
list-style: none;
position: relative;
display: flex;
justify-content: center;
align-items: center;
margin: 0;
padding: 0;
height: 3em;
background-size: contain;
background: var(--background);
}
li {
position: relative;
height: 100%;
}
li[aria-current="page"]::before {
position: absolute;
top: 0;
left: calc(50% - var(--size));
--size: 6px;
width: 0;
height: 0;
border: var(--size) solid transparent;
border-top: var(--size) solid var(--color-theme-1);
content: "";
}
nav a {
display: flex;
align-items: center;
padding: 0 0.5rem;
height: 100%;
font-size: 0.8rem;
font-weight: 700;
letter-spacing: 0.1em;
text-decoration: none;
text-transform: uppercase;
color: var(--color-text);
transition: color 0.2s linear;
}
a:hover {
color: var(--color-theme-1);
}
</style>
24 changes: 24 additions & 0 deletions src/routes/Socials.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
menu {
list-style: none;
position: relative;
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: center;
align-items: center;
gap: 2.4rem;
margin: 0;
padding: 0;
}

li {
flex: 0 0 auto;
width: 2.4rem;
height: 2.4rem;
}

menu img {
height: 100%;
aspect-ratio: 1/1;
object-fit: cover;
}
28 changes: 3 additions & 25 deletions src/routes/Socials.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -92,33 +92,11 @@

<style
lang="css">
div.socials {
display: flex;
justify-content: space-between;
}
@import "Socials.css";
menu {
list-style: none;
position: relative;
.socials {
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: center;
align-items: center;
gap: 2.4rem;
margin: 0;
padding: 0;
}
li {
flex: 0 0 auto;
width: 2.4rem;
height: 2.4rem;
justify-content: space-between;
}
menu img {
height: 100%;
aspect-ratio: 1/1;
object-fit: cover;
}
</style>
File renamed without changes.

0 comments on commit 297e84b

Please sign in to comment.