diff --git a/CHANGELOG.md b/CHANGELOG.md index 4141117a9..332e99be4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `IconSVG` component to load SVG Icons. - `Suggestions` component. - `SearchHistory` component. +- `Badge` interactive variation. ### Changed - Move inline styles to external stylesheet to improve TBT diff --git a/src/components/cart/CartSidebar/cart-sidebar.scss b/src/components/cart/CartSidebar/cart-sidebar.scss index e7327516d..15ebee057 100644 --- a/src/components/cart/CartSidebar/cart-sidebar.scss +++ b/src/components/cart/CartSidebar/cart-sidebar.scss @@ -12,8 +12,10 @@ padding: var(--space-2) var(--page-padding-phone) var(--space-2); background-color: var(--bg-neutral-lightest); - [data-store-icon-button] { - margin-right: calc(-1 * var(--space-1)); + > [data-store-icon-button] { + &:last-of-type { + margin-right: calc(-1 * var(--space-1)); + } } } diff --git a/src/components/ui/Badge/Badge.tsx b/src/components/ui/Badge/Badge.tsx index a6efefe00..e0c12f7a0 100644 --- a/src/components/ui/Badge/Badge.tsx +++ b/src/components/ui/Badge/Badge.tsx @@ -1,26 +1,62 @@ import { Badge as UIBadge } from '@faststore/ui' import type { ReactNode } from 'react' import React from 'react' +import IconButton from 'src/components/ui/IconButton' +import Icon from 'src/components/ui/Icon' import './badge.scss' export type BadgeVariants = 'info' | 'highlighted' | 'neutral' +type InteractiveBadge = + | { + interactive: true + onClose?: () => void + } + | { + interactive?: false + onClose?: never + } + type Props = { small?: boolean variant?: BadgeVariants children: ReactNode -} + onClose?: () => void + interactive?: boolean +} & InteractiveBadge -const Badge = ({ small = false, variant, children, ...otherProps }: Props) => { +const Badge = ({ + variant, + children, + onClose, + small = false, + interactive = false, + ...otherProps +}: Props) => { return ( - {children} + {children} + {interactive && ( + + } + /> + )} ) } diff --git a/src/components/ui/Badge/badge.scss b/src/components/ui/Badge/badge.scss index 46ad684d0..715adbafb 100644 --- a/src/components/ui/Badge/badge.scss +++ b/src/components/ui/Badge/badge.scss @@ -1,7 +1,9 @@ .badge[data-store-badge] { + display: flex; + align-content: stretch; + align-items: stretch; width: fit-content; height: fit-content; - padding: var(--space-1) var(--space-2); color: var(--color-text); font-weight: var(--text-weight-bold); font-size: var(--text-size-2); @@ -9,9 +11,29 @@ text-transform: uppercase; border-radius: var(--border-radius-pill); + > span { + padding: var(--space-1) var(--space-2); + } + &[data-store-badge="small"] { - padding: var(--space-0) var(--space-2); font-size: var(--text-size-0); + + > span { + padding: var(--space-0) var(--space-2); + } + } + + [data-store-icon-button] { + width: var(--tap-min-size); + height: auto; + color: var(--color-neutral-7); + border-top-right-radius: var(--border-radius-pill); + border-bottom-right-radius: var(--border-radius-pill); + + &:hover, &:focus { + background-color: var(--color-black-transparent-10); + background-blend-mode: multiply; + } } }