From a28b9e4d330bfb1c6740c935b1c3c9378d3d57ef Mon Sep 17 00:00:00 2001 From: Ben White Date: Thu, 23 Nov 2023 11:50:02 +0100 Subject: [PATCH] Fix --- .../lib/lemon-ui/LemonBanner/LemonBanner.scss | 47 ++++------------- .../lib/lemon-ui/LemonBanner/LemonBanner.tsx | 50 ++++++++++++------- 2 files changed, 43 insertions(+), 54 deletions(-) diff --git a/frontend/src/lib/lemon-ui/LemonBanner/LemonBanner.scss b/frontend/src/lib/lemon-ui/LemonBanner/LemonBanner.scss index 84c5d572ea43e..8f19bd42dcba9 100644 --- a/frontend/src/lib/lemon-ui/LemonBanner/LemonBanner.scss +++ b/frontend/src/lib/lemon-ui/LemonBanner/LemonBanner.scss @@ -9,7 +9,11 @@ min-height: 3rem; padding: 0.5rem 0.75rem; text-align: left; - container-type: inline-size; + + &.LemonBanner--compact { + flex-direction: column; + padding: 0.5rem; + } &.LemonBanner--info { background-color: var(--primary-alt-highlight); @@ -30,41 +34,12 @@ color: var(--success-dark); } - .LemonBanner__content { - display: flex; - flex: 1; - align-items: center; - justify-content: space-between; - gap: 0.5rem; - - .LemonBanner__content__row { - display: flex; - align-items: center; - gap: 0.5rem; - justify-content: space-between; - - p { - margin-bottom: 0.25em; - } - - > .LemonIcon { - line-height: 0; - flex-shrink: 0; - font-size: 1.5rem; - } - } + .LemonBanner__icon { + line-height: 0; + flex-shrink: 0; + font-size: 1.5rem; } - - @container (max-width: 30rem) { - .LemonBanner__content { - flex-direction: column; - align-items: stretch; - - .LemonBanner__content__row { - > .LemonIcon { - display: none; - } - } - } + p { + margin-bottom: 0.25em; } } diff --git a/frontend/src/lib/lemon-ui/LemonBanner/LemonBanner.tsx b/frontend/src/lib/lemon-ui/LemonBanner/LemonBanner.tsx index 838f57386f751..a175c346f4626 100644 --- a/frontend/src/lib/lemon-ui/LemonBanner/LemonBanner.tsx +++ b/frontend/src/lib/lemon-ui/LemonBanner/LemonBanner.tsx @@ -7,6 +7,7 @@ import { LemonButton, SideAction } from 'lib/lemon-ui/LemonButton' import { LemonButtonPropsBase } from 'lib/lemon-ui/LemonButton/LemonButton' import { lemonBannerLogic } from './lemonBannerLogic' +import { useResizeBreakpoints } from 'lib/hooks/useResizeObserver' export type LemonBannerAction = SideAction & Pick @@ -46,26 +47,39 @@ export function LemonBanner({ return <> } + const { ref: wrapperRef, size } = useResizeBreakpoints({ + 0: 'compact', + 400: 'normal', + }) + + const isCompact = size === 'compact' + return ( -
-
-
- {type === 'warning' || type === 'error' ? : } -
{children}
-
-
- {action && } - {showCloseButton && ( - } - onClick={_onClose} - aria-label="close" - /> - )} -
+
+
+ {!isCompact ? ( + type === 'warning' || type === 'error' ? ( + + ) : ( + + ) + ) : null} +
{children}
+ {!isCompact && action && } + {showCloseButton && ( + } + onClick={_onClose} + aria-label="close" + /> + )}
+ {isCompact && action && }
) }