diff --git a/.storybook/storybook.scss b/.storybook/storybook.scss index 60b3d6d8..88bdcb64 100644 --- a/.storybook/storybook.scss +++ b/.storybook/storybook.scss @@ -22,8 +22,9 @@ .storybook-rows { display: flex; - width: 100%; - min-width: 50vw; + width: 50vw; + min-width: 100%; + max-width: 100%; .storybook-row { width: 100%; diff --git a/package.json b/package.json index 296a347e..5a6ee061 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ebs-integrator/react-ebs-ui", - "version": "0.0.1-beta.8", + "version": "0.0.1-beta.9", "description": "Basic React UI elements.", "author": "EBS Integrator", "maintainers": [ diff --git a/src/components/atoms/Alert/Alert.scss b/src/components/atoms/Alert/Alert.scss index d0983f65..a6784625 100644 --- a/src/components/atoms/Alert/Alert.scss +++ b/src/components/atoms/Alert/Alert.scss @@ -6,7 +6,7 @@ padding: $alert-padding; border-radius: $border-radius; - svg { + .ebs-icon { width: $alert-icon-size; height: $alert-icon-size; border-radius: 100px; @@ -14,28 +14,30 @@ color: $success-color; } - &__type { - &--info { - border: 1px dashed $info-color; + &--info { + border: 1px dashed $info-color; - svg { - color: $info-color; - } + .ebs-icon { + color: $info-color; } + } - &--warning { - border: 1px dashed $warning-color; + &--warning { + border: 1px dashed $warning-color; - svg { - color: $warning-color; - } + .ebs-icon { + color: $warning-color; } + } + + &--error { + border: 1px dashed $danger-color; - &--error { - border: 1px solid $danger-color; + .ebs-icon { + color: $danger-color; - svg { - color: $danger-color; + path:last-child { + fill: $white; } } } diff --git a/src/components/atoms/Alert/Alert.tsx b/src/components/atoms/Alert/Alert.tsx index d93a43e5..48abe8f7 100644 --- a/src/components/atoms/Alert/Alert.tsx +++ b/src/components/atoms/Alert/Alert.tsx @@ -1,4 +1,6 @@ import * as React from 'react'; + +import cn from 'classnames'; import { Icon } from '../'; export type AlertType = 'success' | 'info' | 'warning' | 'error'; @@ -30,7 +32,7 @@ export const Alert: React.FC = ({ type = 'success', message = '', classNa }, [message, getHeader]); return message.length ? ( -
+
{renderByType[type]} {message}
diff --git a/src/components/atoms/Avatar/Avatar.scss b/src/components/atoms/Avatar/Avatar.scss index 73a40edd..e6fc92af 100644 --- a/src/components/atoms/Avatar/Avatar.scss +++ b/src/components/atoms/Avatar/Avatar.scss @@ -1,56 +1,49 @@ .ebs-avatar { + @include flex-center; position: relative; border-radius: $border-radius; - @include flex-center; - - &__type { - &--regular { - color: $primary-color; - background-color: $grey-100; - } - &--primary { - color: $white; - background-color: $primary-color; - } + &--circle, + &--circle &__img { + border-radius: 50%; + } - &--white { - color: $text-color; - background-color: $white; - } + &--regular { + color: $primary-color; + background-color: $grey-100; } - &.circle { - border-radius: 50%; + &--primary { + color: $white; + background-color: $primary-color; + } - .ebs-avatar__img { - border-radius: 50%; - } + &--white { + color: $text-color; + background-color: $white; } - &.ebs-avatar__size { - &--small { - min-width: $avatar-size-small; - width: $avatar-size-small; - height: $avatar-size-small; + &--small { + min-width: $avatar-size-small; + width: $avatar-size-small; + height: $avatar-size-small; + } - .ebs-avatar-short-alt { - font-size: $avatar-font-small; - } - } + &--small &-short-alt { + font-size: $avatar-font-small; + } - &--big { - min-width: $avatar-size-big; - width: $avatar-size-big; - height: $avatar-size-big; + &--big { + min-width: $avatar-size-big; + width: $avatar-size-big; + height: $avatar-size-big; + } - .ebs-avatar-short-alt { - font-size: $avatar-font-big; - } - } + &--big &-short-alt { + font-size: $avatar-font-big; } - .ebs-avatar__short-alt { + &__short-alt { position: absolute; left: 50%; top: 50%; @@ -59,7 +52,7 @@ white-space: nowrap; } - .ebs-avatar__img { + &__img { position: relative; width: 100%; height: 100%; @@ -68,7 +61,7 @@ object-fit: cover; } - .ebs-avatar__status { + &__status { position: absolute; bottom: rem(-2.5px); right: rem(-2.5px); @@ -85,65 +78,64 @@ background-color: $primary-color; } - &--uanctive { + &--inactive { background-color: $avatar-status-uanctive; } } -} -.ebs-avatar__card { - display: inline-flex; - align-items: center; - background-color: #f9f9f9; - border: 1px solid #dfddd6; - border-radius: $border-radius; + &__card { + display: inline-flex; + align-items: center; + background-color: #f9f9f9; + border: 1px solid #dfddd6; + border-radius: $border-radius; - .ebs-avatar { - border-top-right-radius: 0; - border-bottom-right-radius: 0; - height: rem(23px); - width: rem(23px); + &-alt { + color: #333; + padding: rem(0 $gutter-size / 2); + border-top-right-radius: $border-radius; + border-bottom-right-radius: $border-radius; + @include fontMedium; + font-size: rem(9px); + } img { border-top-right-radius: 0; border-bottom-right-radius: 0; } - } - .ebs-avatar__card-alt { - color: #333; - padding: rem(0 $gutter-size / 2); - border-top-right-radius: $border-radius; - border-bottom-right-radius: $border-radius; - @include fontMedium; - font-size: rem(9px); + .ebs-avatar { + border-top-right-radius: 0; + border-bottom-right-radius: 0; + height: rem(23px); + width: rem(23px); + } } -} -.ebs-avatar__inline { - display: flex; - align-items: center; + &__inline { + display: flex; + align-items: center; + text-align: left; - .ebs-avatar__inline-alt { - margin-left: $gutter-size; - @include fontSemiBold; - font-size: rem(12px); - color: $black; - } + &--reversed &-alt { + margin-left: 0; + margin-right: $gutter-size; + } - &.is-white .ebs-avatar__inline-alt { - color: $white; - } + &-alt { + margin-left: $gutter-size; + @include fontSemiBold; + font-size: rem(12px); + color: $black; + } - .ebs-avatar__inline-description { - font-size: rem(10px); - color: $avatar-description-color; - } + &--white &-alt { + color: $white; + } - &.is-reversed { - .ebs-avatar__inline-alt { - margin-left: 0; - margin-right: $gutter-size; + &-description { + font-size: rem(10px); + color: $avatar-description-color; } } } diff --git a/src/components/atoms/Avatar/Avatar.tsx b/src/components/atoms/Avatar/Avatar.tsx index 61899ed3..2f4fd659 100644 --- a/src/components/atoms/Avatar/Avatar.tsx +++ b/src/components/atoms/Avatar/Avatar.tsx @@ -33,8 +33,8 @@ export const Avatar: React.FC = ({ return (
{img ? ( diff --git a/src/components/atoms/Avatar/AvatarInline.tsx b/src/components/atoms/Avatar/AvatarInline.tsx index 4adecb8b..06b6fbfd 100644 --- a/src/components/atoms/Avatar/AvatarInline.tsx +++ b/src/components/atoms/Avatar/AvatarInline.tsx @@ -15,7 +15,16 @@ export const AvatarInline: React.FC = ({ description, reversed = false, }) => ( -
+
{!reversed && ( .ebs-icon { @@ -42,34 +41,24 @@ } } - &__type { - &--success { - .ebs-badge__container { - background-color: $badge-success-bg-color; - color: $white; - } - } + &__type--success &__container { + background-color: $badge-success-bg-color; + color: $white; + } - &--info { - .ebs-badge__container { - background-color: $badge-info-bg-color; - color: $white; - } - } + &__type--info &__container { + background-color: $badge-info-bg-color; + color: $white; + } - &--warning { - .ebs-badge__container { - background-color: $badge-warning-bg-color; - color: $white; - } - } + &__type--warning &__container { + background-color: $badge-warning-bg-color; + color: $white; + } - &--danger { - .ebs-badge__container { - background-color: $badge-danger-bg-color; - color: $white; - } - } + &__type--danger &__container { + background-color: $badge-danger-bg-color; + color: $white; } .ebs-sidebar__prefix > & { diff --git a/src/components/atoms/Badge/Badge.tsx b/src/components/atoms/Badge/Badge.tsx index d6f27ea9..370d8c8f 100644 --- a/src/components/atoms/Badge/Badge.tsx +++ b/src/components/atoms/Badge/Badge.tsx @@ -14,7 +14,9 @@ export const Badge: React.FC = ({ count, text, type = 'regular', classNam return (
- {(count || text) &&
{count || text}
} + {(count || text) && ( +
{count || text}
+ )} {children}
diff --git a/src/components/atoms/Button/Button.scss b/src/components/atoms/Button/Button.scss index 96073eaf..50ff5149 100644 --- a/src/components/atoms/Button/Button.scss +++ b/src/components/atoms/Button/Button.scss @@ -1,211 +1,206 @@ // fade @include fadeBackground('regularFade', #000); -.ebs-button__wrapper { - position: relative; - display: inline-block; - text-align: center; - border-radius: rem($border-radius); - transition: $transition-base; - border: 1px solid transparent; - - // button - .ebs-button { - width: 100%; - cursor: pointer; - font-size: rem(13px); - line-height: $btn-line-height; - border-color: transparent; - background: transparent; - padding: 0; - outline: none !important; - @include fontMedium; - - &-icon { - line-height: 0; - } +// button +.ebs-button { + @include fontMedium; + cursor: pointer; + width: 100%; + font-size: rem(13px); + line-height: $btn-line-height; + border-color: transparent; + background: transparent; + padding: 0; + outline: none !important; + + &--is-icon { + @include flex-center; + height: 100%; } - // button size - &.ebs-button__size { - &--large { - border-radius: $btn-border-radius-lg; + &--prefix button.ebs-button { + padding-left: rem(30px); + } - .ebs-button { - padding: rem($btn-padding-y-lg $btn-padding-x-lg); - font-weight: $btn-font-weight-lg; - font-size: rem($btn-font-size-lg); - } - } + &--icon { + display: flex; + align-items: center; + } - &--medium { - border-radius: $btn-border-radius; + &--block { + width: 100%; + display: block; + } - .ebs-button { - padding: rem($btn-padding-y $btn-padding-x); - font-weight: $btn-font-weight; - font-size: rem($btn-font-size); - } + // button type (Color) + &--primary { + border-color: $primary-color; + background-color: $primary-color; + color: $white; + + &:hover, + &.hover { + border-color: $primary-600; + background-color: $primary-600; + } + + &:active, + &.active { + border-color: $primary-700; + background-color: $primary-700; } + } - &--small { - border-radius: $btn-border-radius-sm; + &--primary & { + color: $white; - .ebs-button { - padding: rem($btn-padding-y-sm $btn-padding-x-sm); - font-weight: $btn-font-weight-sm; - font-size: rem($btn-font-size-sm); - line-height: $btn-line-height-sm; - } + :hover { + color: $white; } } - // button type (Color) - &.ebs-button__type { - &--primary { + &--fill { + border-color: $primary-100; + background-color: $primary-100; + color: $primary-color; + + &:hover, + &.hover { border-color: $primary-color; background-color: $primary-color; color: $white; .ebs-button { color: $white; - - &:hover { - color: $white; - } - } - - &:hover, - &.hover { - border-color: $primary-600; - background-color: $primary-600; - } - - &:active, - &.active { - border-color: $primary-700; - background-color: $primary-700; } } - &--fill { - border-color: $primary-100; - background-color: $primary-100; - color: $primary-color; + &:active, + &.active { + border-color: $primary-600; + background-color: $primary-600; + color: $white; .ebs-button { - color: $primary-color; + color: $white; } + } + } - &:hover, - &.hover { - border-color: $primary-color; - background-color: $primary-color; - color: $white; + &--fill & { + color: $primary-color; + } - & .ebs-button { - color: $white; - } - } + &--ghost.ebs-button__wrapper { + background-color: $btn-type-ghost-background; + border-color: $btn-type-ghost-border-color; + color: $btn-type-ghost-color; - &:active, - &.active { - border-color: $primary-600; - background-color: $primary-600; - color: $white; + &:hover, + &.hover { + border-color: $btn-type-ghost-hover-border-color; + background-color: $btn-type-ghost-hover-background; + color: $btn-type-ghost-hover-color; - & .ebs-button { - color: $white; - } + .ebs-button { + color: $btn-type-ghost-hover-color; } } - &--ghost { - background-color: $btn-type-ghost-background; - border-color: $btn-type-ghost-border-color; - color: $btn-type-ghost-color; + &:active, + &.active { + border-color: $btn-type-ghost-active-border-color; + background-color: $btn-type-ghost-active-background; + color: $btn-type-ghost-active-color; .ebs-button { - color: $btn-type-ghost-color; + color: $btn-type-ghost-active-color; } + } + } - &:hover, - &.hover { - border-color: $btn-type-ghost-hover-border-color; - background-color: $btn-type-ghost-hover-background; - color: $btn-type-ghost-hover-color; + &--ghost & { + color: $btn-type-ghost-color; + } - & .ebs-button { - color: $btn-type-ghost-hover-color; - } - } + &--text { + background-color: transparent; + color: $primary-color; - &:active, - &.active { - border-color: $btn-type-ghost-active-border-color; - background-color: $btn-type-ghost-active-background; - color: $btn-type-ghost-active-color; + &:hover, + &.hover { + background-color: transparent; - & .ebs-button { - color: $btn-type-ghost-active-color; - } + .ebs-button { + color: $primary-600; } } - &--text { + &:active, + &.active { background-color: transparent; - color: $primary-color; .ebs-button { - color: $primary-color; + color: $primary-700; } + } + } - &:hover, - &.hover { - background-color: transparent; - - & .ebs-button { - color: $primary-600; - } - } + &--text & { + color: $primary-color; + } - &:active, - &.active { - background-color: transparent; + &--disabled { + background-color: $border-color; - & .ebs-button { - color: $primary-700; - } - } + .ebs-button { + cursor: not-allowed; + color: $grey-500; } + } - &--disabled { - background-color: $border-color; + // button size + &--large { + border-radius: $btn-border-radius-lg; + } - .ebs-button { - cursor: not-allowed; - color: $grey-500; - } - } + &--large & { + padding: rem($btn-padding-y-lg $btn-padding-x-lg); + font-weight: $btn-font-weight-lg; + font-size: rem($btn-font-size-lg); } - &.has-prefix { - .ebs-button { - padding-left: rem(30px); - } + &--medium { + border-radius: $btn-border-radius; } - &.has-icon { - display: flex; - align-items: center; + &--medium & { + padding: rem($btn-padding-y $btn-padding-x); + font-weight: $btn-font-weight; + font-size: rem($btn-font-size); } - &.block { - width: 100%; - display: block; + &--small { + border-radius: $btn-border-radius-sm; + } + + &--small & { + padding: rem($btn-padding-y-sm $btn-padding-x-sm); + font-weight: $btn-font-weight-sm; + font-size: rem($btn-font-size-sm); + line-height: $btn-line-height-sm; } - .ebs-button__loading { + &__wrapper { + position: relative; + display: inline-block; + text-align: center; + border-radius: rem($border-radius); + transition: $transition-base; + border: 1px solid transparent; + } + + &__loading { position: absolute; left: 0; top: 0; @@ -214,10 +209,8 @@ border-radius: rem($border-radius); pointer-events: none; - &.ebs-button__loading { - &-regular { - animation: regularFade 0.25s forwards; - } + &-regular { + animation: regularFade 0.25s forwards; } .ebs-loader__spinner { @@ -228,7 +221,7 @@ } } - .ebs-button__prefix { + &__prefix { position: absolute; left: rem(10px); top: 50%; @@ -237,27 +230,25 @@ display: flex; align-items: center; } -} -.ebs-button__group { - display: flex; - flex-wrap: wrap; + &__group { + display: flex; + flex-wrap: wrap; - > .ebs-button__wrapper { - &:first-child { + .ebs-button__wrapper:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; } - &:not(:first-child):not(:last-child) { + .ebs-button__wrapper:not(:first-child):not(:last-child) { border-radius: 0; } - &:not(:last-child) { + .ebs-button__wrapper:not(:last-child) { border-right: none; } - &:last-child { + .ebs-button__wrapper:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; } diff --git a/src/components/atoms/Button/Button.tsx b/src/components/atoms/Button/Button.tsx index c6934808..5b803bb1 100644 --- a/src/components/atoms/Button/Button.tsx +++ b/src/components/atoms/Button/Button.tsx @@ -38,13 +38,13 @@ export const Button: React.FC = ({
= ({