1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-04 18:19:54 +00:00

Categories: Style the categories card

This commit is contained in:
Timur Ismagilov 2022-03-22 16:40:40 +03:00
parent eb88cbf23e
commit 81c075bfb4
6 changed files with 69 additions and 26 deletions

View File

@ -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;
}
/*

View File

@ -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

View File

@ -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
}{

View File

@ -10,16 +10,16 @@
<input type="hidden" name="cat" value="{{.}}">
<input type="hidden" name="hypha" value="{{$hyphaName}}">
<input type="hidden" name="redirect-to" value="/hypha/{{$hyphaName}}">
<input type="submit" value="X">
<input type="submit" value="x" class="btn categories-card__btn">
</form>
</li>
{{end}}
<li class="categories-card__entry categories-card__add-to-cat">
<form method="POST" action="/add-to-category" class="categories-card__add-form">
<input type="text" name="cat" id="_cat-name" placeholder="Category name">
<input type="text" name="cat" id="_cat-name" placeholder="Category name...">
<input type="hidden" name="hypha" value="{{$hyphaName}}">
<input type="hidden" name="redirect-to" value="/hypha/{{$hyphaName}}">
<input type="submit" value="Add to category">
<input type="submit" class="btn categories-card__btn" value="+">
</form>
</li>
</ul>
@ -45,7 +45,7 @@
placeholder="{{block `hypha name` .}}Hypha name{{end}}">
<input type="hidden" name="cat" value="{{$catName}}">
<input type="hidden" name="redirect-to" value="/category/{{$catName}}">
<input type="submit" value="{{block `add hypha` .}}Add to the category{{end}}">
<input type="submit" class="btn" value="{{block `add hypha` .}}Add to the category{{end}}">
</form>
</li>
</ul>

View File

@ -77,7 +77,7 @@
<div class="dialog__content"></div>
</div>
</template>
{%= CommonScripts() %}
{%= commonScripts() %}
<script src="/static/view.js"></script>
</body>
</html>
@ -173,7 +173,7 @@
</div>
{% endfunc %}
{% func CommonScripts() %}
{% func commonScripts() %}
{% for _, scriptPath := range cfg.CommonScripts %}
<script src="{%s scriptPath %}"></script>
{% endfor %}

View File

@ -215,7 +215,7 @@ func StreamBase(qw422016 *qt422016.Writer, title, body string, lc *l18n.Localize
</template>
`)
//line views/stuff.qtpl:80
StreamCommonScripts(qw422016)
streamcommonScripts(qw422016)
//line views/stuff.qtpl:80
qw422016.N().S(`
<script src="/static/view.js"></script>
@ -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