git ssb

16+

Dominic / patchbay



Commit ddf533c74d989b38d8a15ce293a021f67153b2cc

smooth textarea transition, sweet paperclip

mix irving committed on 1/8/2017, 1:15:16 AM
Parent: 2445f7f6c568d24593d20f150be2fa3a18c84c58

Files changed

modules_basic/compose.jschanged
modules_basic/compose.mcsschanged
style.csschanged
modules_basic/compose.jsView
@@ -56,17 +56,17 @@
5656 if(!meta.type) throw new Error('message must have type')
5757
5858 var textArea = h('textarea', {
5959 placeholder: opts.placeholder || 'Write a message',
60- style: {height: opts.shrink === false ? '200px' : ''}
60 + className: opts.shrink === false ? '-expanded' : '-contracted'
6161 })
6262
6363 if(opts.shrink !== false) {
6464 var blur
6565 textArea.addEventListener('focus', () => {
6666 clearTimeout(blur)
6767 if(!textArea.value) {
68- textArea.style.height = '200px'
68 + textArea.className = '-expanded'
6969 }
7070 actions.style.display = 'flex'
7171 })
7272 textArea.addEventListener('blur', () => {
@@ -74,11 +74,11 @@
7474 //to click the publish button.
7575 clearTimeout(blur)
7676 blur = setTimeout(() => {
7777 if(textArea.value) return
78- textArea.style.height = '50px'
78 + textArea.className = '-contracted'
7979 actions.style.display = 'none'
80- }, 200)
80 + }, 300)
8181 })
8282 }
8383
8484 textArea.addEventListener('keydown', ev => {
@@ -129,17 +129,15 @@
129129 files.push(file)
130130 filesById[file.link] = file
131131
132132 var embed = file.type.indexOf('image/') === 0 ? '!' : ''
133- textArea.value += embed + '['+file.name+']('+file.link+')'
133 + textArea.value += '\n' + embed + '['+file.name+']('+file.link+')'
134134 console.log('added:', file)
135135 })
136136 var publishBtn = h('button', {'ev-click': publish}, 'Publish' )
137137 var actions = h('section.actions',
138138 //hidden until you focus the textarea
139- { style: {display: opts.shrink === false ? '' : ''} },
140- // revert
141- // { style: {display: opts.shrink === false ? '' : 'none'} },
139 + { style: {display: opts.shrink === false ? '' : 'none'} },
142140 [ fileInput, publishBtn ]
143141 )
144142
145143 var composer = h('Compose', [
modules_basic/compose.mcssView
@@ -5,35 +5,45 @@
55 padding: 1rem .5rem
66
77 textarea {
88 border: 1px solid gainsboro
9 +
10 + -expanded {
11 + height: 200px
12 + transition: height .15s ease-out
13 + }
14 +
15 + -contracted {
16 + height: 50px
17 + transition: height .15s ease-in
18 + }
919 }
1020
1121 section.actions {
1222 display: flex
1323 flex-direction: row
1424 align-items: baseline
1525
26 + margin-top: .4rem
27 +
1628 input[type="file"] {
1729 flex-grow: 1
1830
31 + padding: .5rem 0
32 +
1933 width: 5.5rem
2034 color: transparent
2135
2236 ::-webkit-file-upload-button {
2337 visibility: hidden
2438 }
2539
2640 ::before {
27- content: 'attach file'
41 + $composeButton
42 + padding-top: .3rem
2843
29- background: #fff
30- color: #666
31- padding: .5rem
32- margin: .5rem 0
33- cursor: pointer
34- text-transform: uppercase
35- font-size: .7rem
44 + content: '📎'
45 + font-size: 1rem
3646
3747 outline: none
3848 white-space: nowrap
3949 -webkit-user-select: none
@@ -45,19 +55,23 @@
4555 }
4656 }
4757
4858 button {
49- background: #fff
50- color: #666
51- border: 1px solid #bbb
52- border-radius: .5rem
53- padding: .5rem
54- margin: .5rem 0
55- cursor: pointer
59 + $composeButton
60 +
5661 text-transform: uppercase
5762 font-weight: bold
5863 font-size: .7rem
5964 }
6065 }
6166 }
6267
68 +$composeButton {
69 + background: #fff
70 + color: #666
71 + border: 1px solid #bbb
72 + border-radius: .5rem
73 + padding: .5rem
74 + margin: 0
75 + cursor: pointer
76 +}
6377
style.cssView
@@ -162,21 +162,8 @@
162162 margin-left: auto;
163163 margin-right: auto;
164164 }
165165
166-/* compose */
167-
168-.compose {
169- width: 100%;
170- margin-top: .5em;
171- margin-bottom: .5em;
172- border: 1px solid #f5f5f5;
173-}
174-
175-.compose button {
176- float: right;
177-}
178-
179166 /* messages */
180167 /* is .title used any more? */
181168
182169 .title {

Built with git-ssb-web