|
1 | | -<script> |
| 1 | +<script lang="ts"> |
| 2 | + interface IconData { |
| 3 | + paths: string[]; |
| 4 | + } |
| 5 | + |
2 | 6 | export let warning = false; |
3 | | - const color = warning ? "orange" : "green"; |
| 7 | + const color: 'orange' | 'green' = warning ? "orange" : "green"; |
| 8 | + |
| 9 | + // Icon paths |
| 10 | + const WarningIcon: IconData = { |
| 11 | + paths: [ |
| 12 | + "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3", |
| 13 | + "M12 9v4", |
| 14 | + "M12 17h.01" |
| 15 | + ] |
| 16 | + }; |
| 17 | + |
| 18 | + const TipIcon: IconData = { |
| 19 | + paths: [ |
| 20 | + "M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5", |
| 21 | + "M9 18h6", |
| 22 | + "M10 22h4" |
| 23 | + ] |
| 24 | + }; |
| 25 | + |
| 26 | + const iconPaths = warning ? WarningIcon.paths : TipIcon.paths; |
4 | 27 | </script> |
5 | 28 |
|
6 | | -<!-- For tailwind: |
7 | | - border-green-50 text-green-700 from-green-50 dark:from-green-900 before:border-green-500 dark:before:border-green-800 |
8 | | - border-orange-50 text-orange-700 from-orange-50 dark:from-orange-900 before:border-orange-500 dark:before:border-orange-800 |
9 | | ---> |
10 | | - |
11 | 29 | <div |
12 | | - class="course-tip {color === 'orange' |
13 | | - ? 'course-tip-orange' |
14 | | - : ''} bg-gradient-to-br dark:bg-gradient-to-r before:border-{color}-500 dark:before:border-{color}-800 from-{color}-50 border to-white dark:from-gray-900 dark:to-gray-950 border-{color}-50 text-{color}-700 dark:text-gray-400" |
| 30 | + class="course-tip {color === 'orange' ? 'course-tip-orange' : ''} bg-gradient-to-br dark:bg-gradient-to-r border to-white dark:from-gray-900 dark:to-gray-950 dark:text-gray-400 {color === 'orange' ? 'from-orange-50 border-orange-50 text-orange-700 before:border-orange-500 dark:before:border-orange-800' : 'from-green-50 border-green-50 text-green-700 before:border-green-500 dark:before:border-green-800'}" |
15 | 31 | > |
16 | | - <div class="flex items-center gap-2"> |
17 | | - {#if warning} |
18 | | - <svg |
19 | | - xmlns="http://www.w3.org/2000/svg" |
20 | | - width="20" |
21 | | - height="20" |
22 | | - viewBox="0 0 24 24" |
23 | | - fill="none" |
24 | | - stroke="currentColor" |
25 | | - stroke-width="2" |
26 | | - stroke-linecap="round" |
27 | | - stroke-linejoin="round" |
28 | | - class="-mt-0.5 h-4 w-4 flex-shrink-0" |
29 | | - ><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" /><path |
30 | | - d="M12 9v4" |
31 | | - /><path d="M12 17h.01" /></svg |
32 | | - > |
33 | | - {:else} |
34 | | - <svg |
35 | | - xmlns="http://www.w3.org/2000/svg" |
36 | | - width="20" |
37 | | - height="20" |
38 | | - viewBox="0 0 24 24" |
39 | | - fill="none" |
40 | | - stroke="currentColor" |
41 | | - stroke-width="2" |
42 | | - stroke-linecap="round" |
43 | | - stroke-linejoin="round" |
44 | | - class="-mt-0.5 h-4 w-4 flex-shrink-0" |
45 | | - ><path |
46 | | - d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5" |
47 | | - /><path d="M9 18h6" /><path d="M10 22h4" /></svg |
48 | | - > |
49 | | - {/if} |
50 | | - <div class="flex-1"> |
| 32 | + <div class="flex items-baseline gap-2"> |
| 33 | + <svg |
| 34 | + xmlns="http://www.w3.org/2000/svg" |
| 35 | + width="20" |
| 36 | + height="20" |
| 37 | + viewBox="0 0 24 24" |
| 38 | + fill="none" |
| 39 | + stroke="currentColor" |
| 40 | + stroke-width="2" |
| 41 | + stroke-linecap="round" |
| 42 | + stroke-linejoin="round" |
| 43 | + class="h-4 w-4 flex-shrink-0 transform translate-y-0.5" |
| 44 | + > |
| 45 | + {#each iconPaths as path} |
| 46 | + <path d={path} /> |
| 47 | + {/each} |
| 48 | + </svg> |
| 49 | + <div class="flex-1 mt-0.5"> |
51 | 50 | <slot /> |
52 | 51 | </div> |
53 | 52 | </div> |
|
0 commit comments