From 4006e9aff3c4e497dc23fe5bb88fc28c82a717d3 Mon Sep 17 00:00:00 2001 From: alexnatalia Date: Mon, 9 Nov 2020 23:27:06 +0300 Subject: [PATCH 01/22] Added Border Radius configuration, updated Tabs and Button components and stories. --- src/components/Button/SButton.vue | 19 +++++++++++- src/components/Button/consts.ts | 3 +- src/components/Button/index.ts | 4 +-- src/components/Tab/STabs.vue | 19 +++++++++++- src/components/Tab/consts.ts | 4 +++ src/components/Tab/index.ts | 4 +-- src/stories/SButton.stories.ts | 26 +++++++++++++++- src/stories/Tab/STabs.stories.ts | 6 +++- src/styles/button.scss | 1 - src/styles/tabs.scss | 50 ++++++++++++++++++++++++++----- src/styles/variables.scss | 12 ++++++++ src/types/index.ts | 7 +++++ 12 files changed, 137 insertions(+), 18 deletions(-) diff --git a/src/components/Button/SButton.vue b/src/components/Button/SButton.vue index 14cb1635..c1d1d0b3 100644 --- a/src/components/Button/SButton.vue +++ b/src/components/Button/SButton.vue @@ -27,7 +27,7 @@ import { PopoverPlacement } from 'element-ui/types/popover' import { SIcon } from '../Icon' import { STooltip, TooltipPlacement } from '../Tooltip' -import { ButtonTypes, ButtonSize, ButtonNativeTypes } from './consts' +import { ButtonTypes, ButtonSize, ButtonNativeTypes, BorderRadius } from './consts' @Component({ components: { SIcon, STooltip } @@ -52,6 +52,12 @@ export default class SButton extends Vue { * By default it's set to `"medium"` */ @Prop({ default: ButtonSize.MEDIUM, type: String }) readonly size!: string + /** + * Border radius of button. Possible values: `"big"`, `"medium"`, `"small"`, `"mini"`. + * + * By default it's set to `"small"` + */ + @Prop({ default: BorderRadius.SMALL, type: String }) readonly borderRadius!: string /** * Icon name from icon collection of this library */ @@ -113,6 +119,14 @@ export default class SButton extends Vue { return this.size } + get computedBrderRadius (): string { + if (this.borderRadius === BorderRadius.SMALL || + !(Object.values(BorderRadius) as Array).includes(this.borderRadius)) { + return '' + } + return this.borderRadius + } + get computedType (): string { if (this.type === ButtonTypes.PRIMARY) { return this.type @@ -127,6 +141,9 @@ export default class SButton extends Vue { } else if ((Object.values(ButtonSize) as Array).includes(this.size)) { cssClasses.push(`s-${this.size}`) } + if ((Object.values(BorderRadius) as Array).includes(this.borderRadius)) { + cssClasses.push(`s-border-radius-${this.borderRadius}`) + } if ((Object.values(ButtonTypes) as Array).includes(this.type)) { cssClasses.push(`s-${this.type}`) } diff --git a/src/components/Button/consts.ts b/src/components/Button/consts.ts index 4599450b..fcd3e222 100644 --- a/src/components/Button/consts.ts +++ b/src/components/Button/consts.ts @@ -1,4 +1,4 @@ -import { Size } from '../../types' +import { Size, SizeExtended } from '../../types' export enum ButtonTypes { PRIMARY = 'primary', @@ -15,3 +15,4 @@ export enum ButtonNativeTypes { } export const ButtonSize = Size +export const BorderRadius = SizeExtended diff --git a/src/components/Button/index.ts b/src/components/Button/index.ts index f91e9931..b0f63a08 100644 --- a/src/components/Button/index.ts +++ b/src/components/Button/index.ts @@ -1,5 +1,5 @@ import SButton from './SButton.vue' import SButtonGroup from './SButtonGroup.vue' -import { ButtonTypes, ButtonSize, ButtonNativeTypes } from './consts' +import { ButtonTypes, ButtonSize, ButtonNativeTypes, BorderRadius } from './consts' -export { SButton, SButtonGroup, ButtonTypes, ButtonSize, ButtonNativeTypes } +export { SButton, SButtonGroup, ButtonTypes, ButtonSize, ButtonNativeTypes, BorderRadius } diff --git a/src/components/Tab/STabs.vue b/src/components/Tab/STabs.vue index 48af7487..77303fcb 100644 --- a/src/components/Tab/STabs.vue +++ b/src/components/Tab/STabs.vue @@ -22,7 +22,7 @@