add filter elements to page

This commit is contained in:
Rhiannon Morris 2020-08-03 23:10:52 +02:00
parent 3c77492294
commit ac73c80ea6
3 changed files with 99 additions and 0 deletions

View file

@ -43,6 +43,26 @@ make' title prefix nsfw infos = [b|@0
</h2> </h2>
</header> </header>
<form id=filters>
<details>
<summary><h2>filters</h2></summary>
<div>
<h3>show only</h3>
<ul id=require class='buttonbar choice'>
$8.requireFilters
</ul>
<h3>exclude</h3>
<ul id=exclude class='buttonbar choice'>
$8.excludeFilters
</ul>
<a href=# id=clear>clear</a>
<a href=# id=reset>reset</a>
</div>
</details>
</form>
<main> <main>
<ul class=grid> <ul class=grid>
$4.items $4.items
@ -70,6 +90,14 @@ make' title prefix nsfw infos = [b|@0
requireFilters = map (uncurry $ makeFilter "require") allTags requireFilters = map (uncurry $ makeFilter "require") allTags
excludeFilters = map (uncurry $ makeFilter "exclude") allTags excludeFilters = map (uncurry $ makeFilter "exclude") allTags
makeFilter :: Text -> Text -> Int -> Builder
makeFilter prefix tag count = [b|@8
<li>
<input type=checkbox id="$id'" value="$*tag">
<label for="$id'">$*tag</label>
|]
where id' = [b|$*prefix$&_$tag'|]; tag' = escId tag
makeYearItems :: Bool -- ^ nsfw makeYearItems :: Bool -- ^ nsfw
-> Integer -- ^ year -> Integer -- ^ year
-> [(FilePath, Info)] -> [(FilePath, Info)]

View file

@ -148,6 +148,16 @@ footer {
} }
summary h1, summary h2, summary h3, summary h4 {
display: inline;
}
summary:focus-within {
outline: none;
color: var(--focus-text);
}
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
:root { :root {
--gradient: --gradient:

View file

@ -11,6 +11,67 @@ body {
padding-right: 4em; padding-right: 4em;
} }
#filters div {
display: grid;
grid-template-columns: 15% auto;
align-items: baseline;
grid-gap: 0.5em 0.75em;
margin: 1em 0 2em 0;
}
#filters h3, #filters div > a {
font-weight: 100;
font-size: 110%;
margin: 0;
}
#filters h3 {
text-align: right;
grid-area: auto / 1;
}
#clear {
text-align: right;
}
#reset {
text-align: left;
}
#filters ul {
font-weight: 400;
font-size: 90%;
margin: 0;
border-radius: 0.5em;
border: 1px solid var(--text-col);
overflow: hidden;
background: var(--text-col);
grid-gap: 1px;
}
#filters ul:focus-within {
box-shadow: var(--focus-box);
}
#filters li {
margin: 0;
flex-grow: 1;
}
#filters li:focus-within {
color: var(--focus-text);
}
#filters label {
display: block;
margin: 0;
border-radius: 0;
padding: 0.15em 0.5em;
text-align: center;
border: none;
box-shadow: none;
}
.grid { .grid {
padding: 0; padding: 0;
display: grid; display: grid;