diff --git a/packages/core/lib/components/select/_select.scss b/packages/core/lib/components/select/_select.scss index e7c03df1..829b88c2 100644 --- a/packages/core/lib/components/select/_select.scss +++ b/packages/core/lib/components/select/_select.scss @@ -1,11 +1,14 @@ @import '../../global/mixins/form-items'; +$ray-icon-width: 1rem; + .#{$ray-class-prefix}select { border: $ray-border-width solid $ray-color-gray-60; background-color: $ray-color-white; border-radius: $ray-border-radius; position: relative; height: $ray-field-height; + display: flex; &::after { content: ''; @@ -50,6 +53,40 @@ } } + @mixin icon { + width: 1rem; + height: 1rem; + position: absolute; + line-height: 1; + top: 20px; + border-radius: 2px; + } + + &__icon--left { + @include icon; + left: $ray-field-h-spacing; + } + + &__icon--right { + @include icon; + // add spacing to compensate for the + right: calc(#{$ray-field-h-spacing} * 2 + 12px); + } + + &--with-icon-left { + .#{$ray-class-prefix}select__input, + .#{$ray-class-prefix}select__label { + padding-left: calc(#{$ray-field-h-spacing} * 2 + #{$ray-icon-width}); + } + } + + &--with-icon-right { + .#{$ray-class-prefix}select__input, + .#{$ray-class-prefix}select__label { + padding-right: calc(#{$ray-field-h-spacing} * 2 + #{$ray-icon-width}); + } + } + &--has-value { .#{$ray-class-prefix}select__label { @include label--active; @@ -107,6 +144,11 @@ padding-top: 0; padding-bottom: 0; } + + .#{$ray-class-prefix}select__icon--left, + .#{$ray-class-prefix}select__icon--right { + top: $ray-field-v-spacing-compact; + } } &--disabled { diff --git a/packages/core/stories/select.stories.js b/packages/core/stories/select.stories.js index c9ddbca7..8863f543 100644 --- a/packages/core/stories/select.stories.js +++ b/packages/core/stories/select.stories.js @@ -183,4 +183,84 @@ storiesOf('Select', module) > ); + }) + .addWithJSX('select, with icon', () => { + setTimeout(init); + + return withPadding( + <> +