diff --git a/src/ui/atoms/button/index.tsx b/src/ui/atoms/button/index.tsx index d7ca92c1..46493f78 100644 --- a/src/ui/atoms/button/index.tsx +++ b/src/ui/atoms/button/index.tsx @@ -32,7 +32,13 @@ const ButtonBase: React.FC = ({ variant = 'secondary', ...p }) => ( - @@ -40,11 +46,6 @@ const ButtonBase: React.FC = ({ export const Button = styled(ButtonBase)` ${box} - - & { - padding: 0; - } - --local-text-color: var(--woly-shape-text-default); --local-shape-color: var(--woly-shape-default); --local-border-color: var(--woly-shape-default); @@ -54,6 +55,7 @@ export const Button = styled(ButtonBase)` justify-content: center; box-sizing: border-box; + padding: 0; color: var(--local-text-color); font-size: var(--woly-font-size); diff --git a/src/ui/molecules/index.ts b/src/ui/molecules/index.ts index c9d75773..87323580 100644 --- a/src/ui/molecules/index.ts +++ b/src/ui/molecules/index.ts @@ -7,3 +7,4 @@ export { RadioButton } from './radio-button'; export { Popover } from './popover'; export { Select } from './select'; export { Switch } from './switch'; +export { Toast } from './toast'; diff --git a/src/ui/molecules/toast/index.tsx b/src/ui/molecules/toast/index.tsx new file mode 100644 index 00000000..1bd234d5 --- /dev/null +++ b/src/ui/molecules/toast/index.tsx @@ -0,0 +1,98 @@ +import * as React from 'react'; +import styled, { StyledComponent } from 'styled-components'; +import { Variant } from 'lib/types'; +import { box } from 'ui/elements'; + +interface ToastProps { + action?: React.ReactNode; + className?: string; + icon?: React.ReactNode; + outlined?: boolean; +} + +const ToastBase: React.FC = ({ + action, + children, + className, + icon, + outlined = false, + variant = 'secondary', +}) => ( +
+ {icon && {icon}} +
{children}
+ {action && {action}} +
+); + +export const Toast = styled(ToastBase)` + ${box} + --local-text-color: var(--woly-shape-text-default); + --local-shape-color: var(--woly-shape-default); + --local-border-color: var(--woly-shape-default); + --local-toast-gap: max(9px, calc(1px * var(--woly-component-level) * var(--woly-main-level))); + + display: flex; + flex-wrap: nowrap; + align-items: center; + + min-width: fit-content; + max-width: 75%; + + color: var(--local-text-color); + font-size: var(--woly-font-size); + line-height: var(--woly-line-height); + + background-color: var(--local-shape-color); + border: var(--woly-border-width) solid var(--local-border-color); + border-radius: var(--woly-rounding); + outline: none; + + &[data-outlined='true'] { + color: var(--local-shape-color); + + background-color: transparent; + + [data-icon='toast'] { + svg > path { + fill: var(--local-shape-color); + } + } + } + + [data-content] { + display: flex; + flex: 1; + flex-wrap: nowrap; + } + + [data-icon='toast'] { + --woly-component-level: 0; + --local-icon-size: var(--woly-line-height); + display: flex; + align-items: center; + justify-content: center; + width: var(--local-icon-size); + height: var(--local-icon-size); + } + + [data-action] { + --woly-component-level: 0; + display: flex; + align-items: center; + + & > *:not(:last-child) { + margin-right: var(--local-toast-gap); + } + } + + &:hover { + --local-text-color: var(--woly-shape-text-hover); + --local-border-color: var(--woly-shape-hover); + --local-shape-color: var(--woly-shape-hover); + } + + &:focus { + box-shadow: 0 0 0 var(--woly-border-width) var(--woly-focus); + } +` as StyledComponent<'div', Record, ToastProps & Variant>; diff --git a/src/ui/molecules/toast/usage.mdx b/src/ui/molecules/toast/usage.mdx new file mode 100644 index 00000000..fbe4db60 --- /dev/null +++ b/src/ui/molecules/toast/usage.mdx @@ -0,0 +1,164 @@ +--- +name: toast +category: molecules +package: 'woly' +--- + +import { Button, Toast } from 'ui'; +import { IconPlus, IconSearch } from 'static/icons'; +import { block, Playground, State } from 'lib/playground'; + +`Toast` is lightweight notification designed to mimic the push notifications. +Toast is intended to be small interruptions to your visitors or users, +and therefore should contain minimal, to-the-point, non-interactive content. + +### Example + +Siple Toast with text only + + + + + Режим предпросмотра таблицы + + + + +### Icons + +Toast can be used with icon on the left side. + + + + } variant="primary" outlined> + Перетащите файл формата XLS + + + + +Toast can also consist action block + + + + +