File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ import kebabCase from ' lodash.kebabcase'
3+
4+ export interface Props {
5+ difficulty: string
6+ }
7+
8+ const { difficulty } = Astro .props
9+ const difficultyStyleMap: Record <string , string > = {
10+ Easy: ' difficulty-easy' ,
11+ Medium: ' difficulty-medium' ,
12+ Hard: ' difficulty-hard' ,
13+ }
14+
15+ const getDifficultyCssClass: (difficulty : string ) => string = (
16+ difficulty : string
17+ ) => {
18+ return Object .keys (difficultyStyleMap ).includes (difficulty )
19+ ? difficultyStyleMap [difficulty ] || ' '
20+ : ' '
21+ }
22+ ---
23+
24+ <a
25+ href ={ ` /difficulties/${kebabCase (difficulty )} ` }
26+ class:list ={ [' px-2 py-1' , getDifficultyCssClass (difficulty )]}
27+ >
28+ { difficulty }
29+ </a >
30+
31+ <style lang =" scss" >
32+ $difficulties: 'easy', 'medium', 'hard';
33+
34+ @each $difficulty in $difficulties {
35+ .difficulty-#{$difficulty} {
36+ @apply bg-difficulty-#{$difficulty};
37+ @apply border-2;
38+ @apply border-difficulty-#{$difficulty};
39+ @apply text-difficulty-#{$difficulty};
40+ @apply hover:bg-transparent;
41+ @apply hover:border-difficulty-#{$difficulty}-hover;
42+ @apply hover:text-difficulty-#{$difficulty}-hover;
43+ }
44+ }
45+ </style >
You can’t perform that action at this time.
0 commit comments