Skip to content

Commit d9d3137

Browse files
authored
refactor: BEM convention with scss (#370)
1 parent 61d9913 commit d9d3137

File tree

10 files changed

+206
-214
lines changed

10 files changed

+206
-214
lines changed

src/lib/components/header.svelte

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
const { right_nav }: Props = $props();
1010
</script>
1111

12-
<header>
13-
<nav>
12+
<header class="header">
13+
<nav class="header__nav">
1414
<span>Products <coreicons-shape-chevron variant="down"></coreicons-shape-chevron></span>
1515
<span class="disabled">Blog</span>
1616
</nav>
17-
<a href="/" class="coreproject-icon">
18-
<Coreproject style="width: 8rem;" />
17+
<a href="/" class="header__icon">
18+
<Coreproject />
1919
</a>
20-
<nav>
20+
<nav class="header__nav">
2121
{@render right_nav?.()}
2222
<a href="https://github.com/coreproject-moe" target="_blank">
2323
<coreicons-logo-github></coreicons-logo-github>
@@ -26,8 +26,8 @@
2626
</nav>
2727
</header>
2828

29-
<style>
30-
header {
29+
<style lang="scss">
30+
.header {
3131
display: flex;
3232
align-items: center;
3333
justify-content: space-between;
@@ -46,25 +46,26 @@
4646
padding-inline: 5rem;
4747
}
4848
49-
.coreproject-icon {
49+
&__icon {
5050
display: none;
5151
position: absolute;
5252
left: 50%;
5353
transform: translateX(-50%);
54+
width: 8rem;
5455
5556
@media (width >= 40rem) {
5657
display: block;
5758
}
5859
}
5960
60-
nav {
61+
&__nav {
6162
display: flex;
6263
align-items: center;
6364
gap: 2rem;
6465
color: var(--color-info);
6566
font-weight: 600;
6667
67-
& * {
68+
& > * {
6869
display: flex;
6970
align-items: center;
7071
gap: 0.5rem;

src/lib/components/highlight.svelte

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/lib/components/ui/toast/toaster.svelte

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,25 @@
66

77
<div class="toaster">
88
{#each toasts_store.value as toast (toast.id)}
9-
<div animate:flip={{ duration: 300 }} transition:fly={{ y: 5 }} class="toast">
9+
<div animate:flip={{ duration: 300 }} transition:fly={{ y: 5 }} class="toaster__toast">
1010
{#if toast.icon}
1111
{@html toast.icon}
1212
{:else}
1313
<coreicons-shape-info></coreicons-shape-info>
1414
{/if}
15-
<span>{toast.message}</span>
16-
<button aria-label="Close toast" onclick={() => toasts_store.dismiss(toast.id)}>
15+
<span class="toaster__toast-message">{toast.message}</span>
16+
<button
17+
aria-label="Close toast"
18+
class="toaster__toast-close-btn"
19+
onclick={() => toasts_store.dismiss(toast.id)}
20+
>
1721
<coreicons-shape-x variant="no-border"></coreicons-shape-x>
1822
</button>
1923
</div>
2024
{/each}
2125
</div>
2226

23-
<style>
27+
<style lang="scss">
2428
.toaster {
2529
position: fixed;
2630
bottom: 1rem;
@@ -33,7 +37,7 @@
3337
gap: 0.5rem;
3438
align-items: center;
3539
36-
.toast {
40+
&__toast {
3741
background-color: var(--color-neutral);
3842
height: 3rem;
3943
padding-inline: 1rem;
@@ -44,11 +48,11 @@
4448
gap: 0.5rem;
4549
color: var(--color-info);
4650
47-
span {
51+
&-message {
4852
font-weight: 600;
4953
}
5054
51-
button {
55+
&-close-btn {
5256
font-size: 0.75rem;
5357
}
5458
}

src/routes/+layout.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import Toaster from "$lib/components/ui/toast/toaster.svelte";
3-
import "../styles/global.css";
3+
import "../styles/global.scss";
44
import { defineCustomElements } from "@coreproject-moe/icons/loader";
55
let { children } = $props();
66

0 commit comments

Comments
 (0)