Commit 89658f9e88208096af0770fc6f691ff668a73c0b
Merge branch 'branch-front-end' into 'master'
Branch front end See merge request zachmandeville/dat-zine-library!3zach mandeville committed on 7/8/2018, 7:15:50 AM
Parent: 84e7089dcecb5f534a64c17d398045e5425f2550
Parent: 7c481dbee0cd1b97f72d740e58d70abb9a6533ff
Files changed
building/aesthetic/stylesheets/main.css | ||
---|---|---|
@@ -1,14 +1,63 @@ | ||
1 | 1 … | body{ |
2 … | + margin-bottom: 1em; | |
2 | 3 … | font-family: var(--primary-text); |
3 | 4 … | background: var(--background-color); |
4 | 5 … | color: var(--text); |
5 | 6 … | padding: 0; |
6 | 7 … | margin: 0; |
7 | 8 … | box-sizing: border-box; |
8 | 9 … | } |
9 | 10 … | |
11 … | +#placard-form{ | |
12 … | + box-shadow: -1px 2px 8px grey inset; | |
13 … | + position: absolute; | |
14 … | + width: 100%; | |
15 … | + z-index: 0; | |
16 … | + height: 100%; | |
17 … | + padding-left: 0; | |
18 … | + margin-left: 0; | |
19 … | + background: var(--new-branch-form-bg); | |
20 … | + display: flex; | |
21 … | + flex-direction: column; | |
22 … | + justify-content: center; | |
23 … | +} | |
10 | 24 … | |
25 … | +#placard-form label{ | |
26 … | + margin-bottom: 0; | |
27 … | + text-align: left; | |
28 … | +} | |
29 … | +#placard-form input{ | |
30 … | + width: auto; | |
31 … | +} | |
32 … | + | |
33 … | +#placard-form textarea{ | |
34 … | + margin-left: 1em; | |
35 … | + margin-top: -1em; | |
36 … | + width: 80%; | |
37 … | + background-color: peachpuff; | |
38 … | + outline-width: 0; | |
39 … | + border: none; | |
40 … | + font-size: 1em; | |
41 … | +} | |
42 … | + | |
43 … | +#placard-form input[type=submit]{ | |
44 … | + box-shadow: -1px -1px 8px grey inset; | |
45 … | +} | |
46 … | + | |
47 … | +#placard-form-close{ | |
48 … | + position: absolute; | |
49 … | + right: 1em; | |
50 … | + top: 0; | |
51 … | + cursor: pointer; | |
52 … | +} | |
53 … | + | |
54 … | +#placard-form-close:hover{ | |
55 … | + color: teal; | |
56 … | +} | |
57 … | + | |
58 … | + | |
59 … | + | |
11 | 60 … | #zine-shelves{ |
12 | 61 … | display: grid; |
13 | 62 … | width: 80%; |
14 | 63 … | margin: auto; |
@@ -17,11 +66,14 @@ | ||
17 | 66 … | grid-gap: 2em; |
18 | 67 … | } |
19 | 68 … | |
20 | 69 … | #branch-placard{ |
21 | - margin: 0.5em; | |
70 … | + position: relative; | |
71 … | + height: 40vh; | |
22 | 72 … | width: 50%; |
23 | 73 … | text-align: justify; |
74 … | + margin-top: 1em; | |
75 … | + margin-bottom: 1em; | |
24 | 76 … | } |
25 | 77 … | |
26 | 78 … | #branch-placard h1{ |
27 | 79 … | font-family: arial; |
@@ -92,8 +144,15 @@ | ||
92 | 144 … | background-color: var(--add-button-bg); |
93 | 145 … | color: var(--new-zine-form-text); |
94 | 146 … | } |
95 | 147 … | |
148 … | +#edit-form-button{ | |
149 … | + border-radius: 0px; | |
150 … | + font-size: 0.5em; | |
151 … | + background-color: var(--add-button-bg); | |
152 … | + color: var(--new-zine-form-text); | |
153 … | +} | |
154 … | + | |
96 | 155 … | #add-button:hover{ |
97 | 156 … | background-color: var(--add-button-hover); |
98 | 157 … | color: indigo; |
99 | 158 … | } |
@@ -108,25 +167,31 @@ | ||
108 | 167 … | color: var(--branch-button-text); |
109 | 168 … | } |
110 | 169 … | |
111 | 170 … | .form-card{ |
112 | - position: fixed; | |
113 | - z-index: 1; | |
114 | - right: -60%; | |
115 | - width: 40%; | |
116 | 171 … | display: flex; |
117 | 172 … | flex-direction: column; |
118 | 173 … | justify-content: space-between; |
119 | 174 … | align-items: left; |
120 | - border: 1px outset gray; | |
121 | - box-shadow: -2px 4px 20px 6px var(--new-branch-form-shadow); | |
122 | 175 … | } |
123 | 176 … | |
124 | 177 … | #new-branch-form.form-card{ |
178 … | + border: 1px outset gray; | |
179 … | + box-shadow: -2px 4px 20px 6px var(--new-branch-form-shadow); | |
180 … | + position: fixed; | |
181 … | + z-index: 1; | |
182 … | + right: -60%; | |
183 … | + width: 40%; | |
125 | 184 … | background: var(--new-branch-form-bg); |
126 | 185 … | color: var(--new-branch-form-text);; |
127 | 186 … | } |
128 | 187 … | #new-zine-form.form-card{ |
188 … | + border: 1px outset gray; | |
189 … | + box-shadow: -2px 4px 20px 6px var(--new-branch-form-shadow); | |
190 … | + position: fixed; | |
191 … | + z-index: 1; | |
192 … | + right: -60%; | |
193 … | + width: 40%; | |
129 | 194 … | background: var(--new-zine-form-bg); |
130 | 195 … | color: var(--new-zine-form-text);; |
131 | 196 … | } |
132 | 197 … | |
@@ -203,12 +268,30 @@ | ||
203 | 268 … | .revealed { |
204 | 269 … | right: 0 !important; |
205 | 270 … | } |
206 | 271 … | |
272 … | +#placard{ | |
273 … | + position: absolute; | |
274 … | + z-index: 2; | |
275 … | + background: var(--background-color); | |
276 … | + left: 0; | |
277 … | + padding-left: 1em; | |
278 … | + height: 100%; | |
279 … | +} | |
280 … | + | |
281 … | +.hidden{ | |
282 … | + position: absolute; | |
283 … | + left: -1000% !important; | |
284 … | +} | |
285 … | + | |
207 | 286 … | .transition { |
208 | 287 … | transition: right 0.3s ease-in; |
209 | 288 … | } |
210 | 289 … | |
290 … | +.transition-left { | |
291 … | + transition: left 1s ease-in-out; | |
292 … | +} | |
293 … | + | |
211 | 294 … | .details{ |
212 | 295 … | background: var(--details-bg); |
213 | 296 … | display: flex; |
214 | 297 … | flex-direction: column; |
building/components/actionButtons.js | ||
---|---|---|
@@ -1,7 +1,7 @@ | ||
1 | 1 … | const html = require('nanohtml') |
2 | 2 … | |
3 | -module.exports = { addZine, makeBranch } | |
3 … | +module.exports = { addZine, makeBranch, editDetails, placardClose } | |
4 | 4 … | |
5 | 5 … | function addZine (state) { |
6 | 6 … | if (state.identity === 'librarian') { |
7 | 7 … | return html` |
@@ -15,8 +15,29 @@ | ||
15 | 15 … | <button id='branch-button' onclick=${toggleBranch}>Make A New Branch</button> |
16 | 16 … | ` |
17 | 17 … | } |
18 | 18 … | |
19 … | +function editDetails (id) { | |
20 … | + if (id === 'librarian') { | |
21 … | + console.log('librarian!') | |
22 … | + return html`<button id='edit-form-button' onclick=${placardOpen}>edit</button>` | |
23 … | + } else { | |
24 … | + console.log('hi friend') | |
25 … | + } | |
26 … | + | |
27 … | + function placardOpen () { | |
28 … | + var placard = document.querySelector('#placard') | |
29 … | + var form = document.querySelector('#placard-form') | |
30 … | + placard.classList.add('hidden') | |
31 … | + } | |
32 … | +} | |
33 … | + | |
34 … | +function placardClose () { | |
35 … | + var placard = document.querySelector('#placard') | |
36 … | + var form = document.querySelector('#placard-form') | |
37 … | + placard.classList.remove('hidden') | |
38 … | +} | |
39 … | + | |
19 | 40 … | function toggleForm () { |
20 | 41 … | var addButton = document.getElementById('add-button') |
21 | 42 … | var form = document.getElementById('new-zine-form') |
22 | 43 … | |
@@ -28,8 +49,10 @@ | ||
28 | 49 … | addButton.textContent = 'close' |
29 | 50 … | } |
30 | 51 … | } |
31 | 52 … | |
53 … | + | |
54 … | + | |
32 | 55 … | function toggleBranch () { |
33 | 56 … | var branchButton = document.querySelector('#branch-button') |
34 | 57 … | var form = document.querySelector('#new-branch-form') |
35 | 58 … |
building/components/branchPlacard.js | ||
---|---|---|
@@ -2,22 +2,25 @@ | ||
2 | 2 … | const raw = require('nanohtml/raw') |
3 | 3 … | const md = require('markdown-it')() |
4 | 4 … | |
5 | 5 … | const button = require('./actionButtons') |
6 … | +const editForm = require('./branchPlacardForm') | |
6 | 7 … | |
7 | 8 … | module.exports = view |
8 | 9 … | |
9 | 10 … | function view (state, emit) { |
10 | - if (state.branch.title) { | |
11 … | + if (state.branch.name) { | |
11 | 12 … | var branch = state.branch |
12 | - console.log({branch}) | |
13 | 13 … | return html` |
14 | 14 … | <section id='branch-placard'> |
15 | - <h1>${branch.title}</h1> | |
15 … | + <div id='placard' class='transition-left'> | |
16 … | + <h1>${branch.name} ${button.editDetails(state.identity)}</h1> | |
16 | 17 … | ${render(branch.description)} |
17 | 18 … | <p>Want to start your own zine library?<span> ${button.makeBranch()}</span></p> |
19 … | + </div> | |
20 … | + ${editForm(state, emit)} | |
18 | 21 … | </section> |
19 | - ` | |
22 … | + ` | |
20 | 23 … | } else { |
21 | 24 … | return html`<h1>loading</h1>` |
22 | 25 … | } |
23 | 26 … | } |
building/components/branchPlacardForm.js | ||
---|---|---|
@@ -1,0 +1,26 @@ | ||
1 … | +const html = require('nanohtml') | |
2 … | + | |
3 … | +const button = require('./actionButtons') | |
4 … | + | |
5 … | +module.exports = (state, emit) => { | |
6 … | + var branch = state.branch | |
7 … | + if (state.branch.name) { | |
8 … | + return html` | |
9 … | + <div id='placard-form' class='form-card'> | |
10 … | + <h1>Library Details</h1> | |
11 … | + <p id='placard-form-close' onclick=${button.placardClose}>close</p> | |
12 … | + <form onsubmit=${updateBranch}> | |
13 … | + <label for='branch name'>Branch Name:<input type='text' name='name' value=${branch.name} /></label> | |
14 … | + <label for='branch description'>description:</label><textarea name='description' value=${branch.description}/>${branch.description}</textarea> | |
15 … | + <input type='submit' /> | |
16 … | + </form> | |
17 … | + </div> | |
18 … | + ` | |
19 … | + } | |
20 … | + | |
21 … | + function updateBranch (e) { | |
22 … | + e.preventDefault() | |
23 … | + var form = e.currentTarget | |
24 … | + emit('branch updated', form) | |
25 … | + } | |
26 … | +} |
volunteers/displayBranchInfo.js | ||
---|---|---|
@@ -1,17 +1,32 @@ | ||
1 | 1 … | const smarkt = require('smarkt') |
2 | 2 … | |
3 … | +const formHandler = require('./formHandler') | |
4 … | + | |
3 | 5 … | var archive = new DatArchive(window.location) |
4 | 6 … | |
5 | 7 … | function store (state, emitter) { |
6 | 8 … | state.branch = {} |
7 | 9 … | emitter.on('DOMContentLoaded', function () { |
8 | - archive.readFile('distro/info.txt') | |
9 | - .then(file => { | |
10 | - var branchInfo = smarkt.parse(file) | |
11 | - state.branch = branchInfo | |
10 … | + mapInfoToState(state, emitter) | |
11 … | + }) | |
12 … | + | |
13 … | + emitter.on('branch updated', function (form) { | |
14 … | + var infoAsObj = formHandler.handle(form) | |
15 … | + var infoAsTxt = smarkt.stringify(infoAsObj) | |
16 … | + | |
17 … | + state.branch = infoAsObj | |
18 … | + archive.writeFile('branch/info.txt', infoAsTxt) | |
19 … | + .then(emitter.emit('pushState')) | |
20 … | + }) | |
21 … | + | |
22 … | + function mapInfoToState (state, emitter) { | |
23 … | + archive.readFile('branch/info.txt') | |
24 … | + .then(info => { | |
25 … | + var infoAsObj = smarkt.parse(info) | |
26 … | + state.branch = infoAsObj | |
12 | 27 … | emitter.emit('pushState') |
13 | 28 … | }) |
14 | - }) | |
29 … | + } | |
15 | 30 … | } |
16 | 31 … | |
17 | 32 … | module.exports = store |
volunteers/setBranchName.js |
---|
volunteers/formHandler.js | ||
---|---|---|
@@ -1,0 +1,10 @@ | ||
1 … | +module.exports = {handle} | |
2 … | + | |
3 … | +function handle (form) { | |
4 … | + var formData = new FormData(form) | |
5 … | + var data = {} | |
6 … | + for (var pair of formData.entries()) { | |
7 … | + data[pair[0]] = pair[1] | |
8 … | + } | |
9 … | + return data | |
10 … | +} |
zines/read-me.txt | ||
---|---|---|
@@ -1,5 +1,5 @@ | ||
1 | 1 … | title: read me |
2 | 2 … | ---- |
3 | 3 … | url: dat://d0222b1bcf7833e0708aa65ba8376aadba3f13e3025a113b10f755342b4c14d1/ |
4 | 4 … | ---- |
5 | -notes: Found it on Scuttlebutt, looks to be good sci fi. | |
5 … | +notes: I made this! |
zines/11-killer-app-ideas.txt | ||
---|---|---|
@@ -1,0 +1,5 @@ | ||
1 … | +title: 11 killer app ideas | |
2 … | +---- | |
3 … | +url: dat://86220354e57b0ac6dc3ef47ac9f8f75b62aebcd079d9688f2d7ede0af6abfba3/ | |
4 … | +---- | |
5 … | +notes: i made this one too. |
zines/A-Guided-Meditation.txt | ||
---|---|---|
@@ -1,0 +1,5 @@ | ||
1 … | +title: A Guided Meditation | |
2 … | +---- | |
3 … | +url: dat://0256c7538c0431d2e6dba8f11369407b19c3875957c8557cda4db6bd588f7be9/ | |
4 … | +---- | |
5 … | +notes: My Friend Ryland's Audio Meditation Zine. |
branch/info.txt | ||
---|---|---|
@@ -1,0 +1,8 @@ | ||
1 … | +name: Zach's Zine Library! | |
2 … | +---- | |
3 … | +description: The first dat zine library, but hopefully not the last! | |
4 … | + | |
5 … | +Collecting zines I wrote, my friends wrote, and ones that I discovered through sharing on here. | |
6 … | + | |
7 … | + | |
8 … | +**Send me your zine! [webmaster@coolguy.website](mailto:webmaster@coolguy.website) or through [Scuttlebutt](https://scuttlebutt.nz) (where I am Zach!)** |
distro/info.txt | ||
---|---|---|
@@ -1,9 +1,0 @@ | ||
1 | -title: Zach Mandeville's Zine Library | |
2 | ----- | |
3 | -description: | |
4 | - | |
5 | -The first dat zine library, but hopefully not the last! Collecting zines I wrote, my friends wrote, and ones that I discovered through sharing on here. | |
6 | - | |
7 | - | |
8 | -**Send me your zine! [webmaster@coolguy.website](mailto:webmaster@coolguy.website) or through [Scuttlebutt](https://scuttlebutt.nz) (where I am Zach!)** | |
9 | - |
Built with git-ssb-web