-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathchip.templ
117 lines (114 loc) · 3.16 KB
/
chip.templ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package components
type ChipProps struct {
Label string
Icon string
ClassName string
Variant string
}
/**
* Chip Component.
*
* @author: github.com/tego101 <-> x.com/tegodotdev
* @license: MIT
* =====================
* This component renders a chip element based on the provided properties.
*
* @params ChipProps
* @property {string} Label - The label text displayed inside the chip.
* @property {string} Icon - The icon displayed inside the chip.
* @property {string} ClassName - Additional CSS classes to apply to the chip.
* @property {string} Variant - The variant of the chip (filled, gradient, outlined, ghost, etc.).
*
* Usage:
*
* Filled Chip:
* @components.Chip(components.ChipProps{
* Label: "Filled Chip",
* Icon: "🌟",
* ClassName: "custom-class",
* Variant: "filled",
* })
*
* Gradient Chip:
* @components.Chip(components.ChipProps{
* Label: "Gradient Chip",
* Icon: "🔥",
* ClassName: "custom-class",
* Variant: "gradient",
* })
*
* Outlined Chip:
* @components.Chip(components.ChipProps{
* Label: "Outlined Chip",
* Icon: "✏️",
* ClassName: "custom-class",
* Variant: "outlined",
* })
*
* Ghost Chip:
* @components.Chip(components.ChipProps{
* Label: "Ghost Chip",
* Icon: "👻",
* ClassName: "custom-class",
* Variant: "ghost",
* })
*/
templ Chip(chip ChipProps) {
switch chip.Variant {
case "filled":
<div
class={ "relative grid select-none items-center whitespace-nowrap rounded-lg bg-gray-900 py-1.5 px-3 font-sans text-xs font-bold uppercase text-white" + chip.ClassName }
>
if chip.Icon != "" {
<span class="mr-1">
@templ.Raw(chip.Icon)
</span>
}
<span class="">{ chip.Label }</span>
</div>
case "gradient":
<div
class={ "relative grid select-none items-center whitespace-nowrap rounded-lg bg-gradient-to-tr from-gray-900 to-gray-800 py-1.5 px-3 font-sans text-xs font-bold uppercase text-white" + chip.ClassName }
>
if chip.Icon != "" {
<span class="mr-1">
@templ.Raw(chip.Icon)
</span>
}
<span class="">{ chip.Label }</span>
</div>
case "outlined":
<div
class={ "relative grid select-none items-center whitespace-nowrap rounded-lg border border-gray-900 py-1.5 px-3 font-sans text-xs font-bold uppercase text-gray-700" + chip.ClassName }
>
if chip.Icon != "" {
<span class="mr-1">
@templ.Raw(chip.Icon)
</span>
}
<span class="">{ chip.Label }</span>
</div>
case "ghost":
<div
class={ "relative grid select-none items-center whitespace-nowrap rounded-lg bg-transparent py-1.5 px-3 font-sans text-xs font-bold uppercase text-gray-700" + chip.ClassName }
>
if chip.Icon != "" {
<span class="mr-1">
@templ.Raw(chip.Icon)
</span>
}
<span class="">{ chip.Label }</span>
</div>
default:
<div
class={ "relative grid select-none items-center whitespace-nowrap rounded-lg bg-[#FAF7F5] dark:bg-slate-100 py-1.5 px-3 font-sans text-xs font-bold uppercase dark:text-slate-800" + chip.ClassName }
>
if chip.Icon != "" {
<span class="mr-1">
@templ.Raw(chip.Icon)
</span>
}
<span class="">{ chip.Label }</span>
</div>
}
}