From 81c075bfb4a24fabfa9ce2f3a0ad6265d1e47fe6 Mon Sep 17 00:00:00 2001 From: Timur Ismagilov Date: Tue, 22 Mar 2022 16:40:40 +0300 Subject: [PATCH] Categories: Style the categories card --- static/default.css | 38 ++++++++++++++++++++++++++++++++++---- views/base.go | 4 ++++ views/categories.go | 29 +++++++++++++++++++---------- views/categories.html | 8 ++++---- views/stuff.qtpl | 4 ++-- views/stuff.qtpl.go | 12 ++++++------ 6 files changed, 69 insertions(+), 26 deletions(-) diff --git a/static/default.css b/static/default.css index d5f3565..63568d1 100644 --- a/static/default.css +++ b/static/default.css @@ -239,6 +239,7 @@ blockquote { border-left: 2px #999 solid; } .prevnext { border-top: #eee 1px solid; } td { border: #ddd 1px solid; } +.categories-card__link:hover, .sibling-hyphae__link:hover { background-color: #eee; } /* Dark theme! */ @@ -249,7 +250,10 @@ main, article, header, .layout-card { background-color: #343434; color: #ddd; } a, .wikilink_external { color: #f1fa8c; } a:visited, .wikilink_external:visited { color: #ffb86c; } .wikilink_new, .wikilink_new:visited { color: #dd4444; } -.subhyphae__link:hover, .sibling-hyphae__link:hover { background-color: #444; } + +.categories-card__link:hover, +.subhyphae__link:hover, +.sibling-hyphae__link:hover { background-color: #444; } .prevnext__el, .prevnext__el:visited { color: #ddd; } @@ -279,10 +283,36 @@ mark { background: rgba(130, 80, 30, 5); color: inherit; } * Categories */ .categories-card__entries { - padding-left: 1rem; + padding: 0; + margin: 0; } -.categories-card__remove-form { - float: right; +.categories-card__entry { + display: flex; +} +.categories-card__link { + display: inline-block; + text-decoration: none; + padding: .25rem .5rem; + flex: 9; +} +.categories-card__add-to-cat { + width: 100%; +} +.categories-card__add-form { + width: 100%; + display: flex; +} +.categories-card .categories-card__btn { + display: block; + flex: 1; + border: none; + background: none; +} +.categories-card #_cat-name { + width: 100%; + margin: 0; + padding: 0 .5rem; + border: none; } /* diff --git a/views/base.go b/views/base.go index b45a6d4..df5464c 100644 --- a/views/base.go +++ b/views/base.go @@ -1,6 +1,7 @@ package views import ( + "embed" "github.com/bouncepaw/mycorrhiza/l18n" "github.com/bouncepaw/mycorrhiza/user" "io" @@ -23,3 +24,6 @@ func MetaFrom(w http.ResponseWriter, rq *http.Request) Meta { W: w, } } + +//go:embed *.html +var fs embed.FS diff --git a/views/categories.go b/views/categories.go index ec79639..117235c 100644 --- a/views/categories.go +++ b/views/categories.go @@ -1,7 +1,6 @@ package views import ( - "embed" "github.com/bouncepaw/mycorrhiza/hyphae/categories" "github.com/bouncepaw/mycorrhiza/util" "html/template" @@ -10,9 +9,6 @@ import ( "strings" ) -//go:embed categories.html -var fs embed.FS - const categoriesRu = ` {{define "empty cat"}}Эта категория пуста.{{end}} {{define "add hypha"}}Добавить в категорию{{end}} @@ -31,12 +27,17 @@ func init() { template.FuncMap{ "beautifulName": util.BeautifulName, }). - ParseFS(fs, "*")) + ParseFS(fs, "categories.html")) } func categoryCard(hyphaName string) string { var buf strings.Builder - err := categoryT.ExecuteTemplate(&buf, "category card", struct { + t, err := categoryT.Clone() + if err != nil { + log.Println(err) + return "" + } + err = t.ExecuteTemplate(&buf, "category card", struct { HyphaName string Categories []string }{ @@ -51,11 +52,19 @@ func categoryCard(hyphaName string) string { func CategoryPage(meta Meta, catName string) { var buf strings.Builder - var t, _ = categoryT.Clone() - if meta.Lc.Locale == "ru" { - _, _ = t.Parse(categoriesRu) + var t, err = categoryT.Clone() + if err != nil { + log.Println(err) + return } - err := t.ExecuteTemplate(&buf, "category page", struct { + if meta.Lc.Locale == "ru" { + _, err = t.Parse(categoriesRu) + if err != nil { + log.Println(err) + return + } + } + err = t.ExecuteTemplate(&buf, "category page", struct { CatName string Hyphae []string }{ diff --git a/views/categories.html b/views/categories.html index 6eac0fe..e8b4a99 100644 --- a/views/categories.html +++ b/views/categories.html @@ -10,16 +10,16 @@ - + {{end}}
  • - + - +
  • @@ -45,7 +45,7 @@ placeholder="{{block `hypha name` .}}Hypha name{{end}}"> - + diff --git a/views/stuff.qtpl b/views/stuff.qtpl index 79fba7a..3c164d5 100644 --- a/views/stuff.qtpl +++ b/views/stuff.qtpl @@ -77,7 +77,7 @@
    - {%= CommonScripts() %} + {%= commonScripts() %} @@ -173,7 +173,7 @@ {% endfunc %} -{% func CommonScripts() %} +{% func commonScripts() %} {% for _, scriptPath := range cfg.CommonScripts %} {% endfor %} diff --git a/views/stuff.qtpl.go b/views/stuff.qtpl.go index 8c53fd2..ee439b0 100644 --- a/views/stuff.qtpl.go +++ b/views/stuff.qtpl.go @@ -215,7 +215,7 @@ func StreamBase(qw422016 *qt422016.Writer, title, body string, lc *l18n.Localize `) //line views/stuff.qtpl:80 - StreamCommonScripts(qw422016) + streamcommonScripts(qw422016) //line views/stuff.qtpl:80 qw422016.N().S(` @@ -618,7 +618,7 @@ func HyphaList(lc *l18n.Localizer) string { } //line views/stuff.qtpl:176 -func StreamCommonScripts(qw422016 *qt422016.Writer) { +func streamcommonScripts(qw422016 *qt422016.Writer) { //line views/stuff.qtpl:176 qw422016.N().S(` `) @@ -641,22 +641,22 @@ func StreamCommonScripts(qw422016 *qt422016.Writer) { } //line views/stuff.qtpl:180 -func WriteCommonScripts(qq422016 qtio422016.Writer) { +func writecommonScripts(qq422016 qtio422016.Writer) { //line views/stuff.qtpl:180 qw422016 := qt422016.AcquireWriter(qq422016) //line views/stuff.qtpl:180 - StreamCommonScripts(qw422016) + streamcommonScripts(qw422016) //line views/stuff.qtpl:180 qt422016.ReleaseWriter(qw422016) //line views/stuff.qtpl:180 } //line views/stuff.qtpl:180 -func CommonScripts() string { +func commonScripts() string { //line views/stuff.qtpl:180 qb422016 := qt422016.AcquireByteBuffer() //line views/stuff.qtpl:180 - WriteCommonScripts(qb422016) + writecommonScripts(qb422016) //line views/stuff.qtpl:180 qs422016 := string(qb422016.B) //line views/stuff.qtpl:180