diff --git a/package.json b/package.json index 211112ee..f694e1f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@soramitsu/soramitsu-js-ui", - "version": "0.3.0", + "version": "0.3.1", "private": false, "publishConfig": { "registry": "https://nexus.iroha.tech/repository/npm-soramitsu-private/" diff --git a/src/components/DatePicker/SDatePicker.vue b/src/components/DatePicker/SDatePicker.vue index 18f8f5be..04fbc835 100644 --- a/src/components/DatePicker/SDatePicker.vue +++ b/src/components/DatePicker/SDatePicker.vue @@ -52,7 +52,6 @@ export default class SDatePicker extends Vue { * `"year"`/`"month"`/`"date"`/`"dates"`/`"datetime"`/`"week"`/`"datetimerange"`/`"daterange"`/`"monthrange"` */ @Prop({ type: String, default: PickerTypes.DATE }) readonly type!: string - /** * Input type of the datepicker component. Available values: `"input"`, `"select"`. * `"input"` can be set only when `type` is not range. Otherwise, `"select"` will be set automatically. @@ -190,9 +189,12 @@ export default class SDatePicker extends Vue { this.$emit('change', value) } + get isRange (): boolean { + return ([PickerTypes.DATETIMERANGE, PickerTypes.DATERANGE, PickerTypes.MONTHRANGE] as Array).includes(this.type) + } + get isInputType (): boolean { - return !([PickerTypes.DATETIMERANGE, PickerTypes.DATERANGE, PickerTypes.MONTHRANGE] as Array).includes(this.type) && - this.inputType === InputTypes.INPUT + return !this.isRange && this.inputType === InputTypes.INPUT } get willHaveClearButton (): boolean { @@ -221,7 +223,7 @@ export default class SDatePicker extends Vue { if (this.disabled) { cssClasses.push('disabled') } - if (this.model) { + if ((!this.isRange && this.model) || (this.isRange && this.model.length !== 0)) { cssClasses.push('has-value') } return cssClasses @@ -339,6 +341,9 @@ export default class SDatePicker extends Vue { } &.select { .el-date-editor { + .el-input__inner, .el-range-input, .el-range-separator { + font-weight: bold; + } &.el-input__inner, & .el-input__inner { border-radius: 8px; padding-left: 12px; @@ -347,6 +352,7 @@ export default class SDatePicker extends Vue { } &::placeholder, .el-range-input::placeholder { color: $color-neutral-tertiary; + font-weight: bold; } } } @@ -365,6 +371,7 @@ export default class SDatePicker extends Vue { top: 30%; pointer-events: none; color: $color-neutral-tertiary; + transition: transform .3s; } &.has-value { .s-icon-chevron-bottom { diff --git a/src/components/Pagination/SPagination.vue b/src/components/Pagination/SPagination.vue index f05fc612..4f1b1aaa 100644 --- a/src/components/Pagination/SPagination.vue +++ b/src/components/Pagination/SPagination.vue @@ -77,13 +77,13 @@ export default class SPagination extends Vue { */ @Prop({ default: '', type: String }) readonly popperClass!: string /** - * Custom class name for the total element of the pagination component + * Styles object for the total element of the pagination component */ - @Prop({ default: '', type: String }) readonly totalClass!: string + @Prop() readonly totalStyle!: object /** - * Custom class name for the sizes element of the pagination component + * Styles object for the sizes element of the pagination component */ - @Prop({ default: '', type: String }) readonly sizesClass!: string + @Prop() readonly sizesStyle!: object /** * Text of the previous button */ @@ -118,11 +118,15 @@ export default class SPagination extends Vue { const items = Array.from(this.pagination.$el.childNodes) as Array this.totalItem = items.find(item => item.className === 'el-pagination__total') this.sizesItem = items.find(item => item.className === 'el-pagination__sizes') - if (this.totalItem && this.totalClass) { - (this.totalItem as Element).classList.add(this.totalClass) + if (this.totalItem && this.totalStyle) { + for (const styleProp in this.totalStyle) { + (this.totalItem as HTMLElement).style[styleProp] = this.totalStyle[styleProp] + } } - if (this.sizesItem && this.sizesClass) { - (this.sizesItem as Element).classList.add(this.sizesClass) + if (this.sizesItem && this.sizesStyle) { + for (const styleProp in this.sizesStyle) { + (this.sizesItem as HTMLElement).style[styleProp] = this.sizesStyle[styleProp] + } } } @@ -239,6 +243,7 @@ export default class SPagination extends Vue { } .el-pagination__total, .per-page-text, .el-pagination__jump { color: $color-neutral-secondary; + font-weight: normal; } .el-pager li { color: $color-basic-black; diff --git a/src/components/Select/SOption.vue b/src/components/Select/SOption.vue new file mode 100644 index 00000000..1cea17fa --- /dev/null +++ b/src/components/Select/SOption.vue @@ -0,0 +1,32 @@ + + + + + diff --git a/src/components/Select/SOptionGroup.vue b/src/components/Select/SOptionGroup.vue new file mode 100644 index 00000000..df01ef52 --- /dev/null +++ b/src/components/Select/SOptionGroup.vue @@ -0,0 +1,34 @@ + + + + + diff --git a/src/components/Select/SSelect.vue b/src/components/Select/SSelect.vue new file mode 100644 index 00000000..8ed019e1 --- /dev/null +++ b/src/components/Select/SSelect.vue @@ -0,0 +1,411 @@ + + + + + diff --git a/src/components/Select/consts.ts b/src/components/Select/consts.ts new file mode 100644 index 00000000..0484a8e2 --- /dev/null +++ b/src/components/Select/consts.ts @@ -0,0 +1,4 @@ +export enum InputTypes { + INPUT = 'input', + SELECT = 'select' +} diff --git a/src/components/Select/index.ts b/src/components/Select/index.ts new file mode 100644 index 00000000..fa6ba46e --- /dev/null +++ b/src/components/Select/index.ts @@ -0,0 +1,6 @@ +import SSelect from './SSelect.vue' +import SOption from './SOption.vue' +import SOptionGroup from './SOptionGroup.vue' +import { InputTypes } from './consts' + +export { SSelect, SOption, SOptionGroup, InputTypes } diff --git a/src/components/index.ts b/src/components/index.ts index 6a7f0ed5..e6622472 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -24,6 +24,7 @@ import { SMenu, SMenuItem, SMenuItemGroup, SSubmenu } from './Menu' import { SPagination } from './Pagination' import { SRow } from './Layout/Row' import { SScrollSectionItem, SScrollSections } from './ScrollSections' +import { SSelect, SOption, SOptionGroup } from './Select' import { STab, STabs } from './Tab' import { STable, STableColumn } from './Table' import { STooltip } from './Tooltip' @@ -57,10 +58,13 @@ export { SMenu, SMenuItem, SMenuItemGroup, + SOption, + SOptionGroup, SPagination, SRow, SScrollSectionItem, SScrollSections, + SSelect, SSubmenu, STab, STabs, diff --git a/src/index.ts b/src/index.ts index 2a066fa5..e8d3487e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,10 +29,13 @@ import { SMenu, SMenuItem, SMenuItemGroup, + SOption, + SOptionGroup, SPagination, SRow, SScrollSectionItem, SScrollSections, + SSelect, SSubmenu, STab, STabs, @@ -74,10 +77,13 @@ const components = [ { component: SMenu, name: Components.SMenu }, { component: SMenuItem, name: Components.SMenuItem }, { component: SMenuItemGroup, name: Components.SMenuItemGroup }, + { component: SOption, name: Components.SOption }, + { component: SOptionGroup, name: Components.SOptionGroup }, { component: SPagination, name: Components.SPagination }, { component: SRow, name: Components.SRow }, { component: SScrollSectionItem, name: Components.SScrollSectionItem }, { component: SScrollSections, name: Components.SScrollSections }, + { component: SSelect, name: Components.SSelect }, { component: SSubmenu, name: Components.SSubmenu }, { component: STab, name: Components.STab }, { component: STabs, name: Components.STabs }, @@ -136,9 +142,12 @@ export { SMenuItem, SMenuItemGroup, SPagination, + SOption, + SOptionGroup, SRow, SScrollSectionItem, SScrollSections, + SSelect, SSubmenu, STab, STabs, diff --git a/src/stories/Select/SOption.stories.ts b/src/stories/Select/SOption.stories.ts new file mode 100644 index 00000000..79770041 --- /dev/null +++ b/src/stories/Select/SOption.stories.ts @@ -0,0 +1,44 @@ +import { text, withKnobs, boolean } from '@storybook/addon-knobs' + +import { SSelect, SRow, SCol, SOption } from '../../components' + +export default { + component: SOption, + title: 'Design System/Select/Option', + decorators: [withKnobs], + excludeStories: /.*Data$/ +} + +export const optionsData = [ + { label: 'First', value: 'first' }, + { label: 'Second', value: 'second' }, + { label: 'Third', value: 'third' } +] +export const configurable = () => ({ + components: { SSelect, SOption, SRow, SCol }, + template: ` + + + + + + + `, + data: () => ({ + model: '', + options: optionsData + }), + props: { + disabled: { + default: boolean('Disabled', false) + }, + label: { + default: text('Label', 'Custom') + } + } +}) diff --git a/src/stories/Select/SOptionGroup.stories.ts b/src/stories/Select/SOptionGroup.stories.ts new file mode 100644 index 00000000..49c9a274 --- /dev/null +++ b/src/stories/Select/SOptionGroup.stories.ts @@ -0,0 +1,53 @@ +import { text, withKnobs, boolean } from '@storybook/addon-knobs' + +import { SSelect, SRow, SCol, SOption, SOptionGroup } from '../../components' + +export default { + component: SOptionGroup, + title: 'Design System/Select/Option Group', + decorators: [withKnobs], + excludeStories: /.*Data$/ +} + +export const optionsData = [ + { label: 'First', value: 'first' }, + { label: 'Second', value: 'second' }, + { label: 'Third', value: 'third' } +] +export const configurable = () => ({ + components: { SSelect, SOption, SRow, SCol, SOptionGroup }, + template: ` + + + + + + + + + + + `, + data: () => ({ + model: '', + options: optionsData + }), + props: { + disabled: { + default: boolean('Disabled', false) + }, + label: { + default: text('Label', 'Custom') + } + } +}) diff --git a/src/stories/Select/SSelect.stories.ts b/src/stories/Select/SSelect.stories.ts new file mode 100644 index 00000000..0fb66cba --- /dev/null +++ b/src/stories/Select/SSelect.stories.ts @@ -0,0 +1,153 @@ +import { text, withKnobs, boolean, number } from '@storybook/addon-knobs' + +import { SSelect, SRow, SCol, SOption } from '../../components' +import { InputTypes } from '../../components/Select' + +export default { + component: SSelect, + title: 'Design System/Select', + decorators: [withKnobs], + excludeStories: /.*Data$/ +} + +export const differentInputsData = Object.values(InputTypes).map(inputType => ({ inputType, model: '' })) +export const optionsData = [ + { label: 'First', value: 'first' }, + { label: 'Second', value: 'second' }, + { label: 'Third', value: 'third' } +] + +export const configurable = () => ({ + components: { SSelect, SOption, SRow, SCol }, + template: ` + +
"{{ item.inputType }}" input type
+ + + +
+
`, + data: () => ({ + model: '', + items: differentInputsData, + options: optionsData + }), + props: { + disabled: { + default: boolean('Disabled', false) + }, + loading: { + default: boolean('Loading', false) + }, + multiple: { + default: boolean('Multiple', false) + }, + clearable: { + default: boolean('Clearable', false) + }, + multipleLimit: { + default: number('Multiple limit', 0) + }, + placeholder: { + default: text('Placeholder', 'Select') + }, + multipleTextPrefix: { + default: text('Multiple text prefix', 'Data') + }, + loadingText: { + default: text('Loading text', 'Loading') + }, + noDataText: { + default: text('No data text', 'No data') + } + }, + methods: { + handleChange: (selected) => console.log('handleChange', selected) + } +}) + +export const multiple = () => ({ + components: { SSelect, SOption, SRow, SCol }, + template: ` + +
"{{ item.inputType }}" input type
+ + + +
+
`, + data: () => ({ + model: '', + items: differentInputsData, + options: optionsData + }), + props: { + multipleLimit: { + default: number('Multiple limit', 0) + }, + multipleTextPrefix: { + default: text('Multiple text prefix', 'Data') + } + }, + methods: { + handleChange: (selected) => console.log('handleChange', selected) + } +}) + +export const disabled = () => ({ + components: { SSelect, SOption, SRow, SCol }, + template: ` + +
{{ item.label }}
+ + + +
+
`, + data: () => ({ + items: differentInputsData.flatMap(item => [ + { ...item, label: `"${item.inputType}" input type` }, + { ...item, model: 'first', label: `"${item.inputType}" input type with selected value` } + ]), + options: optionsData + }) +}) diff --git a/src/styles/icons.scss b/src/styles/icons.scss index 73248705..53039ba4 100644 --- a/src/styles/icons.scss +++ b/src/styles/icons.scss @@ -11,6 +11,7 @@ -moz-osx-font-smoothing: grayscale; color: $color-basic-black; } +$icons-font: 'soramitsu-icons' !important; /*_____________________________________________Icons variables_____________________________________________*/ $s-icon-warning: "\e96c"; $s-icon-logout: "\e98c"; diff --git a/src/types/components.ts b/src/types/components.ts index 780ae75d..3b1a4701 100644 --- a/src/types/components.ts +++ b/src/types/components.ts @@ -27,10 +27,13 @@ export enum Components { SMenu = 'SMenu', SMenuItem = 'SMenuItem', SMenuItemGroup = 'SMenuItemGroup', + SOption = 'SOption', + SOptionGroup = 'SOptionGroup', SPagination = 'SPagination', SRow = 'SRow', SScrollSectionItem = 'SScrollSectionItem', SScrollSections = 'SScrollSections', + SSelect = 'SSelect', SSubmenu = 'SSubmenu', STab = 'STab', STabs = 'STabs',