From 11afa8140c5706c8ad105e50cef63df83db66e7a Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 14 Nov 2018 16:30:58 +0900 Subject: [Client] Improve alert component --- src/client/app/common/scripts/check-for-update.ts | 2 +- src/client/app/common/scripts/fuck-ad-block.ts | 7 +- src/client/app/common/scripts/note-mixin.ts | 7 +- src/client/app/common/views/components/alert.vue | 179 +++++++++++++++++++++ .../app/common/views/components/note-menu.vue | 10 +- src/client/app/common/views/components/ok.vue | 175 -------------------- .../common/views/components/password-settings.vue | 7 +- .../app/common/views/components/profile-editor.vue | 2 +- src/client/app/common/views/components/theme.vue | 14 +- .../app/common/views/components/ui/button.vue | 2 + .../common/views/components/ui/horizon-group.vue | 22 ++- 11 files changed, 219 insertions(+), 208 deletions(-) create mode 100644 src/client/app/common/views/components/alert.vue delete mode 100644 src/client/app/common/views/components/ok.vue (limited to 'src/client/app/common') diff --git a/src/client/app/common/scripts/check-for-update.ts b/src/client/app/common/scripts/check-for-update.ts index 377eccc6b5..7fe9d8d50c 100644 --- a/src/client/app/common/scripts/check-for-update.ts +++ b/src/client/app/common/scripts/check-for-update.ts @@ -22,7 +22,7 @@ export default async function($root: any, force = false, silent = false) { } if (!silent) { - $root.$dialog({ + $root.alert({ title: $root.$t('@.update-available-title'), text: $root.$t('@.update-available', { newer, current }) }); diff --git a/src/client/app/common/scripts/fuck-ad-block.ts b/src/client/app/common/scripts/fuck-ad-block.ts index 8d0a3e2785..f5cc1b71f2 100644 --- a/src/client/app/common/scripts/fuck-ad-block.ts +++ b/src/client/app/common/scripts/fuck-ad-block.ts @@ -4,12 +4,9 @@ export default ($root: any) => { require('fuckadblock'); function adBlockDetected() { - $root.$dialog({ + $root.alert({ title: $root.$t('@.adblock.detected'), - text: $root.$t('@.adblock.warning'), - actins: [{ - text: 'OK' - }] + text: $root.$t('@.adblock.warning') }); } diff --git a/src/client/app/common/scripts/note-mixin.ts b/src/client/app/common/scripts/note-mixin.ts index 9f1a4c6eea..80935927d5 100644 --- a/src/client/app/common/scripts/note-mixin.ts +++ b/src/client/app/common/scripts/note-mixin.ts @@ -3,7 +3,6 @@ import { sum } from '../../../../prelude/array'; import shouldMuteNote from './should-mute-note'; import MkNoteMenu from '../views/components/note-menu.vue'; import MkReactionPicker from '../views/components/reaction-picker.vue'; -import Ok from '../views/components/ok.vue'; function focus(el, fn) { const target = fn(el); @@ -142,7 +141,11 @@ export default (opts: Opts = {}) => ({ this.$root.api('notes/favorites/create', { noteId: this.appearNote.id }).then(() => { - this.$root.new(Ok); + // TODO + /*this.$root.alert({ + pointer: false, + autoClose: true + });*/ }); }, diff --git a/src/client/app/common/views/components/alert.vue b/src/client/app/common/views/components/alert.vue new file mode 100644 index 0000000000..8f307f86ea --- /dev/null +++ b/src/client/app/common/views/components/alert.vue @@ -0,0 +1,179 @@ + + + + + diff --git a/src/client/app/common/views/components/note-menu.vue b/src/client/app/common/views/components/note-menu.vue index 86b3820c36..d45c9c8835 100644 --- a/src/client/app/common/views/components/note-menu.vue +++ b/src/client/app/common/views/components/note-menu.vue @@ -9,7 +9,6 @@ import Vue from 'vue'; import i18n from '../../../i18n'; import { url } from '../../../config'; import copyToClipboard from '../../../common/scripts/copy-to-clipboard'; -import Ok from './ok.vue'; import { concat, intersperse } from '../../../../../prelude/array'; export default Vue.extend({ @@ -79,7 +78,8 @@ export default Vue.extend({ this.$root.api('i/pin', { noteId: this.note.id }).then(() => { - this.$root.new(Ok); + // TODO + //this.$root.new(Ok); this.destroyDom(); }); }, @@ -105,7 +105,8 @@ export default Vue.extend({ this.$root.api('notes/favorites/create', { noteId: this.note.id }).then(() => { - this.$root.new(Ok); + // TODO + //this.$root.new(Ok); this.destroyDom(); }); }, @@ -114,7 +115,8 @@ export default Vue.extend({ this.$root.api('notes/favorites/delete', { noteId: this.note.id }).then(() => { - this.$root.new(Ok); + // TODO + //this.$root.new(Ok); this.destroyDom(); }); }, diff --git a/src/client/app/common/views/components/ok.vue b/src/client/app/common/views/components/ok.vue deleted file mode 100644 index 63bd784b18..0000000000 --- a/src/client/app/common/views/components/ok.vue +++ /dev/null @@ -1,175 +0,0 @@ - - - - - diff --git a/src/client/app/common/views/components/password-settings.vue b/src/client/app/common/views/components/password-settings.vue index 8661b51538..356f8b2fa4 100644 --- a/src/client/app/common/views/components/password-settings.vue +++ b/src/client/app/common/views/components/password-settings.vue @@ -25,12 +25,9 @@ export default Vue.extend({ type: 'password' }).then(newPassword2 => { if (newPassword !== newPassword2) { - this.$dialog({ + this.$root.alert({ title: null, - text: this.$t('not-match'), - actions: [{ - text: 'OK' - }] + text: this.$t('not-match') }); return; } diff --git a/src/client/app/common/views/components/profile-editor.vue b/src/client/app/common/views/components/profile-editor.vue index 034c3bed8c..bbb2fdb800 100644 --- a/src/client/app/common/views/components/profile-editor.vue +++ b/src/client/app/common/views/components/profile-editor.vue @@ -193,7 +193,7 @@ export default Vue.extend({ this.$store.state.i.bannerUrl = i.bannerUrl; if (notify) { - this.$swal({ + this.$root.alert({ type: 'success', text: this.$t('saved') }); diff --git a/src/client/app/common/views/components/theme.vue b/src/client/app/common/views/components/theme.vue index 4a6d066d7f..fac11d9efb 100644 --- a/src/client/app/common/views/components/theme.vue +++ b/src/client/app/common/views/components/theme.vue @@ -221,7 +221,7 @@ export default Vue.extend({ try { theme = JSON5.parse(code); } catch (e) { - this.$swal({ + this.$root.alert({ type: 'error', text: this.$t('invalid-theme') }); @@ -234,7 +234,7 @@ export default Vue.extend({ } if (theme.id == null) { - this.$swal({ + this.$root.alert({ type: 'error', text: this.$t('invalid-theme') }); @@ -242,7 +242,7 @@ export default Vue.extend({ } if (this.$store.state.device.themes.some(t => t.id == theme.id)) { - this.$swal({ + this.$root.alert({ type: 'info', text: this.$t('already-installed') }); @@ -254,7 +254,7 @@ export default Vue.extend({ key: 'themes', value: themes }); - this.$swal({ + this.$root.alert({ type: 'success', text: this.$t('installed').replace('{}', theme.name) }); @@ -267,7 +267,7 @@ export default Vue.extend({ key: 'themes', value: themes }); - this.$swal({ + this.$root.alert({ type: 'info', text: this.$t('uninstalled').replace('{}', theme.name) }); @@ -304,7 +304,7 @@ export default Vue.extend({ const theme = this.myTheme; if (theme.name == null || theme.name.trim() == '') { - this.$swal({ + this.$root.alert({ type: 'warning', text: this.$t('theme-name-required') }); @@ -318,7 +318,7 @@ export default Vue.extend({ key: 'themes', value: themes }); - this.$swal({ + this.$root.alert({ type: 'success', text: this.$t('saved') }); diff --git a/src/client/app/common/views/components/ui/button.vue b/src/client/app/common/views/components/ui/button.vue index 132518da92..ee8366e89d 100644 --- a/src/client/app/common/views/components/ui/button.vue +++ b/src/client/app/common/views/components/ui/button.vue @@ -57,6 +57,7 @@ export default Vue.extend({ text-align center font-weight normal font-size 16px + line-height 24px border none border-radius 6px outline none @@ -85,6 +86,7 @@ export default Vue.extend({ &.inline display inline-block width auto + min-width 100px &.primary font-weight bold diff --git a/src/client/app/common/views/components/ui/horizon-group.vue b/src/client/app/common/views/components/ui/horizon-group.vue index b9c7cf5cbe..0d4eafae52 100644 --- a/src/client/app/common/views/components/ui/horizon-group.vue +++ b/src/client/app/common/views/components/ui/horizon-group.vue @@ -1,5 +1,5 @@ @@ -15,21 +15,27 @@ export default Vue.extend({ type: Boolean, required: false, default: false + }, + noGrow: { + type: Boolean, + required: false, + default: false } } }); -- cgit v1.2.3-freya