pinafore/src/routes/_components/compose/ComposeToolbar.html

114 lines
3.2 KiB
HTML
Raw Normal View History

2018-02-27 06:50:03 +01:00
<div class="compose-box-toolbar">
2018-03-25 03:04:54 +02:00
<div class="compose-box-toolbar-items">
<IconButton
className="compose-toolbar-button"
2018-03-25 03:04:54 +02:00
label="Insert emoji"
href="#fa-smile"
on:click="onEmojiClick()"
/>
<IconButton
className="compose-toolbar-button"
svgClassName={$uploadingMedia ? 'spin' : ''}
2018-03-25 03:04:54 +02:00
label="Add media"
href={$uploadingMedia ? '#fa-spinner' : '#fa-camera'}
2018-03-25 03:04:54 +02:00
on:click="onMediaClick()"
disabled={$uploadingMedia || (media.length === 4)}
2018-03-25 03:04:54 +02:00
/>
<IconButton
className="compose-toolbar-button"
label="{poll && poll.options && poll.options.length ? 'Remove poll' : 'Add poll'}"
href="#fa-bar-chart"
on:click="onPollClick()"
pressable="true"
pressed={poll && poll.options && poll.options.length}
/>
2018-03-25 03:04:54 +02:00
<IconButton
className="compose-toolbar-button"
label="Adjust privacy (currently {postPrivacy.label})"
href={postPrivacy.icon}
2018-03-25 03:04:54 +02:00
on:click="onPostPrivacyClick()"
/>
<IconButton
className="compose-toolbar-button"
label={contentWarningShown ? 'Remove content warning' : 'Add content warning'}
2018-03-25 03:04:54 +02:00
href="#fa-exclamation-triangle"
on:click="onContentWarningClick()"
pressable="true"
pressed={contentWarningShown}
2018-03-25 03:04:54 +02:00
/>
</div>
2018-03-01 18:02:42 +01:00
<input ref:input
2018-03-01 18:29:11 +01:00
on:change="onFileChange(event)"
2018-03-01 18:02:42 +01:00
style="display: none;"
type="file"
accept={mediaAccept} >
2018-02-27 06:50:03 +01:00
</div>
<style>
.compose-box-toolbar {
grid-area: toolbar;
align-self: center;
2018-03-25 03:04:54 +02:00
}
.compose-box-toolbar-items {
2018-02-27 06:50:03 +01:00
display: flex;
align-items: center;
}
@media (max-width: 320px) {
:global(button.icon-button.compose-toolbar-button) {
padding-left: 5px;
padding-right: 5px;
}
}
2018-02-27 06:50:03 +01:00
</style>
<script>
import IconButton from '../IconButton.html'
2018-02-28 08:18:07 +01:00
import { store } from '../../_store/store'
import { importShowEmojiDialog, importShowPostPrivacyDialog } from '../dialog/asyncDialogs'
2018-03-02 06:21:49 +01:00
import { doMediaUpload } from '../../_actions/media'
2018-03-04 00:44:43 +01:00
import { toggleContentWarningShown } from '../../_actions/contentWarnings'
import { mediaAccept } from '../../_static/media'
import { enablePoll, disablePoll } from '../../_actions/composePoll'
2018-02-28 08:18:07 +01:00
2018-02-27 06:50:03 +01:00
export default {
components: {
IconButton
2018-02-28 08:18:07 +01:00
},
data: () => ({
mediaAccept
}),
2018-02-28 08:18:07 +01:00
store: () => store,
methods: {
2018-04-20 06:38:01 +02:00
async onEmojiClick () {
let { realm } = this.get()
let showEmojiDialog = await importShowEmojiDialog()
showEmojiDialog(realm)
2018-03-01 18:02:42 +01:00
},
2018-04-20 06:38:01 +02:00
onMediaClick () {
2018-03-01 18:02:42 +01:00
this.refs.input.click()
2018-03-01 18:29:11 +01:00
},
2018-04-20 06:38:01 +02:00
onFileChange (e) {
2018-03-01 18:29:11 +01:00
let file = e.target.files[0]
let { realm } = this.get()
doMediaUpload(realm, file)
2018-03-03 22:23:26 +01:00
},
2018-04-20 06:38:01 +02:00
async onPostPrivacyClick () {
let { realm } = this.get()
let showPostPrivacyDialog = await importShowPostPrivacyDialog()
showPostPrivacyDialog(realm)
2018-03-04 00:44:43 +01:00
},
2018-04-20 06:38:01 +02:00
onContentWarningClick () {
let { realm } = this.get()
toggleContentWarningShown(realm)
},
onPollClick () {
let { poll, realm } = this.get()
if (poll && poll.options && poll.options.length) {
disablePoll(realm)
} else {
enablePoll(realm)
}
2018-02-28 08:18:07 +01:00
}
2018-02-27 06:50:03 +01:00
}
}
</script>