2018-02-26 04:45:11 +00:00
|
|
|
<div class="lite-compose-box {{overLimit ? 'over-char-limit' : ''}}">
|
2018-02-27 05:50:03 +00:00
|
|
|
<div class="compose-box-current-user">
|
|
|
|
<Avatar account="{{verifyCredentials}}" className="compose-box-avatar" size="small"/>
|
|
|
|
<a class="compose-box-display-name" href="/accounts/{{verifyCredentials.id}}">
|
2018-02-26 00:26:43 +00:00
|
|
|
{{verifyCredentials.display_name || verifyCredentials.acct}}
|
|
|
|
</a>
|
2018-02-27 05:50:03 +00:00
|
|
|
<span class="compose-box-handle">
|
2018-02-26 00:26:43 +00:00
|
|
|
{{'@' + verifyCredentials.acct}}
|
|
|
|
</span>
|
|
|
|
<textarea
|
2018-02-27 05:50:03 +00:00
|
|
|
class="compose-box-input"
|
2018-02-26 00:26:43 +00:00
|
|
|
placeholder="What's on your mind?"
|
|
|
|
ref:textarea
|
|
|
|
bind:value=inputText
|
|
|
|
></textarea>
|
2018-02-27 05:50:03 +00:00
|
|
|
<ComposeLengthGauge :inputLength />
|
|
|
|
<ComposeToolbar />
|
|
|
|
<ComposeLengthIndicator :inputLength />
|
|
|
|
<button class="primary compose-box-button">
|
2018-02-26 00:26:43 +00:00
|
|
|
Toot!
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<style>
|
|
|
|
.lite-compose-box {
|
|
|
|
display: grid;
|
|
|
|
flex-direction: row;
|
|
|
|
}
|
2018-02-27 05:50:03 +00:00
|
|
|
.compose-box-current-user {
|
2018-02-26 00:26:43 +00:00
|
|
|
border-radius: 4px;
|
|
|
|
padding: 20px;
|
|
|
|
display: grid;
|
|
|
|
align-items: flex-start;
|
|
|
|
grid-template-areas:
|
2018-02-27 04:55:49 +00:00
|
|
|
"avatar display-name handle handle"
|
|
|
|
"avatar input input input"
|
|
|
|
"avatar gauge gauge gauge"
|
|
|
|
"avatar toolbar toolbar length"
|
|
|
|
"avatar button button button";
|
|
|
|
grid-template-columns: min-content minmax(0, max-content) 1fr 1fr;
|
2018-02-26 00:26:43 +00:00
|
|
|
border-bottom: 1px solid var(--main-border);
|
|
|
|
width: 560px;
|
|
|
|
max-width: calc(100vw - 40px);
|
|
|
|
}
|
2018-02-27 05:50:03 +00:00
|
|
|
:global(.compose-box-avatar) {
|
2018-02-26 00:26:43 +00:00
|
|
|
grid-area: avatar;
|
|
|
|
margin-right: 15px;
|
|
|
|
}
|
2018-02-27 05:50:03 +00:00
|
|
|
.compose-box-display-name {
|
2018-02-26 00:26:43 +00:00
|
|
|
color: var(--deemphasized-text-color);
|
|
|
|
grid-area: display-name;
|
|
|
|
min-width: 0;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
font-size: 1.1em;
|
|
|
|
margin-left: 5px;
|
|
|
|
font-weight: 600;
|
|
|
|
}
|
2018-02-27 05:50:03 +00:00
|
|
|
.compose-box-display-name,
|
|
|
|
.compose-box-display-name:hover,
|
|
|
|
.compose-box-display-name:visited {
|
2018-02-26 00:26:43 +00:00
|
|
|
color: var(--body-text-color);
|
|
|
|
}
|
2018-02-27 05:50:03 +00:00
|
|
|
:global(.compose-box-handle) {
|
2018-02-26 00:26:43 +00:00
|
|
|
grid-area: handle;
|
|
|
|
color: var(--deemphasized-text-color);
|
|
|
|
min-width: 0;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
font-size: 1.1em;
|
|
|
|
margin-left: 5px;
|
|
|
|
}
|
|
|
|
|
2018-02-27 05:50:03 +00:00
|
|
|
:global(.compose-box-input) {
|
2018-02-26 00:26:43 +00:00
|
|
|
grid-area: input;
|
2018-02-27 04:55:49 +00:00
|
|
|
margin: 10px 0 0 5px;
|
2018-02-26 08:24:28 +00:00
|
|
|
padding: 10px;
|
2018-02-26 00:26:43 +00:00
|
|
|
border: 1px solid var(--input-border);
|
|
|
|
min-height: 75px;
|
|
|
|
resize: none;
|
2018-02-26 01:21:17 +00:00
|
|
|
overflow: hidden;
|
2018-02-26 06:29:12 +00:00
|
|
|
word-wrap: break-word;
|
2018-02-26 05:12:22 +00:00
|
|
|
/* Text must be at least 16px or else iOS Safari zooms in */
|
|
|
|
font-size: 1.2em;
|
|
|
|
/* Hack to make Edge stretch the element all the way to the right.
|
|
|
|
* Also desktop Safari makes the gauge stretch too far to the right without it.
|
|
|
|
*/
|
2018-02-26 04:45:11 +00:00
|
|
|
width: calc(100% - 5px);
|
2018-02-26 00:26:43 +00:00
|
|
|
}
|
|
|
|
|
2018-02-27 05:50:03 +00:00
|
|
|
.compose-box-button {
|
2018-02-26 00:26:43 +00:00
|
|
|
grid-area: button;
|
|
|
|
justify-self: right;
|
|
|
|
text-transform: uppercase;
|
2018-02-26 01:21:17 +00:00
|
|
|
margin-top: 10px;
|
|
|
|
}
|
|
|
|
|
2018-02-26 00:26:43 +00:00
|
|
|
@media (max-width: 767px) {
|
2018-02-27 05:50:03 +00:00
|
|
|
.compose-box-current-user {
|
2018-02-26 00:26:43 +00:00
|
|
|
padding: 10px 10px;
|
|
|
|
max-width: calc(100vw - 20px);
|
|
|
|
width: 580px;
|
|
|
|
}
|
2018-02-27 05:50:03 +00:00
|
|
|
:global(.compose-box-avatar) {
|
2018-02-26 00:26:43 +00:00
|
|
|
grid-area: avatar;
|
|
|
|
margin-right: 5px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
import Avatar from '../Avatar.html'
|
|
|
|
import { store } from '../../_store/store'
|
2018-02-26 04:45:11 +00:00
|
|
|
import { autosize } from '../../_utils/autosize'
|
2018-02-26 00:26:43 +00:00
|
|
|
import { scheduleIdleTask } from '../../_utils/scheduleIdleTask'
|
|
|
|
import debounce from 'lodash/debounce'
|
2018-02-26 00:47:45 +00:00
|
|
|
import { mark, stop } from '../../_utils/marks'
|
2018-02-27 05:50:03 +00:00
|
|
|
import ComposeToolbar from './ComposeToolbar.html'
|
|
|
|
import ComposeLengthGauge from './ComposeLengthGauge.html'
|
|
|
|
import ComposeLengthIndicator from './ComposeLengthIndicator.html'
|
2018-02-26 01:21:17 +00:00
|
|
|
|
2018-02-26 00:26:43 +00:00
|
|
|
export default {
|
|
|
|
oncreate() {
|
|
|
|
this.set({inputText: store.get('currentInputTextInCompose')})
|
|
|
|
|
2018-02-26 06:50:50 +00:00
|
|
|
requestAnimationFrame(() => {
|
|
|
|
mark('autosize()')
|
|
|
|
autosize(this.refs.textarea)
|
|
|
|
stop('autosize()')
|
|
|
|
})
|
|
|
|
|
|
|
|
const saveText = debounce(() => scheduleIdleTask(() => this.store.save()), 1000)
|
2018-02-26 00:26:43 +00:00
|
|
|
this.observe('inputText', inputText => {
|
|
|
|
let inputTextInCompose = this.store.get('inputTextInCompose')
|
|
|
|
let currentInstance = this.store.get('currentInstance')
|
|
|
|
inputTextInCompose[currentInstance] = inputText || ''
|
|
|
|
this.store.set({inputTextInCompose: inputTextInCompose})
|
|
|
|
saveText()
|
|
|
|
}, {init: false})
|
|
|
|
},
|
|
|
|
ondestroy() {
|
2018-02-26 00:47:45 +00:00
|
|
|
mark('autosize.destroy()')
|
2018-02-26 00:26:43 +00:00
|
|
|
autosize.destroy(this.refs.textarea)
|
2018-02-26 00:47:45 +00:00
|
|
|
stop('autosize.destroy()')
|
2018-02-26 00:26:43 +00:00
|
|
|
},
|
|
|
|
data: () => ({
|
|
|
|
inputText: ''
|
|
|
|
}),
|
|
|
|
components: {
|
2018-02-27 04:55:49 +00:00
|
|
|
Avatar,
|
2018-02-27 05:50:03 +00:00
|
|
|
ComposeToolbar,
|
|
|
|
ComposeLengthGauge,
|
|
|
|
ComposeLengthIndicator
|
2018-02-26 00:26:43 +00:00
|
|
|
},
|
|
|
|
store: () => store,
|
|
|
|
computed: {
|
2018-02-26 01:21:17 +00:00
|
|
|
currentInputTextInCompose: ($currentInputTextInCompose) => $currentInputTextInCompose,
|
|
|
|
inputLength: (inputText) => inputText ? inputText.length : 0,
|
2018-02-26 00:26:43 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-26 08:24:28 +00:00
|
|
|
</script>
|