|
1 | 1 | <script lang="ts"> |
2 | | - import type { createEmptySlangProject, ISlangProject } from "$lib/EntryData"; |
3 | | - import { scale } from 'svelte/transition'; |
4 | | - import { expoInOut } from 'svelte/easing'; |
5 | | - const {num, SlangProject} = $props(); |
| 2 | + import type { |
| 3 | + createEmptySlangProject, |
| 4 | + ISlangProject, |
| 5 | + } from "$lib/EntryData"; |
| 6 | + import { scale } from "svelte/transition"; |
| 7 | + import { expoInOut } from "svelte/easing"; |
| 8 | + import { onMount } from "svelte"; |
6 | 9 |
|
| 10 | + const { num, SlangProject } = $props(); |
7 | 11 |
|
| 12 | + //======================== |
| 13 | + // TODO: refactor this to be reusable, it is also in the header component |
| 14 | + let darkMode = $state(); |
| 15 | + onMount(() => { |
| 16 | + darkMode = window.matchMedia("(prefers-color-scheme: dark)").matches; |
| 17 | + window |
| 18 | + .matchMedia("(prefers-color-scheme: dark)") |
| 19 | + .addListener(function (e) { |
| 20 | + console.log(`changed to ${e.matches ? "dark" : "light"} mode`); |
| 21 | + if (e.matches) { |
| 22 | + darkMode = true; |
| 23 | + } else { |
| 24 | + darkMode = false; |
| 25 | + } |
| 26 | + }); |
| 27 | + }); |
8 | 28 | </script> |
9 | 29 |
|
10 | | -<div transition:scale={{duration: 220, delay:20, easing: expoInOut}} class=" flex bg-white border-1 border-zinc-200 p-4 lg:p-2 flex-col duration-120 rounded-2xl shadow-xl w-full lg:mx-0 "> |
11 | | -<div class="px-2 w-full flex flex-row items-center justify-between"> |
12 | | - <div class="flex flex-col wrap flex-1 min-w-0"> |
13 | | - <div class="w-full"> |
14 | | - <div class="overflow-x-auto whitespace-nowrap w-full no-scrollbar"> |
15 | | - <h1 class="font-chivo font-semibold text-2xl inline-block">{SlangProject.name}</h1> |
| 30 | +<div |
| 31 | + transition:scale={{ duration: 220, delay: 20, easing: expoInOut }} |
| 32 | + class=" flex bg-white dark:bg-zinc-900 border-1 border-zinc-200 dark:border-zinc-900 p-4 lg:p-2 flex-col duration-120 rounded-2xl shadow-xl w-full lg:mx-0" |
| 33 | +> |
| 34 | + <div class="px-2 w-full flex flex-row items-center justify-between"> |
| 35 | + <div class="flex flex-col wrap flex-1 min-w-0"> |
| 36 | + <div class="w-full"> |
| 37 | + <div |
| 38 | + class="overflow-x-auto whitespace-nowrap w-full no-scrollbar" |
| 39 | + > |
| 40 | + <h1 |
| 41 | + class="font-chivo dark:text-white font-semibold text-2xl inline-block" |
| 42 | + > |
| 43 | + {SlangProject.name} |
| 44 | + </h1> |
| 45 | + </div> |
16 | 46 | </div> |
| 47 | + <p class="text-s text-zinc-400 dark:text-zinc-200"> |
| 48 | + by: {SlangProject.authorName} |
| 49 | + </p> |
| 50 | + </div> |
| 51 | + <div class="h-7 w-7 lg:h-8 lg:w-8 flex-shrink-0 justify-end m-2"> |
| 52 | + <a |
| 53 | + target="_blank" |
| 54 | + rel="noopener noreferrer" |
| 55 | + class="h-full w-full" |
| 56 | + href={SlangProject.ghLink} |
| 57 | + > |
| 58 | + <img |
| 59 | + alt="github" |
| 60 | + class="hover:scale-110 duration-100 h-full w-full" |
| 61 | + src={darkMode |
| 62 | + ? "svg/github-light.svg" |
| 63 | + : "svg/github-cyan.svg"} |
| 64 | + /> |
| 65 | + </a> |
17 | 66 | </div> |
18 | | - <p class="text-s text-zinc-400">by: {SlangProject.authorName}</p> |
19 | | - </div> |
20 | | - <div class="h-7 w-7 lg:h-8 lg:w-8 flex-shrink-0 justify-end m-2"> |
21 | | - <a target="_blank" rel="noopener noreferrer" class="h-full w-full" href={SlangProject.ghLink}> |
22 | | - <img alt="github" class="hover:scale-110 duration-100 h-full w-full" src="svg/github-cyan.svg"> |
23 | | - </a> |
24 | 67 | </div> |
25 | | -</div> |
26 | | - <div class="w-1/3 ml-2 mt-2 h-1 {num %2 == 0 ? " bg-amber-500" : "bg-teal-700" } "></div> |
27 | | - <div class ="mx-2 mt-4 overflow-hidden overflow-y-scroll m-2 font-chivo font-light lg:h-80 h-80 text-sm lg:text-lg"> |
28 | | - <p class=" font-bold">Description:</p> |
29 | | - <div class="text-lg "> |
| 68 | + <div |
| 69 | + class="w-1/3 ml-2 mt-2 h-1 {num % 2 == 0 |
| 70 | + ? ' bg-amber-500' |
| 71 | + : 'bg-teal-700'} " |
| 72 | + ></div> |
| 73 | + <div |
| 74 | + class="mx-2 mt-4 overflow-hidden overflow-y-scroll m-2 font-chivo font-light lg:h-80 h-80 text-sm lg:text-lg" |
| 75 | + > |
| 76 | + <p class=" font-bold dark:text-white">Description:</p> |
| 77 | + <div class="dark:text-white text-lg"> |
30 | 78 | {SlangProject.description} |
31 | 79 | </div> |
32 | 80 | </div> |
33 | 81 |
|
34 | | - <p class=" ml-2 font-bold mt-2">Tags:</p> |
| 82 | + <p class=" ml-2 font-bold dark:text-white mt-2">Tags:</p> |
35 | 83 |
|
36 | | - <div class = "w-full mt-1 h-30 gap-3 grid grid-cols-3 overflow-auto grid-rows-3"> |
37 | | - {#each SlangProject.tags as tag, i } |
38 | | - <button class=" justify-around {num%2 == 0 ? "bg-amber-600 text-white" : " bg-teal-700 text-white" } p-1 shadow-md rounded-2xl h-8" >{tag}</button> |
39 | | - {/each} |
| 84 | + <div |
| 85 | + class="w-full mt-1 h-30 gap-3 grid grid-cols-3 overflow-auto grid-rows-3" |
| 86 | + > |
| 87 | + {#each SlangProject.tags as tag, i} |
| 88 | + <button |
| 89 | + class=" justify-around {num % 2 == 0 |
| 90 | + ? 'bg-amber-600 text-white' |
| 91 | + : ' bg-teal-700 text-white'} p-1 shadow-md rounded-2xl h-8" |
| 92 | + >{tag}</button |
| 93 | + > |
| 94 | + {/each} |
40 | 95 | </div> |
41 | | - |
42 | 96 | </div> |
0 commit comments