@@ -11,26 +11,44 @@ const usePkgName = useState('badge-use-name', () => false)
1111const badgeStyle = useState (' badge-style' , () => ' default' )
1212
1313const types = [
14- ' version' , ' license' , ' size' , ' downloads' , ' downloads-day' ,
15- ' downloads-week' , ' downloads-month' , ' downloads-year' ,
16- ' vulnerabilities' , ' dependencies' , ' created' , ' updated' ,
17- ' engines' , ' types' , ' maintainers' , ' deprecated' ,
18- ' quality' , ' popularity' , ' maintenance' , ' score' , ' name' ,
14+ ' version' ,
15+ ' license' ,
16+ ' size' ,
17+ ' downloads' ,
18+ ' downloads-day' ,
19+ ' downloads-week' ,
20+ ' downloads-month' ,
21+ ' downloads-year' ,
22+ ' vulnerabilities' ,
23+ ' dependencies' ,
24+ ' created' ,
25+ ' updated' ,
26+ ' engines' ,
27+ ' types' ,
28+ ' maintainers' ,
29+ ' deprecated' ,
30+ ' quality' ,
31+ ' popularity' ,
32+ ' maintenance' ,
33+ ' score' ,
34+ ' name' ,
1935]
2036
2137const styles = [' default' , ' shieldsio' ]
2238
23- const validateHex = ( hex ) => {
39+ const validateHex = hex => {
2440 if (! hex) return true
2541 const clean = hex .replace (' #' , ' ' )
2642 return / ^ [0-9A-F ] {3} $ / i .test (clean) || / ^ [0-9A-F ] {6} $ / i .test (clean)
2743}
2844
2945const isLabelHexValid = computed (() => validateHex (labelColor .value ))
3046const isBadgeHexValid = computed (() => validateHex (badgeColor .value ))
31- const isInputValid = computed (() => isLabelHexValid .value && isBadgeHexValid .value && pkg .value .length > 0 )
47+ const isInputValid = computed (
48+ () => isLabelHexValid .value && isBadgeHexValid .value && pkg .value .length > 0 ,
49+ )
3250
33- const cleanHex = ( hex ) => hex? .replace (' #' , ' ' ) || ' '
51+ const cleanHex = hex => hex? .replace (' #' , ' ' ) || ' '
3452
3553const queryParams = computed (() => {
3654 if (! isInputValid .value ) return ' '
@@ -71,11 +89,14 @@ const copyToClipboard = async () => {
7189< / script>
7290
7391< template>
74- < div class = " my-8 p-5 rounded-xl border border-gray-200/60 dark:border-white/5 bg-gray-50/50 dark:bg-white/2 flex flex-col gap-6" >
75-
92+ < div
93+ class = " my-8 p-5 rounded-xl border border-gray-200/60 dark:border-white/5 bg-gray-50/50 dark:bg-white/2 flex flex-col gap-6"
94+ >
7695 < div class = " flex flex-col lg:flex-row items-end gap-4" >
7796 < div class = " flex flex-col gap-1.5 flex-1 w-full" >
78- < label class = " text-[11px] font-bold uppercase tracking-wider text-gray-400 ml-1" > Package Name< / label>
97+ < label class = " text-[11px] font-bold uppercase tracking-wider text-gray-400 ml-1"
98+ > Package Name< / label
99+ >
79100 < input
80101 v- model= " pkg"
81102 type= " text"
@@ -85,19 +106,32 @@ const copyToClipboard = async () => {
85106 < / div>
86107
87108 < div class = " flex flex-col gap-1.5 flex-1 w-full" >
88- < label class = " text-[11px] font-bold uppercase tracking-wider text-gray-400 ml-1" > Badge Type< / label>
109+ < label class = " text-[11px] font-bold uppercase tracking-wider text-gray-400 ml-1"
110+ > Badge Type< / label
111+ >
89112 < div class = " relative" >
90- < select v- model= " type" class = " w-full h-10.5 px-4 py-2 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-black/20 focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-500 outline-none text-sm transition-all appearance-none cursor-pointer" >
113+ < select
114+ v- model= " type"
115+ class = " w-full h-10.5 px-4 py-2 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-black/20 focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-500 outline-none text-sm transition-all appearance-none cursor-pointer"
116+ >
91117 < option v- for = " t in types" : key= " t" : value= " t" class = " dark:bg-gray-900" > {{ t }}< / option>
92118 < / select>
93- < span class = " absolute right-3 top-1/2 -translate-y-1/2 i-lucide-chevron-down w-4 h-4 text-gray-400 pointer-events-none" / >
119+ < span
120+ class = " absolute right-3 top-1/2 -translate-y-1/2 i-lucide-chevron-down w-4 h-4 text-gray-400 pointer-events-none"
121+ / >
94122 < / div>
95123 < / div>
96124
97125 < div class = " flex flex-col gap-1.5 flex-2 w-full" >
98- < label class = " text-[11px] font-bold uppercase tracking-wider text-gray-400 ml-1" > Preview & Action< / label>
99- < div class = " flex items-center bg-white dark:bg-black/20 border border-gray-200 dark:border-white/10 rounded-lg h-10.5 overflow-hidden" >
100- < div class = " flex-1 flex items-center justify-center px-3 border-r border-gray-200 dark:border-white/10 h-full bg-gray-50/10 dark:bg-transparent" >
126+ < label class = " text-[11px] font-bold uppercase tracking-wider text-gray-400 ml-1"
127+ > Preview & Action< / label
128+ >
129+ < div
130+ class = " flex items-center bg-white dark:bg-black/20 border border-gray-200 dark:border-white/10 rounded-lg h-10.5 overflow-hidden"
131+ >
132+ < div
133+ class = " flex-1 flex items-center justify-center px-3 border-r border-gray-200 dark:border-white/10 h-full bg-gray-50/10 dark:bg-transparent"
134+ >
101135 < img
102136 v- if = " isValid && isInputValid"
103137 : src= " badgeUrl"
@@ -113,7 +147,11 @@ const copyToClipboard = async () => {
113147 @click= " copyToClipboard"
114148 : disabled= " !isValid || !isInputValid"
115149 class = " px-6 h-full text-[11px] font-bold uppercase tracking-widest transition-all disabled:opacity-20 disabled:cursor-not-allowed min-w-24 hover:bg-gray-50 dark:hover:bg-white/5"
116- : class = " copied ? 'text-emerald-500 bg-emerald-50/50 dark:bg-emerald-500/10' : 'text-gray-500 dark:text-gray-400'"
150+ : class = "
151+ copied
152+ ? 'text-emerald-500 bg-emerald-50/50 dark:bg-emerald-500/10'
153+ : 'text-gray-500 dark:text-gray-400'
154+ "
117155 >
118156 {{ copied ? ' Done!' : ' Copy' }}
119157 < / button>
@@ -124,11 +162,12 @@ const copyToClipboard = async () => {
124162 < div class = " h-px bg-gray-200 dark:bg-white/5 w-full" / >
125163
126164 < div class = " grid grid-cols-1 sm:grid-cols-3 gap-6" >
127-
128165 < div class = " flex flex-col gap-1.5" >
129166 < div class = " flex items-center justify-between min-h-3.75" >
130167 < label class = " text-[10px] font-bold uppercase text-gray-400 ml-1" > Label Text < / label>
131- < span v- if = " usePkgName" class = " text-[9px] text-emerald-500 font-medium transition-opacity" > Auto- Name Enabled< / span>
168+ < span v- if = " usePkgName" class = " text-[9px] text-emerald-500 font-medium transition-opacity"
169+ > Auto- Name Enabled< / span
170+ >
132171 < / div>
133172 < input
134173 v- model= " labelText"
@@ -144,41 +183,76 @@ const copyToClipboard = async () => {
144183 < label class = " text-[10px] font-bold uppercase text-gray-400 ml-1" > Label Color< / label>
145184 < div
146185 class = " flex items-center px-3 rounded-lg border bg-white dark:bg-black/20 transition-all"
147- : class = " isLabelHexValid ? 'border-gray-200 dark:border-white/10 focus-within:border-emerald-500' : 'border-red-500 ring-1 ring-red-500/20'"
186+ : class = "
187+ isLabelHexValid
188+ ? 'border-gray-200 dark:border-white/10 focus-within:border-emerald-500'
189+ : 'border-red-500 ring-1 ring-red-500/20'
190+ "
148191 >
149192 < span class = " text-gray-400 text-xs font-mono mr-1" > #< / span>
150- < input v- model= " labelColor" type= " text" placeholder= " 0a0a0a" class = " w-full py-2 bg-transparent text-xs outline-none" / >
151- < span v- if = " !isLabelHexValid" class = " i-lucide-alert-circle w-3.5 h-3.5 text-red-500 ml-1" / >
193+ < input
194+ v- model= " labelColor"
195+ type= " text"
196+ placeholder= " 0a0a0a"
197+ class = " w-full py-2 bg-transparent text-xs outline-none"
198+ / >
199+ < span
200+ v- if = " !isLabelHexValid"
201+ class = " i-lucide-alert-circle w-3.5 h-3.5 text-red-500 ml-1"
202+ / >
152203 < / div>
153204 < / div>
154205
155206 < div class = " flex flex-col gap-1.5" >
156207 < label class = " text-[10px] font-bold uppercase text-gray-400 ml-1" > Badge Color< / label>
157208 < div
158209 class = " flex items-center px-3 rounded-lg border bg-white dark:bg-black/20 transition-all"
159- : class = " isBadgeHexValid ? 'border-gray-200 dark:border-white/10 focus-within:border-emerald-500' : 'border-red-500 ring-1 ring-red-500/20'"
210+ : class = "
211+ isBadgeHexValid
212+ ? 'border-gray-200 dark:border-white/10 focus-within:border-emerald-500'
213+ : 'border-red-500 ring-1 ring-red-500/20'
214+ "
160215 >
161216 < span class = " text-gray-400 text-xs font-mono mr-1" > #< / span>
162- < input v- model= " badgeColor" type= " text" placeholder= " ff69b4" class = " w-full py-2 bg-transparent text-xs outline-none" / >
163- < span v- if = " !isBadgeHexValid" class = " i-lucide-alert-circle w-3.5 h-3.5 text-red-500 ml-1" / >
217+ < input
218+ v- model= " badgeColor"
219+ type= " text"
220+ placeholder= " ff69b4"
221+ class = " w-full py-2 bg-transparent text-xs outline-none"
222+ / >
223+ < span
224+ v- if = " !isBadgeHexValid"
225+ class = " i-lucide-alert-circle w-3.5 h-3.5 text-red-500 ml-1"
226+ / >
164227 < / div>
165228 < / div>
166229 < / div>
167230
168- < div class = " flex flex-col sm:flex-row sm:items-center justify-between gap-4 pt-4 border-t border-gray-200/50 dark:border-white/5" >
231+ < div
232+ class = " flex flex-col sm:flex-row sm:items-center justify-between gap-4 pt-4 border-t border-gray-200/50 dark:border-white/5"
233+ >
169234 < label class = " relative inline-flex items-center cursor-pointer group" >
170- < input v- model= " usePkgName" type= " checkbox" class = " sr-only peer" >
171- < div class = " w-9 h-5 bg-gray-200 peer-focus:outline-none dark:bg-white/10 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-0.5 after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-emerald-500 rounded-full" >< / div>
172- < span class = " ml-3 text-[10px] font-bold uppercase text-gray-400 group-hover:text-gray-600 dark:group-hover:text-gray-300 transition-colors" > Use package name as label< / span>
235+ < input v- model= " usePkgName" type= " checkbox" class = " sr-only peer" / >
236+ < div
237+ class = " w-9 h-5 bg-gray-200 peer-focus:outline-none dark:bg-white/10 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-0.5 after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-emerald-500 rounded-full"
238+ >< / div>
239+ < span
240+ class = " ml-3 text-[10px] font-bold uppercase text-gray-400 group-hover:text-gray-600 dark:group-hover:text-gray-300 transition-colors"
241+ > Use package name as label< / span
242+ >
173243 < / label>
174244
175245 < div class = " flex items-center gap-3" >
176- < label class = " text-[10px] font-bold uppercase text-gray-400 whitespace-nowrap" > Badge Style< / label>
177- < select v- model= " badgeStyle" class = " min-w-30 px-3 py-1.5 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-black/20 text-xs outline-none cursor-pointer hover:border-emerald-500 transition-colors" >
246+ < label class = " text-[10px] font-bold uppercase text-gray-400 whitespace-nowrap"
247+ > Badge Style< / label
248+ >
249+ < select
250+ v- model= " badgeStyle"
251+ class = " min-w-30 px-3 py-1.5 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-black/20 text-xs outline-none cursor-pointer hover:border-emerald-500 transition-colors"
252+ >
178253 < option v- for = " s in styles" : key= " s" : value= " s" > {{ s }}< / option>
179254 < / select>
180255 < / div>
181256 < / div>
182-
183257 < / div>
184258< / template>
0 commit comments