From 641753121625108fff148e24d6f53a3a549e93dd Mon Sep 17 00:00:00 2001 From: Stefan Popov Date: Sat, 1 Aug 2020 13:28:06 +0400 Subject: [PATCH 01/29] Fix button loading icon position --- src/components/Button/SButton.vue | 34 +++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/components/Button/SButton.vue b/src/components/Button/SButton.vue index 7f0e4a64..5622b21b 100644 --- a/src/components/Button/SButton.vue +++ b/src/components/Button/SButton.vue @@ -5,6 +5,7 @@ :native-type="nativeType" :size="computedSize" :class="computedClasses" + :style="computedStyles" :disabled="disabled" :loading="isLoading" :autofocus="autofocus" @@ -84,6 +85,7 @@ export default class SButton extends Vue { @Inject({ default: '', from: 'elForm' }) elForm!: ElForm @Inject({ default: '', from: 'elFormItem' }) elFormItem!: ElFormItem + private iconLeftOffset = 0 elementIcon = '' get computedSize (): string { @@ -120,6 +122,14 @@ export default class SButton extends Vue { return cssClasses } + get computedStyles () { + const styles = {} as any + if (this.loading) { + styles['--s-button-loading-left'] = `${this.iconLeftOffset}px` + } + return styles + } + get availableIcon (): string { if (!this.icon) { return '' @@ -143,6 +153,16 @@ export default class SButton extends Vue { handleClick (): void { this.$emit('click') } + + mounted (): void { + this.$watch('loading', (value) => { + if (!value) { + return + } + const el = this.$el.querySelector('span') as HTMLSpanElement + this.iconLeftOffset = el.offsetLeft + (el.offsetWidth / 2) - 10 + }, { immediate: true }) + } } @@ -151,12 +171,18 @@ export default class SButton extends Vue { .loading { padding: 12px 17.5px; - > :not(i) { - color: transparent; - } i { position: absolute; - left: 43%; + left: var(--s-button-loading-left); + } + &.small { + padding: 9px 15px; + i { + left: calc(var(--s-button-loading-left) + 2px); + } + } + > :not(i) { + color: transparent; } } From 9778d84a738719d0d68b58d85e1b5ad4cb5de777 Mon Sep 17 00:00:00 2001 From: Stefan Popov Date: Sat, 1 Aug 2020 13:29:02 +0400 Subject: [PATCH 02/29] Update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0f987500..2054fd9d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@soramitsu/soramitsu-js-ui", - "version": "0.2.4", + "version": "0.2.5", "private": false, "publishConfig": { "registry": "https://nexus.iroha.tech/repository/npm-soramitsu-private/" From da4ec4e44e2d47e6a78b2346ec4bd38a3aa7dc50 Mon Sep 17 00:00:00 2001 From: Stefan Popov Date: Sat, 1 Aug 2020 15:18:46 +0400 Subject: [PATCH 03/29] Fix input v-model --- src/components/Input/SInput.vue | 4 +++- src/stories/SInput.stories.ts | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/Input/SInput.vue b/src/components/Input/SInput.vue index 17a652ec..8cf14ce6 100644 --- a/src/components/Input/SInput.vue +++ b/src/components/Input/SInput.vue @@ -30,7 +30,7 @@ /> @@ -45,6 +45,7 @@ import { Autocomplete, InputType } from './consts' @Component export default class SInput extends Vue { readonly InputType = InputType + readonly emptyValue = null /** * Type of input. It can be "text" or "textarea" or any native input type. * `"text"` by default @@ -129,6 +130,7 @@ export default class SInput extends Vue { @Watch('model') private handleValueChange (value: string | number): void { + this.$emit('input', value) this.$emit('change', value) } diff --git a/src/stories/SInput.stories.ts b/src/stories/SInput.stories.ts index f1269566..9ad8258e 100644 --- a/src/stories/SInput.stories.ts +++ b/src/stories/SInput.stories.ts @@ -160,6 +160,7 @@ export const textFileInput = () => ({ type="text-file" placeholder="Upload or input text" :accept="accept" + @change="(value) => handleChange(value, input)" />`, data: () => ({ input: '' @@ -168,5 +169,10 @@ export const textFileInput = () => ({ accept: { default: text('Accept', '*/*') } + }, + methods: { + handleChange: (value, input) => { + console.log(`v-model=${input}`, `@change=${value}`) + } } }) From fd7d4ffdb69a5927cceac7bbd427b22166b317a4 Mon Sep 17 00:00:00 2001 From: Stefan Popov Date: Sun, 2 Aug 2020 01:33:26 +0400 Subject: [PATCH 04/29] Fix checkbox v-model --- src/components/Checkbox/SCheckbox.vue | 17 +++++++++++++++-- src/stories/SCheckbox.stories.ts | 10 ++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/components/Checkbox/SCheckbox.vue b/src/components/Checkbox/SCheckbox.vue index 823ca3d4..ac579b6e 100644 --- a/src/components/Checkbox/SCheckbox.vue +++ b/src/components/Checkbox/SCheckbox.vue @@ -1,7 +1,7 @@