Improve user operations

Resolve #2197
Resolve #3367
This commit is contained in:
syuilo
2018-11-23 08:01:14 +09:00
parent 13a75abc91
commit 246cead2b1
19 changed files with 404 additions and 63 deletions

View File

@@ -5,7 +5,7 @@
<div class="icon" :class="type"><fa :icon="icon"/></div>
<header v-if="title" v-html="title"></header>
<div class="body" v-if="text" v-html="text"></div>
<ui-horizon-group no-grow class="buttons" v-if="!splash">
<ui-horizon-group no-grow class="buttons fit-bottom" v-if="!splash">
<ui-button @click="ok" primary autofocus>OK</ui-button>
<ui-button @click="cancel" v-if="showCancelButton">Cancel</ui-button>
</ui-horizon-group>

View File

@@ -27,9 +27,17 @@ export default Vue.extend({
<style lang="stylus" scoped>
.vnxwkwuf
margin 16px 0
&.inputs
margin 32px 0
&.fit-top
margin-top 0
&.fit-bottom
margin-bottom 0
&:not(.noGrow)
display flex
@@ -37,5 +45,6 @@ export default Vue.extend({
flex 1
> *:not(:last-child)
margin-right 16px
margin-right 16px !important
</style>

View File

@@ -9,27 +9,30 @@
<div class="prefix" ref="prefix"><slot name="prefix"></slot></div>
<template v-if="type != 'file'">
<input ref="input"
:type="type"
v-model="v"
:disabled="disabled"
:required="required"
:readonly="readonly"
:pattern="pattern"
:autocomplete="autocomplete"
:spellcheck="spellcheck"
@focus="focused = true"
@blur="focused = false">
:type="type"
v-model="v"
:disabled="disabled"
:required="required"
:readonly="readonly"
:pattern="pattern"
:autocomplete="autocomplete"
:spellcheck="spellcheck"
@focus="focused = true"
@blur="focused = false"
>
</template>
<template v-else>
<input ref="input"
type="text"
:value="placeholder"
readonly
@click="chooseFile">
type="text"
:value="placeholder"
readonly
@click="chooseFile"
>
<input ref="file"
type="file"
:value="value"
@change="onChangeFile">
type="file"
:value="value"
@change="onChangeFile"
>
</template>
<div class="suffix" ref="suffix"><slot name="suffix"></slot></div>
</div>
@@ -325,6 +328,9 @@ root(fill)
margin 6px 0
font-size 13px
&:empty
display none
*
margin 0

View File

@@ -1,15 +1,17 @@
<template>
<div class="ui-select" :class="[{ focused, filled }, styl]">
<div class="ui-select" :class="[{ focused, disabled, filled, inline }, styl]">
<div class="icon" ref="icon"><slot name="icon"></slot></div>
<div class="input" @click="focus">
<span class="label" ref="label"><slot name="label"></slot></span>
<div class="prefix" ref="prefix"><slot name="prefix"></slot></div>
<select ref="input"
:value="v"
:required="required"
@input="$emit('input', $event.target.value)"
@focus="focused = true"
@blur="focused = false">
:value="v"
:required="required"
:disabled="disabled"
@input="$emit('input', $event.target.value)"
@focus="focused = true"
@blur="focused = false"
>
<slot></slot>
</select>
<div class="suffix"><slot name="suffix"></slot></div>
@@ -22,6 +24,11 @@
import Vue from 'vue';
export default Vue.extend({
inject: {
horizonGrouped: {
default: false
}
},
props: {
value: {
required: false
@@ -30,11 +37,22 @@ export default Vue.extend({
type: Boolean,
required: false
},
disabled: {
type: Boolean,
required: false
},
styl: {
type: String,
required: false,
default: 'line'
}
},
inline: {
type: Boolean,
required: false,
default(): boolean {
return this.horizonGrouped;
}
},
},
data() {
return {
@@ -122,7 +140,7 @@ root(fill)
transition-duration 0.3s
font-size 16px
line-height 32px
color rgba(#000, 0.54)
color var(--inputLabel)
pointer-events none
//will-change transform
transform-origin top left
@@ -171,6 +189,9 @@ root(fill)
margin 6px 0
font-size 13px
&:empty
display none
*
margin 0
@@ -200,4 +221,14 @@ root(fill)
&:not(.fill)
root(false)
&.inline
display inline-block
margin 0
&.disabled
opacity 0.7
&, *
cursor not-allowed !important
</style>

View File

@@ -1,3 +1,10 @@
import Vue from 'vue';
import * as JSON5 from 'json5';
Vue.filter('json5', x => {
return JSON5.stringify(x, null, 2);
});
require('./bytes');
require('./number');
require('./user');

View File

@@ -1,6 +1,7 @@
import Vue from 'vue';
import getAcct from '../../../../../misc/acct/render';
import getUserName from '../../../../../misc/get-user-name';
import { url } from '../../../config';
Vue.filter('acct', user => {
return getAcct(user);
@@ -10,6 +11,6 @@ Vue.filter('userName', user => {
return getUserName(user);
});
Vue.filter('userPage', (user, path?) => {
return `/@${Vue.filter('acct')(user)}${(path ? `/${path}` : '')}`;
Vue.filter('userPage', (user, path?, absolute = false) => {
return `${absolute ? url : ''}/@${Vue.filter('acct')(user)}${(path ? `/${path}` : '')}`;
});