~hokiegeek/tw5-location-crafts

ref: ee4641e7f6e49f768f111760424c9fd5ffd13a81 tw5-location-crafts/macros.tid -rw-r--r-- 5.6 KiB
ee4641e7HokieGeek Improves how elements are defined 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
modified: 20220217125223000
created: 20220214180052000
creator: hokiegeek
title: $:/plugins/hokiegeek/location-crafts/macros
tags: $:/tags/Macro
type: text/vnd.tiddlywiki

<!--
how to mark uniques?
and how to mark them off?
-->

\define category-list(type)
<div class="category-list">
    <$let special-elements-default="expected none custom random special"
          special-elements-locations={{{ [<special-elements-default>addsuffix[ complete]] }}}
          special-elements-encounters=<<special-elements-default>>
          special-elements-objects=<<special-elements-default>>
          categoryState={{{ [{!!title}slugify[]addprefix[$:/state/location-crafts/]] }}}>
    <div class="header-button">
        <h1 style="text-transform: capitalize;">$type$</h1>
        <$button setTitle=<<categoryState>> setField=$type$ setTo="visible" tooltip="Add $type$" aria-label="Add $type$" class="tc-btn-invisible tc-btn-mini">
            {{$:/core/images/new-button}}
        </$button>
    </div>
    <div style="display: grid; width: fit-content;">
        <div style="grid-column-start: 1; font-size: .8rem; margin-right: .5rem;">
            Progress points:
        </div>
        <div style="grid-column-start: 2">
            <$reveal type="gt" stateTitle=<<currentTiddler>> stateField="crafted-$type$-points" text="0">
            <$let next-points={{{ [<currentTiddler>get[crafted-$type$-points]subtract[1]] }}}>
            <$button setTitle=<<currentTiddler>> setField=crafted-$type$-points setTo=<<next-points>> tooltip="remove progress points" aria-label="remove progress points" class="tc-btn-invisible tc-btn-mini">
                {{$:/core/images/minus-button}}
            </$button>
            </$let>
            </$reveal>
            <$list filter="[<currentTiddler>get[crafted-$type$-points]else[0]compare:integer:lteq[0]]">
            <span class="btn-disabled">
                {{$:/core/images/minus-button}}
            </span>
            </$list>
        </div>
        <div style="grid-column-start: 3; padding-left: 0.5rem; padding-right: 0.5rem;">
        <$list filter="[<currentTiddler>get[crafted-$type$-points]else[0]]">
        <<currentTiddler>>
        </$list>
        </div>
        <div style="grid-column-start: 4">
            <$let next-points={{{ [<currentTiddler>get[crafted-$type$-points]else[0]add[1]] }}}>
            <$button setTitle=<<currentTiddler>> setField=crafted-$type$-points setTo=<<next-points>> tooltip="add progress points" aria-label="add progress points" class="tc-btn-invisible tc-btn-mini">
                {{$:/core/images/plus-button}}
            </$button>
            </$let>
        </div>
    </div>
    <ol>
        <$list filter="[<currentTiddler>get[crafted-$type$]enlist-input:raw[]]" variable="element" counter="counter" emptyMessage="no $type$ setup">
        <li>
            <$list filter="[<special-elements-$type$>enlist-input:raw[]match<element>]">
            <<element>>
            </$list>
            <$list filter="[<special-elements-$type$>enlist-input:raw[]match<element>then[found]else[]remove[found]]">
            <$link to=<<element>>><<element>></$link>
            </$list>
            <!--
            <$let prev={{{ [<counter>subtract[1]] }}}
                  last={{{ [<currentTiddler>get[crafted-$type$]enlist-input:raw[]rest<counter>join[ ]] }}}
                  newlist={{{ [<currentTiddler>get[crafted-$type$]enlist-input:raw[]first<prev>append<last>join[ ]] }}}>
            <$button setTitle=<<categoryState>> setField=$type$ setTo="hidden" tooltip="use unique" aria-label="use unique" class="tc-btn-invisible tc-btn-mini btn-close">
                <$action-setfield $tiddler=<<me>> $field="crafted-$type$" $value=<<newlist>> />
                {{$:/core/images/erase}}
            </$button>
            </$let>
            -->
        </li>
        </$list>
        <$reveal type="match" stateTitle=<<categoryState>> stateField=$type$ text="visible">
        <li>
        <div style="display: grid; width: fit-content;">
            <div style="grid-row-start: 1; grid-column-start: 1; padding-right: .3rem;">
            <$edit-text tiddler=<<categoryState>> field="custom-$type$" focus="true" />
            </div>
            <div style="grid-row-start: 1; grid-column-start: 2; padding-right: .2rem;">
            <$button setTitle=<<categoryState>> setField=$type$ setTo="hidden" tooltip="submit" aria-label="submit" class="tc-btn-invisible tc-btn-mini">
                <$action-listops $field="crafted-$type$" $filter="[<currentTiddler>get[crafted-$type$]enlist-input:raw[]] =[<categoryState>get[custom-$type$]]" />
                <$action-setfield $tiddler=<<categoryState>> $field="custom-$type$" $value="" />
                {{$:/core/images/done-button}}
            </$button>
            </div>
            <div style="grid-row-start: 1; grid-column-start: 3;">
            <$button setTitle=<<categoryState>> setField=$type$ setTo="hidden" tooltip="cancel" aria-label="cancel" class="tc-btn-invisible tc-btn-mini">
                <$action-setfield $tiddler=<<categoryState>> $field="custom-$type$" $value="" />
                {{$:/core/images/close-button}}
            </$button>
            </div>
            <div style="grid-row-start: 2">
                <$list filter="[<special-elements-$type$>enlist-input[]]">
                <$button setTitle=<<categoryState>> setField="custom-$type$" setTo=<<currentTiddler>> class="tc-btn-invisible tc-tiddlylink">
                <<currentTiddler>>
                </$button>
                <br />
                </$list>
            </div>
        </div>
        </li>
        </$reveal>
    </ol>
    </$let>
</div>
\end