2018-02-26 00:26:43 +00:00
|
|
|
<div class="lite-compose-box">
|
|
|
|
<div class="compose-profile-current-user">
|
|
|
|
<Avatar account="{{verifyCredentials}}" className="compose-profile-avatar" size="small"/>
|
|
|
|
<a class="compose-profile-display-name" href="/accounts/{{verifyCredentials.id}}">
|
|
|
|
{{verifyCredentials.display_name || verifyCredentials.acct}}
|
|
|
|
</a>
|
|
|
|
<span class="compose-profile-handle">
|
|
|
|
{{'@' + verifyCredentials.acct}}
|
|
|
|
</span>
|
|
|
|
<textarea
|
|
|
|
class="compose-profile-input"
|
|
|
|
placeholder="What's on your mind?"
|
|
|
|
ref:textarea
|
|
|
|
bind:value=inputText
|
|
|
|
></textarea>
|
2018-02-26 01:21:17 +00:00
|
|
|
<div class="compose-profile-length-gauge {{overLimit ? 'over-char-limit' : ''}}"
|
|
|
|
style="transform: scaleX({{inputLengthAsFractionOfMax}});"
|
|
|
|
aria-hidden="true"
|
|
|
|
></div>
|
|
|
|
<span class="compose-profile-length {{overLimit ? 'over-char-limit' : ''}}"
|
|
|
|
aria-label="{{inputLengthLabel}}">
|
|
|
|
{{inputLengthToDisplay}}
|
|
|
|
</span>
|
2018-02-26 00:26:43 +00:00
|
|
|
<button class="primary compose-profile-button">
|
|
|
|
Toot!
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<style>
|
|
|
|
.lite-compose-box {
|
|
|
|
display: grid;
|
|
|
|
flex-direction: row;
|
|
|
|
}
|
|
|
|
.compose-profile-current-user {
|
|
|
|
border-radius: 4px;
|
|
|
|
padding: 20px;
|
|
|
|
display: grid;
|
|
|
|
align-items: flex-start;
|
|
|
|
grid-template-areas:
|
|
|
|
"avatar display-name handle"
|
|
|
|
"avatar input input"
|
2018-02-26 01:21:17 +00:00
|
|
|
"avatar gauge gauge"
|
|
|
|
"avatar length length"
|
2018-02-26 00:26:43 +00:00
|
|
|
"avatar button button";
|
|
|
|
grid-template-columns: min-content minmax(0, max-content) 1fr;
|
|
|
|
border-bottom: 1px solid var(--main-border);
|
|
|
|
width: 560px;
|
|
|
|
max-width: calc(100vw - 40px);
|
|
|
|
}
|
|
|
|
:global(.compose-profile-avatar) {
|
|
|
|
grid-area: avatar;
|
|
|
|
margin-right: 15px;
|
|
|
|
}
|
|
|
|
.compose-profile-display-name {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
.compose-profile-display-name,
|
|
|
|
.compose-profile-display-name:hover,
|
|
|
|
.compose-profile-display-name:visited {
|
|
|
|
color: var(--body-text-color);
|
|
|
|
}
|
|
|
|
:global(.compose-profile-handle) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
:global(.compose-profile-input) {
|
|
|
|
font-size: 1.1em;
|
|
|
|
grid-area: input;
|
|
|
|
margin-left: 5px;
|
|
|
|
padding: 5px;
|
|
|
|
border: 1px solid var(--input-border);
|
|
|
|
min-height: 75px;
|
2018-02-26 01:21:17 +00:00
|
|
|
margin-top: 10px;
|
2018-02-26 00:26:43 +00:00
|
|
|
resize: none;
|
2018-02-26 01:21:17 +00:00
|
|
|
overflow: hidden;
|
2018-02-26 00:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.compose-profile-button {
|
|
|
|
grid-area: button;
|
|
|
|
justify-self: right;
|
|
|
|
text-transform: uppercase;
|
2018-02-26 01:21:17 +00:00
|
|
|
margin-top: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.compose-profile-length-gauge {
|
|
|
|
grid-area: gauge;
|
|
|
|
height: 2px;
|
|
|
|
background: var(--main-theme-color);
|
|
|
|
margin-left: 5px;
|
|
|
|
transform-origin: left;
|
|
|
|
}
|
|
|
|
|
|
|
|
.compose-profile-length {
|
|
|
|
grid-area: length;
|
|
|
|
margin-top: 5px;
|
|
|
|
justify-self: right;
|
|
|
|
color: var(--main-theme-color);
|
|
|
|
font-size: 1.1em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.compose-profile-length.over-char-limit {
|
|
|
|
color: var(--warning-color);
|
|
|
|
}
|
|
|
|
|
|
|
|
.compose-profile-length-gauge.over-char-limit {
|
|
|
|
background: var(--warning-color);
|
2018-02-26 00:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@media (max-width: 767px) {
|
|
|
|
.compose-profile-current-user {
|
|
|
|
padding: 10px 10px;
|
|
|
|
max-width: calc(100vw - 20px);
|
|
|
|
width: 580px;
|
|
|
|
}
|
|
|
|
:global(.compose-profile-avatar) {
|
|
|
|
grid-area: avatar;
|
|
|
|
margin-right: 5px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
import Avatar from '../Avatar.html'
|
|
|
|
import { store } from '../../_store/store'
|
|
|
|
import autosize from 'autosize'
|
|
|
|
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-26 00:26:43 +00:00
|
|
|
|
2018-02-26 01:21:17 +00:00
|
|
|
const CHAR_LIMIT = 500
|
|
|
|
|
2018-02-26 00:26:43 +00:00
|
|
|
export default {
|
|
|
|
oncreate() {
|
|
|
|
this.set({inputText: store.get('currentInputTextInCompose')})
|
2018-02-26 00:47:45 +00:00
|
|
|
mark('autosize()')
|
|
|
|
autosize(this.refs.textarea) // TODO: this layout thrashes, could maybe find a better design
|
|
|
|
stop('autosize()')
|
2018-02-26 00:26:43 +00:00
|
|
|
|
|
|
|
const saveText = debounce(() => scheduleIdleTask(() => this.store.save()), 1000)
|
|
|
|
|
|
|
|
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: {
|
|
|
|
Avatar
|
|
|
|
},
|
|
|
|
store: () => store,
|
|
|
|
computed: {
|
2018-02-26 01:21:17 +00:00
|
|
|
currentInputTextInCompose: ($currentInputTextInCompose) => $currentInputTextInCompose,
|
|
|
|
inputLength: (inputText) => inputText ? inputText.length : 0,
|
|
|
|
inputLengthToDisplay: (inputLength) => (inputLength <= CHAR_LIMIT ? inputLength : CHAR_LIMIT - inputLength),
|
|
|
|
inputLengthAsFractionOfMax: (inputLength) => (Math.min(CHAR_LIMIT, inputLength)) / CHAR_LIMIT,
|
|
|
|
overLimit: (inputLength) => inputLength > CHAR_LIMIT,
|
|
|
|
inputLengthLabel: (overLimit, inputLengthToDisplay) => {
|
|
|
|
if (overLimit) {
|
|
|
|
return `${inputLengthToDisplay} characters over limit`
|
|
|
|
} else {
|
|
|
|
return `${inputLengthToDisplay} characters`
|
|
|
|
}
|
|
|
|
}
|
2018-02-26 00:26:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|