@@ -86,6 +86,18 @@ func StartProgressBar(uid, progress string) string {
86
86
).Render ()
87
87
}
88
88
89
+ func cardSpan (text , icon string ) elem.Node {
90
+ return elem .Span (
91
+ attrs.Props {
92
+ "class" : "inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2" ,
93
+ },
94
+ elem .I (attrs.Props {
95
+ "class" : icon + " pr-2" ,
96
+ }),
97
+ elem .Text (text ),
98
+ )
99
+ }
100
+
89
101
func ListModels (models []* gallery.GalleryModel ) string {
90
102
modelsElements := []elem.Node {}
91
103
span := func (s string ) elem.Node {
@@ -99,10 +111,17 @@ func ListModels(models []*gallery.GalleryModel) string {
99
111
installButton := func (m * gallery.GalleryModel ) elem.Node {
100
112
return elem .Button (
101
113
attrs.Props {
102
- "class" : "float-right inline-block rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong" ,
114
+ "data-twe-ripple-init" : "" ,
115
+ "data-twe-ripple-color" : "light" ,
116
+ "class" : "float-right inline-block rounded bg-primary px-6 pb-2.5 mb-3 pt-2.5 text-xs font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong" ,
103
117
// post the Model ID as param
104
118
"hx-post" : "/browse/install/model/" + fmt .Sprintf ("%s@%s" , m .Gallery .Name , m .Name ),
105
119
},
120
+ elem .I (
121
+ attrs.Props {
122
+ "class" : "fa-solid fa-download pr-2" ,
123
+ },
124
+ ),
106
125
elem .Text ("Install" ),
107
126
)
108
127
}
@@ -111,7 +130,7 @@ func ListModels(models []*gallery.GalleryModel) string {
111
130
112
131
return elem .Div (
113
132
attrs.Props {
114
- "class" : "p-6" ,
133
+ "class" : "p-6 text-surface dark:text-white " ,
115
134
},
116
135
elem .H5 (
117
136
attrs.Props {
@@ -129,42 +148,93 @@ func ListModels(models []*gallery.GalleryModel) string {
129
148
}
130
149
131
150
actionDiv := func (m * gallery.GalleryModel ) elem.Node {
151
+ nodes := []elem.Node {
152
+ cardSpan ("Repository: " + m .Gallery .Name , "fa-brands fa-git-alt" ),
153
+ }
154
+
155
+ if m .License != "" {
156
+ nodes = append (nodes ,
157
+ cardSpan ("License: " + m .License , "fas fa-book" ),
158
+ )
159
+ }
160
+
161
+ for _ , tag := range m .Tags {
162
+ nodes = append (nodes ,
163
+ cardSpan (tag , "fas fa-tag" ),
164
+ )
165
+ }
166
+
167
+ for i , url := range m .URLs {
168
+ nodes = append (nodes ,
169
+ elem .A (
170
+ attrs.Props {
171
+ "class" : "inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2" ,
172
+ "href" : url ,
173
+ "target" : "_blank" ,
174
+ },
175
+ elem .I (attrs.Props {
176
+ "class" : "fas fa-link pr-2" ,
177
+ }),
178
+ elem .Text ("Link #" + fmt .Sprintf ("%d" , i + 1 )),
179
+ ))
180
+ }
181
+
132
182
return elem .Div (
133
183
attrs.Props {
134
184
"class" : "px-6 pt-4 pb-2" ,
135
185
},
136
- elem .Span (
186
+ elem .P (
137
187
attrs.Props {
138
- "class" : "inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2 " ,
188
+ "class" : "mb-4 text-base " ,
139
189
},
140
- elem . Text ( "Repository: " + m . Gallery . Name ) ,
190
+ nodes ... ,
141
191
),
142
192
elem .If (m .Installed , span ("Installed" ), installButton (m )),
143
193
)
144
194
}
145
195
146
196
for _ , m := range models {
197
+
198
+ elems := []elem.Node {}
199
+
200
+ if m .Icon != "" {
201
+ elems = append (elems ,
202
+
203
+ elem .Div (attrs.Props {
204
+ "class" : "flex justify-center items-center" ,
205
+ },
206
+ elem .A (attrs.Props {
207
+ "href" : "#!" ,
208
+ // "class": "justify-center items-center",
209
+ },
210
+ elem .Img (attrs.Props {
211
+ // "class": "rounded-t-lg object-fit object-center h-96",
212
+ "class" : "rounded-t-lg max-h-48 max-w-96 object-cover" ,
213
+ "src" : m .Icon ,
214
+ }),
215
+ ),
216
+ ))
217
+ }
218
+
219
+ elems = append (elems , descriptionDiv (m ), actionDiv (m ))
147
220
modelsElements = append (modelsElements ,
148
221
elem .Div (
149
222
attrs.Props {
150
- "class" : "me-4 mb-2 block rounded-lg bg-white shadow-secondary-1 dark:bg-gray-800 dark:bg-surface-dark dark:text-white text-surface p -2" ,
223
+ "class" : " me-4 mb-2 block rounded-lg bg-white shadow-secondary-1 dark:bg-gray-800 dark:bg-surface-dark dark:text-white text-surface pb -2" ,
151
224
},
152
225
elem .Div (
153
226
attrs.Props {
154
- "class" : "p-6" ,
227
+ // "class": "p-6",
155
228
},
156
- descriptionDiv (m ),
157
- actionDiv (m ),
158
- // elem.If(m.Installed, span("Installed"), installButton(m)),
159
-
160
- // elem.If(m.Installed, span("Installed"), span("Not Installed")),
229
+ elems ... ,
161
230
),
162
231
),
163
232
)
164
233
}
165
234
166
235
wrapper := elem .Div (attrs.Props {
167
- "class" : "dark grid grid-cols-1 grid-rows-1 md:grid-cols-2 " ,
236
+ "class" : "dark grid grid-cols-1 grid-rows-1 md:grid-cols-3 block rounded-lg shadow-secondary-1 dark:bg-surface-dark" ,
237
+ //"class": "block rounded-lg bg-white shadow-secondary-1 dark:bg-surface-dark",
168
238
}, modelsElements ... )
169
239
170
240
return wrapper .Render ()
0 commit comments