Added slim select widget support

This commit is contained in:
roberto 2024-09-10 15:58:20 +02:00
parent 6523c2aed6
commit 584c6aaa8f
9 changed files with 36 additions and 6 deletions

View File

@ -228,7 +228,7 @@ textarea {
html, html,
body { body {
font-family: Verdana, sans-serif; font-family: Verdana, sans-serif;
font-size: 16px; font-size: 15px;
line-height: 1.5 line-height: 1.5
} }
@ -463,7 +463,7 @@ a {
} }
.w3-input { .w3-input {
padding: 8px; padding: 2px;
display: block; display: block;
border: none; border: none;
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
@ -2425,6 +2425,14 @@ table.stickyheader.searchopened thead {
border-color: #777; border-color: #777;
} }
.ss-main .ss-values .ss-value .ss-value-text {
font-size: 15px;
}
.ss-main .ss-values .ss-value {
background-color: #2b5797;
}
/* Small */ /* Small */
@media (max-width:600px) { @media (max-width:600px) {
i { i {

File diff suppressed because one or more lines are too long

View File

@ -194,7 +194,14 @@ document.addEventListener("DOMContentLoaded", function(event){
document.body.addEventListener("activateEasyMDE", function(evt){ document.body.addEventListener("activateEasyMDE", function(evt){
const easyMDE = new EasyMDE({element: document.getElementById(evt.detail.value), forceSync: true}); const easyMDE = new EasyMDE({element: document.getElementById(evt.detail.value), forceSync: true});
}); });
new SlimSelect({select: '.slim-select'});
htmx.on('htmx:afterSettle', (event) => {
new SlimSelect({select: '.slim-select'});
});
}); });
function bm_ignoreSwipe(event) { function bm_ignoreSwipe(event) {

View File

@ -1,4 +1,4 @@
const cacheVersion = "0.267" const cacheVersion = "0.271"
const cacheName = "speedtech-brainminder" const cacheName = "speedtech-brainminder"
const cacheFiles = [ const cacheFiles = [
'/static/bootstrap-icons/font/bootstrap-icons.min.css', '/static/bootstrap-icons/font/bootstrap-icons.min.css',
@ -6,6 +6,7 @@ const cacheFiles = [
'/static/bootstrap-icons/font/fonts/bootstrap-icons.woff2', '/static/bootstrap-icons/font/fonts/bootstrap-icons.woff2',
'/static/bootstrap-icons/*.svg', '/static/bootstrap-icons/*.svg',
"/static/easymde/easymde.min.css", "/static/easymde/easymde.min.css",
'/static/css/slimselect.css',
'/static/css/main.css', '/static/css/main.css',
'/static/img/brainminder.svg', '/static/img/brainminder.svg',
'/static/img/brainminder-icon.svg', '/static/img/brainminder-icon.svg',
@ -15,6 +16,7 @@ const cacheFiles = [
"/static/js/hyperscript.min.js", "/static/js/hyperscript.min.js",
"/static/js/handlebars.js", "/static/js/handlebars.js",
"/static/js/templates.js", "/static/js/templates.js",
"/static/js/slimselect.min.js",
'/static/js/main.js', '/static/js/main.js',
] ]

1
assets/static/js/slimselect.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -11,6 +11,7 @@
<link rel="manifest" href="/static/manifest.json"> <link rel="manifest" href="/static/manifest.json">
<link rel="stylesheet" href="/static/bootstrap-icons/font/bootstrap-icons.min.css" /> <link rel="stylesheet" href="/static/bootstrap-icons/font/bootstrap-icons.min.css" />
<link rel="stylesheet" href="/static/easymde/easymde.min.css" /> <link rel="stylesheet" href="/static/easymde/easymde.min.css" />
<link rel="stylesheet" href="/static/css/slimselect.css" />
<link rel="stylesheet" href="/static/css/main.css" /> <link rel="stylesheet" href="/static/css/main.css" />
<link rel="icon" type="image/svg+xml" href="/static/img/brainminder-icon.svg"> <link rel="icon" type="image/svg+xml" href="/static/img/brainminder-icon.svg">

View File

@ -104,7 +104,7 @@
</div> </div>
<div class="w3-half"> <div class="w3-half">
<p> <p>
{{ widget_select "Categories" "Categories" .item.Categories .categories `multiple="true" class="w3-input w3-border"` }} {{ widget_slim_select "Categories" "Categories" .item.Categories .categories `multiple="true" class="w3-input w3-border"` }}
</p> </p>
</div> </div>
</div> </div>

View File

@ -5,5 +5,6 @@
<script src="/static/js/hyperscript.min.js"></script> <script src="/static/js/hyperscript.min.js"></script>
<script src="/static/js/handlebars.js"></script> <script src="/static/js/handlebars.js"></script>
<script src="/static/js/templates.js"></script> <script src="/static/js/templates.js"></script>
<script src="/static/js/slimselect.min.js"></script>
<script src="/static/js/main.js"></script> <script src="/static/js/main.js"></script>
{{end}} {{end}}

View File

@ -76,6 +76,7 @@ var TemplateFuncs = template.FuncMap{
"widget_relation_type": widget_relation_type, "widget_relation_type": widget_relation_type,
"widget_text": widget_text, "widget_text": widget_text,
"widget_select": widget_select, "widget_select": widget_select,
"widget_slim_select": widget_slim_select,
"widget_checkboxes": widget_checkboxes, "widget_checkboxes": widget_checkboxes,
"field_widget": field_widget, "field_widget": field_widget,
@ -350,6 +351,14 @@ func widget_relation_type(name string, value string, attributes string) template
} }
func widget_select(name string, label string, value any, options []WidgetOption, attributes string) template.HTML { func widget_select(name string, label string, value any, options []WidgetOption, attributes string) template.HTML {
return render_select(name, label, value, options, attributes, "w3-input w3-border")
}
func widget_slim_select(name string, label string, value any, options []WidgetOption, attributes string) template.HTML {
return render_select(name, label, value, options, attributes, "slim-select w3-border")
}
func render_select(name string, label string, value any, options []WidgetOption, attributes string, classes string) template.HTML {
var values []string var values []string
switch v := value.(type) { switch v := value.(type) {
@ -373,7 +382,7 @@ func widget_select(name string, label string, value any, options []WidgetOption,
if len(label) > 0 { if len(label) > 0 {
o = fmt.Sprintf(`<label for="%v">%v</label>`, name, label) o = fmt.Sprintf(`<label for="%v">%v</label>`, name, label)
} }
o = o + fmt.Sprintf(`<select name="%v" id="%v" class="w3-input w3-border" %v>`, name, name, attributes) o = o + fmt.Sprintf(`<select name="%v" id="%v" class="%v" %v>`, name, name, classes, attributes)
selected := "" selected := ""
for _, option := range options { for _, option := range options {
selected = "" selected = ""