diff --git a/package.json b/package.json index 4e9721d3..412e29fe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@soramitsu/soramitsu-js-ui", - "version": "0.2.7", + "version": "0.2.8", "private": false, "publishConfig": { "registry": "https://nexus.iroha.tech/repository/npm-soramitsu-private/" diff --git a/src/components/Input/SInput.vue b/src/components/Input/SInput.vue index aa0ba0a3..5f8a87fc 100644 --- a/src/components/Input/SInput.vue +++ b/src/components/Input/SInput.vue @@ -121,8 +121,21 @@ export default class SInput extends Vue { @Inject({ default: '', from: 'elForm' }) elForm!: ElForm focused = false + autofill = false model = this.value + mounted (): void { + this.$el.addEventListener('animationstart', this.changeAutofillValue) + } + + destroyed (): void { + this.$el.removeEventListener('animationstart', this.changeAutofillValue) + } + + private changeAutofillValue (e: any): void { + this.autofill = e.animationName === 'onAutoFillStart' + } + @Watch('value') private handlePropChange (value: string | number): void { this.model = value @@ -153,6 +166,9 @@ export default class SInput extends Vue { if (this.type === InputType.TEXT_FILE) { cssClasses.push('text-file') } + if (this.autofill) { + cssClasses.push('autofill') + } return cssClasses } @@ -298,6 +314,26 @@ export default class SInput extends Vue { border-color: $color-neutral-border; } } + &.autofill { + .placeholder { + background-color: transparent !important; + } + } + .el-input > input { + &:-webkit-autofill { + color: $color-basic-black !important; + animation-name: onAutoFillStart; // Expose a hook for JavaScript when auto fill is shown + } + &:not(:-webkit-autofill) { + animation-name: onAutoFillCancel; // Expose a hook for JS onAutoFillCancel + } + &:-internal-autofill-selected { + animation-name: onAutoFillStart; + } + &:not(:-internal-autofill-selected) { + animation-name: onAutoFillCancel; + } + } .placeholder + .el-input { > input { padding-top: 12px; @@ -332,5 +368,12 @@ export default class SInput extends Vue { } } } - +@keyframes onAutoFillStart { + from {/**/} + to {/**/} +} +@keyframes onAutoFillCancel { + from {/**/} + to {/**/} +} diff --git a/src/components/Tab/STabs.vue b/src/components/Tab/STabs.vue new file mode 100644 index 00000000..b2ef4019 --- /dev/null +++ b/src/components/Tab/STabs.vue @@ -0,0 +1,204 @@ + + + + + diff --git a/src/components/Tab/consts.ts b/src/components/Tab/consts.ts new file mode 100644 index 00000000..5ae902a9 --- /dev/null +++ b/src/components/Tab/consts.ts @@ -0,0 +1,12 @@ +export enum TabsType { + ROUNDED = 'rounded', + CARD = 'card', + BORDER_CARD = 'border-card' +} + +export enum TabsPosition { + TOP = 'top', + BOTTOM = 'bottom', + RIGHT = 'right', + LEFT = 'left' +} diff --git a/src/components/Tab/index.ts b/src/components/Tab/index.ts new file mode 100644 index 00000000..7381c960 --- /dev/null +++ b/src/components/Tab/index.ts @@ -0,0 +1,9 @@ +import Vue from 'vue' +import { TabPane } from 'element-ui' + +import STabs from './STabs.vue' +import { TabsType, TabsPosition } from './consts' + +const STab = Vue.component('STab', TabPane) + +export { STab, STabs, TabsType, TabsPosition } diff --git a/src/components/index.ts b/src/components/index.ts index 8daef1e2..e44872bf 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -22,6 +22,7 @@ import { SMain } from './Layout/Main' import { SMenu, SMenuItem, SMenuItemGroup, SSubmenu } from './Menu' import { SRow } from './Layout/Row' import { SScrollSectionItem, SScrollSections } from './ScrollSections' +import { STab, STabs } from './Tab' import { STable, STableColumn } from './Table' import { STooltip } from './Tooltip' @@ -57,6 +58,8 @@ export { SScrollSectionItem, SScrollSections, SSubmenu, + STab, + STabs, STable, STableColumn, STooltip diff --git a/src/index.ts b/src/index.ts index 9acebb02..8359691c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -32,12 +32,14 @@ import { SScrollSectionItem, SScrollSections, SSubmenu, + STab, + STabs, STable, STableColumn, STooltip } from './components' import { Components } from './types/components' -import { Message, MessageBox, Notification } from './plugins/elementUI' +import { Loading, Message, MessageBox, Notification } from './plugins/elementUI' const elements = [ { component: SApp, name: Components.SApp }, @@ -71,6 +73,8 @@ const elements = [ { component: SScrollSectionItem, name: Components.SScrollSectionItem }, { component: SScrollSections, name: Components.SScrollSections }, { component: SSubmenu, name: Components.SSubmenu }, + { component: STab, name: Components.STab }, + { component: STabs, name: Components.STabs }, { component: STable, name: Components.STable }, { component: STableColumn, name: Components.STableColumn }, { component: STooltip, name: Components.STooltip } @@ -87,6 +91,7 @@ if (typeof window !== 'undefined' && window.Vue) { } export { + Loading, Message, MessageBox, Notification, @@ -121,6 +126,8 @@ export { SScrollSectionItem, SScrollSections, SSubmenu, + STab, + STabs, STable, STableColumn, STooltip diff --git a/src/plugins/elementUI.ts b/src/plugins/elementUI.ts index aa090194..36d59aff 100644 --- a/src/plugins/elementUI.ts +++ b/src/plugins/elementUI.ts @@ -96,12 +96,14 @@ MsgBox.setDefaults({ cancelButtonText: 'Cancel', confirmButtonText: 'OK' }) +Vue.prototype.$loading = Loading.service Vue.prototype.$prompt = MessageBox.prompt Vue.prototype.$alert = MessageBox.alert Vue.prototype.$message = Message Vue.prototype.$notify = Notification // locale.use(lang) // TODO: it will be used later export { + Loading, MessageBox, Message, Notification diff --git a/src/stories/Tab/STabs.stories.ts b/src/stories/Tab/STabs.stories.ts new file mode 100644 index 00000000..12a66950 --- /dev/null +++ b/src/stories/Tab/STabs.stories.ts @@ -0,0 +1,46 @@ +import { boolean, select, withKnobs } from '@storybook/addon-knobs' + +import { STabs, STab } from '../../components' +import { TabsPosition, TabsType } from '../../components/Tab' + +export default { + component: STabs, + title: 'Design System/Tabs', + decorators: [withKnobs] +} + +export const defaultUsage = () => ({ + components: { STabs, STab }, + template: ` + First + Second + Third + `, + data: () => ({ + activeName: 'first' + }), + props: { + type: { + default: select('Type', [...Object.values(TabsType), '––'], '––') + }, + position: { + default: select('Position', Object.values(TabsPosition), TabsPosition.TOP) + }, + closable: { + default: boolean('Closable', false) + }, + addable: { + default: boolean('Addable', false) + }, + editable: { + default: boolean('Editable', false) + } + } +}) diff --git a/src/types/components.ts b/src/types/components.ts index 1480241e..981a0733 100644 --- a/src/types/components.ts +++ b/src/types/components.ts @@ -30,6 +30,8 @@ export enum Components { SScrollSectionItem = 'SScrollSectionItem', SScrollSections = 'SScrollSections', SSubmenu = 'SSubmenu', + STab = 'STab', + STabs = 'STabs', STable = 'STable', STableColumn = 'STableColumn', STooltip = 'STooltip'