From 8dc64b3b7f8f4979fa91baf7fab77546fc81aab4 Mon Sep 17 00:00:00 2001 From: alexnatalia Date: Wed, 21 Oct 2020 01:49:30 +0300 Subject: [PATCH 1/7] Added Radio Button Group functionality. --- src/components/Radio/SRadio.vue | 18 ++++- src/components/Radio/SRadioGroup.vue | 44 +++++++++++ src/components/Radio/index.ts | 3 +- src/components/index.ts | 3 +- src/index.ts | 3 + src/stories/SRadio.stories.ts | 105 +++++++++++++++++---------- src/types/components.ts | 1 + 7 files changed, 136 insertions(+), 41 deletions(-) create mode 100644 src/components/Radio/SRadioGroup.vue diff --git a/src/components/Radio/SRadio.vue b/src/components/Radio/SRadio.vue index a1bbe20d..d30b2246 100644 --- a/src/components/Radio/SRadio.vue +++ b/src/components/Radio/SRadio.vue @@ -1,5 +1,15 @@ + + diff --git a/src/components/Radio/index.ts b/src/components/Radio/index.ts index ec804fcd..9392d611 100644 --- a/src/components/Radio/index.ts +++ b/src/components/Radio/index.ts @@ -1,4 +1,5 @@ import SRadio from './SRadio.vue' +import SRadioGroup from './SRadioGroup.vue' import { RadioSize } from './consts' -export { SRadio, RadioSize } +export { SRadio, SRadioGroup, RadioSize } diff --git a/src/components/index.ts b/src/components/index.ts index d4cef978..6e2a173a 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -25,7 +25,7 @@ import { SMenu, SMenuItem, SMenuItemGroup, SSubmenu } from './Menu' import { SPagination } from './Pagination' import { SSlider } from './Slider' import { SSwitch } from './Switch' -import { SRadio } from './Radio' +import { SRadio, SRadioGroup } from './Radio' import { SRow } from './Layout/Row' import { SScrollSectionItem, SScrollSections } from './ScrollSections' import { SSelect, SOption, SOptionGroup } from './Select' @@ -66,6 +66,7 @@ export { SOptionGroup, SPagination, SRadio, + SRadioGroup, SRow, SScrollSectionItem, SScrollSections, diff --git a/src/index.ts b/src/index.ts index db402704..68a17fe3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -33,6 +33,7 @@ import { SOptionGroup, SPagination, SRadio, + SRadioGroup, SRow, SScrollSectionItem, SScrollSections, @@ -84,6 +85,7 @@ const components = [ { component: SOptionGroup, name: Components.SOptionGroup }, { component: SPagination, name: Components.SPagination }, { component: SRadio, name: Components.SRadio }, + { component: SRadioGroup, name: Components.SRadioGroup }, { component: SRow, name: Components.SRow }, { component: SScrollSectionItem, name: Components.SScrollSectionItem }, { component: SScrollSections, name: Components.SScrollSections }, @@ -151,6 +153,7 @@ export { SOption, SOptionGroup, SRadio, + SRadioGroup, SRow, SScrollSectionItem, SScrollSections, diff --git a/src/stories/SRadio.stories.ts b/src/stories/SRadio.stories.ts index 0b693797..dc74e96e 100644 --- a/src/stories/SRadio.stories.ts +++ b/src/stories/SRadio.stories.ts @@ -1,6 +1,6 @@ import { withKnobs, select, boolean } from '@storybook/addon-knobs' -import { SRadio, SRow, SCol } from '../components' +import { SRadio, SRadioGroup, SRow, SCol } from '../components' import { RadioSize } from '../components/Radio' export default { @@ -18,22 +18,22 @@ export const radioData = [ export const configurable = () => ({ components: { SRadio, SRow, SCol }, template: ` - - - {{ item.title }} - - - - v-model="{{ vModelValue }}", @change="{{ changeValue }}" - - `, + + + {{ item.title }} + + + + v-model="{{ vModelValue }}", @change="{{ changeValue }}" + + `, data: () => ({ vModelValue: 'first', changeValue: '', @@ -55,16 +55,16 @@ export const configurable = () => ({ export const disabled = () => ({ components: { SRadio, SRow }, template: ` - - {{ item.title }} - - `, + + {{ item.title }} + + `, data: () => ({ model: 'first', items: radioData @@ -74,18 +74,49 @@ export const disabled = () => ({ export const withBorders = () => ({ components: { SRadio, SRow }, template: ` - - {{ item.title }} - - `, + + {{ item.title }} + + `, data: () => ({ model: 'first', items: radioData }) }) + +export const radioButtonGroup = () => ({ + components: { SRadio, SRadioGroup, SRow }, + template: ` + + + {{ item.title }} + + +
+ v-model="{{ model }}" +
+
`, + data: () => ({ + model: 'first', + items: radioData + }), + props: { + size: { + default: select('Size', Object.values(RadioSize), RadioSize.MEDIUM) + }, + disabled: { + default: boolean('Disabled', false) + } + } +}) diff --git a/src/types/components.ts b/src/types/components.ts index 040e6aa0..2f3923f9 100644 --- a/src/types/components.ts +++ b/src/types/components.ts @@ -31,6 +31,7 @@ export enum Components { SOptionGroup = 'SOptionGroup', SPagination = 'SPagination', SRadio = 'SRadio', + SRadioGroup = 'SRadioGroup', SRow = 'SRow', SScrollSectionItem = 'SScrollSectionItem', SScrollSections = 'SScrollSections', From 93fc8f6c20b7476f68649157650a734ce854722f Mon Sep 17 00:00:00 2001 From: alexnatalia Date: Wed, 21 Oct 2020 02:58:13 +0300 Subject: [PATCH 2/7] Radio Button Group: Updated styles. --- src/stories/SRadio.stories.ts | 10 +++++- src/styles/radio.scss | 65 +++++++++++++++++++++++++++++++++++ src/styles/variables.scss | 4 +++ 3 files changed, 78 insertions(+), 1 deletion(-) diff --git a/src/stories/SRadio.stories.ts b/src/stories/SRadio.stories.ts index dc74e96e..a436f6e4 100644 --- a/src/stories/SRadio.stories.ts +++ b/src/stories/SRadio.stories.ts @@ -3,6 +3,12 @@ import { withKnobs, select, boolean } from '@storybook/addon-knobs' import { SRadio, SRadioGroup, SRow, SCol } from '../components' import { RadioSize } from '../components/Radio' +enum RadioButtonSize { + MEDIUM = 'medium', + SMALL = 'small', + MINI = 'mini' +} + export default { component: SRadio, title: 'Design System/Components/Radio', @@ -99,6 +105,8 @@ export const radioButtonGroup = () => ({ :key="item.label" v-model="model" :label="item.label" + :size="size" + :isRadioButton="true" > {{ item.title }} @@ -113,7 +121,7 @@ export const radioButtonGroup = () => ({ }), props: { size: { - default: select('Size', Object.values(RadioSize), RadioSize.MEDIUM) + default: select('Size', Object.values(RadioButtonSize), RadioButtonSize.MEDIUM) }, disabled: { default: boolean('Disabled', false) diff --git a/src/styles/radio.scss b/src/styles/radio.scss index f7a0079d..9d19cb04 100644 --- a/src/styles/radio.scss +++ b/src/styles/radio.scss @@ -1,6 +1,28 @@ @import "./variables"; @import "./common"; +$radio-button-border-width: 1px; +$radio-button-class: ".el-radio-button"; + +@mixin radio-button-size( + $modifier: "mini", + $size: $s-size-small, + $font-size: $s-font-size-small +) { + $radio-button-vertical-padding: #{($size - $font-size) / 2 - $radio-button-border-width}; + #{$radio-button-class} { + &--#{$modifier} { + height: $size; + line-height: $size; + #{$radio-button-class}__inner { + padding-top: $radio-button-vertical-padding; + padding-bottom: $radio-button-vertical-padding; + font-size: $font-size; + } + } + } +} + .el-radio { color: var(--s-color-basic-black); &.s-big { @@ -98,4 +120,47 @@ } } } + &-button { + &:hover { + #{$radio-button-class}__inner { + border-color: var(--s-color-main-brand); + } + } + &.is-disabled { + #{$radio-button-class}__inner { + color: var(--s-color-neutral-inactive); + } + } + &.is-disabled, + &.is-disabled:hover { + #{$radio-button-class}__inner { + border-color: var(--s-color-neutral-border); + } + } + &.is-active { + &:hover { + #{$radio-button-class}__inner { + background-color: var(--s-color-main-hover); + border-color: var(--s-color-main-hover); + } + } + &.is-disabled { + #{$radio-button-class}__inner { + color: var(--s-color-basic-white); + } + } + &.is-disabled, + &.is-disabled:hover { + #{$radio-button-class}__inner { + background-color: var(--s-color-main-inactive); + border-color: var(--s-color-main-inactive); + } + } + } + } + &-group { + @include radio-button-size; + @include radio-button-size("small", $s-size-medium, $s-font-size-big); + @include radio-button-size("medium", $s-size-big, $s-font-size-big); + } } diff --git a/src/styles/variables.scss b/src/styles/variables.scss index 5b8ccd38..4d403700 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -27,6 +27,10 @@ $s-border-radius-default: 4px !default; // Fonts $font-family-default: 'Sora', sans-serif !important; $font-family-mono: 'JetBrainsMono', monospace !important; +// Font sizes +$s-font-size-big: 14px !default; +$s-font-size-small: 12px !default; + // Responsive $--sm: 640px !default; $--md: 1024px !default; From bf5a20d12ed596fb1a9065b6c23b46e4bd0b398e Mon Sep 17 00:00:00 2001 From: alexnatalia Date: Wed, 21 Oct 2020 11:30:04 +0300 Subject: [PATCH 3/7] Slider and Radio Button Group Components: Changed size values to library ones. --- src/components/Radio/SRadioGroup.vue | 6 ++++-- src/components/Slider/SSlider.vue | 6 ++++-- src/components/Slider/consts.ts | 6 ++++++ src/components/Slider/index.ts | 3 ++- src/stories/SRadio.stories.ts | 8 +------- src/stories/SSlider.stories.ts | 11 ++--------- src/styles/radio.scss | 6 +++--- src/styles/slider.scss | 2 +- 8 files changed, 23 insertions(+), 25 deletions(-) create mode 100644 src/components/Slider/consts.ts diff --git a/src/components/Radio/SRadioGroup.vue b/src/components/Radio/SRadioGroup.vue index e8e1c946..93382e17 100644 --- a/src/components/Radio/SRadioGroup.vue +++ b/src/components/Radio/SRadioGroup.vue @@ -11,6 +11,8 @@