Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(3000): Welcome panel #18842

Merged
merged 73 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
01ddcca
Improve banner layout with container queries
benjackwhite Nov 23, 2023
ac8c586
Update UI snapshots for `chromium` (1)
github-actions[bot] Nov 23, 2023
a28b9e4
Fix
benjackwhite Nov 23, 2023
b5c7468
Update UI snapshots for `chromium` (1)
github-actions[bot] Nov 23, 2023
635ed63
Fix
benjackwhite Nov 23, 2023
0544d51
Fixes
benjackwhite Nov 23, 2023
214c782
Fix up closing
benjackwhite Nov 23, 2023
2f91d4b
Started adding stories
benjackwhite Nov 23, 2023
592fe45
Fixed up when it gets shown
benjackwhite Nov 23, 2023
07d3406
Merge branch 'master' into feat/welcome-to-3000
benjackwhite Nov 23, 2023
525d9bc
Fixes
benjackwhite Nov 23, 2023
fdae1b1
Update UI snapshots for `chromium` (1)
github-actions[bot] Nov 23, 2023
447bd70
Fixes
benjackwhite Nov 23, 2023
38cecad
fix
benjackwhite Nov 23, 2023
0497658
Merge branch 'feat/welcome-to-3000' of github.com:PostHog/posthog int…
benjackwhite Nov 23, 2023
f12d7c9
Merge branch 'master' into feat/welcome-to-3000
benjackwhite Nov 23, 2023
bc90f35
Update UI snapshots for `chromium` (1)
github-actions[bot] Nov 23, 2023
499c7d1
Fix
benjackwhite Nov 23, 2023
dca580d
PR feedback
benjackwhite Nov 24, 2023
48e88b8
Added event for the flag
benjackwhite Nov 24, 2023
054508d
Merge branch 'master' into feat/welcome-to-3000
corywatilo Nov 27, 2023
73c4261
updates
benjackwhite Nov 29, 2023
04a7c36
Merge
benjackwhite Nov 29, 2023
a77bf08
Bunch of fixes
benjackwhite Nov 29, 2023
8ae149c
Update UI snapshots for `chromium` (1)
github-actions[bot] Nov 29, 2023
e819032
Update UI snapshots for `chromium` (2)
github-actions[bot] Nov 29, 2023
869e3b7
Fixes
benjackwhite Nov 29, 2023
4510766
Merge branch 'feat/welcome-to-3000' of github.com:PostHog/posthog int…
benjackwhite Nov 29, 2023
349332b
Fix lemon banner small size and add sidepanel stories
benjackwhite Nov 29, 2023
a63379b
Fix
benjackwhite Nov 29, 2023
48473de
Update UI snapshots for `chromium` (1)
github-actions[bot] Nov 29, 2023
2ddc406
Merge branch 'fix/just-banners' into feat/welcome-to-3000
benjackwhite Nov 29, 2023
5e825d8
Merge branch 'feat/welcome-to-3000' of github.com:PostHog/posthog int…
benjackwhite Nov 29, 2023
8ced783
Merge branch 'master' into feat/welcome-to-3000
benjackwhite Nov 29, 2023
d06f6c3
Update frontend/src/layout/navigation-3000/sidepanel/panels/SidePanel…
benjackwhite Nov 29, 2023
0f0b342
Fix
benjackwhite Nov 29, 2023
2c80063
Update UI snapshots for `chromium` (1)
github-actions[bot] Nov 29, 2023
bcc56ae
Update UI snapshots for `chromium` (2)
github-actions[bot] Nov 29, 2023
1dfb49a
Fix
benjackwhite Nov 29, 2023
f0c132d
Merge branch 'master' into feat/welcome-to-3000
benjackwhite Nov 29, 2023
11b96d9
Rework the welcome copy and tune styles
Twixes Nov 29, 2023
e76fbd7
Remove a "the"
Twixes Nov 29, 2023
adb0f02
Update UI snapshots for `chromium` (1)
github-actions[bot] Nov 29, 2023
f28cfc5
Merge branch 'master' into feat/welcome-to-3000
corywatilo Nov 30, 2023
8afcc3e
Update UI snapshots for `chromium` (1)
github-actions[bot] Nov 30, 2023
727e6c7
Update UI snapshots for `chromium` (2)
github-actions[bot] Nov 30, 2023
2b9e093
Merge branch 'master' into feat/welcome-to-3000
corywatilo Dec 1, 2023
afaf955
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 1, 2023
e2a822e
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 1, 2023
40bff04
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 1, 2023
4178540
updated design + content
corywatilo Dec 1, 2023
aab7a63
Merge branch 'feat/welcome-to-3000' of https://github.com/PostHog/pos…
corywatilo Dec 1, 2023
507fa90
transparent close button
corywatilo Dec 1, 2023
90b949d
dark mode images
corywatilo Dec 1, 2023
f45e252
finished dark mode screenshots
corywatilo Dec 1, 2023
32e4b94
Merge branch 'master' into feat/welcome-to-3000
corywatilo Dec 1, 2023
4026322
polish
corywatilo Dec 1, 2023
3acfd17
updated welcome icon, label
corywatilo Dec 1, 2023
06d5e94
updated welcome title to match tab
corywatilo Dec 1, 2023
6f72d70
tweaked spacing
corywatilo Dec 1, 2023
8923a3a
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 1, 2023
6e413b7
Merge branch 'master' into feat/welcome-to-3000
Twixes Dec 5, 2023
bd7b40c
Limit opening posthog.com links in side panel to docs
Twixes Dec 5, 2023
a9b9675
Clean up the panel
Twixes Dec 5, 2023
645d68e
Tune default and min width of side panel
Twixes Dec 5, 2023
becee00
Tweak some text
Twixes Dec 5, 2023
f953d15
The palette is no more
Twixes Dec 5, 2023
92a284f
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 5, 2023
f042e21
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 5, 2023
0d62428
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 5, 2023
e9bdf41
Constrain "Read the blog post" width
Twixes Dec 5, 2023
1fce892
Merge branch 'master' into feat/welcome-to-3000
Twixes Dec 5, 2023
289f04a
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified frontend/__snapshots__/lemon-ui-lemon-banner--closable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-banner--dismissable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-banner--error.png
benjackwhite marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-banner--info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-banner--success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-banner--warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-button--as-links--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-button--as-links--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-batchexports--create-export.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-notebooks--notebooks-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-surveys--surveys-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-other-login--sso-error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-other-settings--settings-project.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Meta, StoryFn } from '@storybook/react'
import { useActions } from 'kea'
import { router } from 'kea-router'
import { FEATURE_FLAGS } from 'lib/constants'
import { useEffect } from 'react'
import { App } from 'scenes/App'
import { urls } from 'scenes/urls'

import { setFeatureFlags } from '~/mocks/browser'
import { SidePanelTab } from '~/types'

import { sidePanelStateLogic } from './sidePanelStateLogic'

const meta: Meta = {
title: 'Scenes-App/SidePanels',
parameters: {
layout: 'fullscreen',
viewMode: 'story',
mockDate: '2023-07-04', // To stabilize relative dates
},
}
export default meta

const BaseTemplate = (props: { panel: SidePanelTab }): JSX.Element => {
const { openSidePanel } = useActions(sidePanelStateLogic)
setFeatureFlags([FEATURE_FLAGS.POSTHOG_3000])
useEffect(() => {
router.actions.push(urls.dashboards())
openSidePanel(props.panel)
}, [])

return <App />
}

export const SidePanelDocs: StoryFn = () => {
return <BaseTemplate panel={SidePanelTab.Docs} />
}

export const SidePanelWelcome: StoryFn = () => {
return <BaseTemplate panel={SidePanelTab.Welcome} />
}

export const SidePanelSettings: StoryFn = () => {
return <BaseTemplate panel={SidePanelTab.Settings} />
}

export const SidePanelActivation: StoryFn = () => {
return <BaseTemplate panel={SidePanelTab.Activation} />
}

export const SidePanelNotebooks: StoryFn = () => {
return <BaseTemplate panel={SidePanelTab.Notebooks} />
}
8 changes: 8 additions & 0 deletions frontend/src/layout/navigation-3000/sidepanel/SidePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import clsx from 'clsx'
import { useActions, useValues } from 'kea'
import { Resizer } from 'lib/components/Resizer/Resizer'
import { resizerLogic, ResizerLogicProps } from 'lib/components/Resizer/resizerLogic'
import { IconFlare } from 'lib/lemon-ui/icons'
import { useEffect, useRef } from 'react'
import { NotebookPanel } from 'scenes/notebooks/NotebookPanel/NotebookPanel'

Expand All @@ -16,6 +17,7 @@ import { SidePanelDocs } from './panels/SidePanelDocs'
import { SidePanelFeaturePreviews } from './panels/SidePanelFeaturePreviews'
import { SidePanelSettings } from './panels/SidePanelSettings'
import { SidePanelSupport } from './panels/SidePanelSupport'
import { SidePanelWelcome } from './panels/SidePanelWelcome'
import { sidePanelLogic } from './sidePanelLogic'
import { sidePanelStateLogic } from './sidePanelStateLogic'

Expand Down Expand Up @@ -46,11 +48,17 @@ export const SidePanelTabs: Record<SidePanelTab, { label: string; Icon: any; Con
Icon: IconGear,
Content: SidePanelSettings,
},

[SidePanelTab.FeaturePreviews]: {
label: 'Previews',
Icon: IconFeatures,
Content: SidePanelFeaturePreviews,
},
[SidePanelTab.Welcome]: {
label: 'Welcome',
Icon: IconFlare,
Content: SidePanelWelcome,
},
}

export function SidePanel(): JSX.Element | null {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import { IconCursorClick, IconGear, IconHome, IconInfo, IconNight, IconNotebook, IconSearch } from '@posthog/icons'
import { LemonButton, Link } from '@posthog/lemon-ui'
import { useActions } from 'kea'
import posthog from 'posthog-js'
import { useEffect } from 'react'

import { KeyboardShortcut } from '../../components/KeyboardShortcut'
import { sidePanelStateLogic } from '../sidePanelStateLogic'

const blogPostUrl = 'https://posthog.com/blog/why-redesign'

export const SidePanelWelcome = (): JSX.Element => {
corywatilo marked this conversation as resolved.
Show resolved Hide resolved
const { closeSidePanel } = useActions(sidePanelStateLogic)

useEffect(() => {
return () => {
// Linked to the FF to ensure it isn't shown again
posthog.capture('3000 welcome acknowledged', {
$set: {
[`3000-welcome-acknowledged`]: true,
},
})
}
}, [])

return (
<div className="flex flex-col items-center justify-center m-4 my-10 flex-1">
<h1 className="font-bold text-4xl text-center">
Welcome to <span className="text-primary-3000">PostHog&nbsp;3000</span>
</h1>

<p className="max-w-120 text-center">
<b>PostHog 3000</b> is the codename for our revamped user experience. You can{' '}
<Link to={blogPostUrl}>read more about it here</Link> but the headline features you will notice are:
</p>
<ul className="space-y-4">
benjackwhite marked this conversation as resolved.
Show resolved Hide resolved
<li className="bg-bg-3000 border rounded p-4 flex gap-4 items-center">
<IconNight className="text-3xl" />
<div className="flex-1">
<h3 className="mb-0 font-semibold">Colors, data density, dark mode</h3>
Twixes marked this conversation as resolved.
Show resolved Hide resolved
<span>
A general refresh of our look and feel for enhanced visibility with improved data density
and a dark mode option
</span>
</div>
</li>
<li className="bg-bg-3000 border rounded p-4 flex gap-4 items-center">
<IconHome className="text-3xl" />
<div className="flex-1">
<h3 className="mb-0 font-semibold">New navigation menu </h3>
<span>
Organized into two main sections: 'project & data' and 'products', collapsible for even more
space
</span>
</div>
</li>
<li className="bg-bg-3000 border rounded p-4 flex gap-4 items-center">
<IconInfo className="text-3xl" />
<div className="flex-1">
<h3 className="mb-0 font-semibold">Side panel</h3>
<span>
A collapsible side panel for easy access to notebooks, in-app documentation, and support
</span>
</div>
</li>
<li className="bg-bg-3000 border rounded p-4 flex gap-4 items-center">
<IconNotebook className="text-3xl" />
<div className="flex-1">
<h3 className="mb-0 font-semibold">Notebooks</h3>
<span>
A feature for aggregating multiple insights, replays, persons or anything else on a single
page, aiding in data exploration and team collaboration
</span>
</div>
</li>
<li className="bg-bg-3000 border rounded p-4 flex gap-4 items-center">
<IconCursorClick className="text-3xl" />
<div className="flex-1">
<h3 className="mb-0 font-semibold">Toolbar 3000</h3>
<span>An updated toolbar with a modern design and dark mode compatibility</span>
</div>
</li>
<li className="bg-bg-3000 border rounded p-4 flex gap-4 items-center">
<IconSearch className="text-3xl" />
<div className="flex-1">
<h3 className="mb-0 font-semibold">Search + commands bar</h3>
<span>
A unified feature enabling navigation to most of PostHog's built-in features using keyboard
shortcuts - try it with <KeyboardShortcut shift k />
benjackwhite marked this conversation as resolved.
Show resolved Hide resolved
</span>
</div>
</li>
<li className="bg-bg-3000 border rounded p-4 flex gap-4 items-center">
<IconGear className="text-3xl" />
<div className="flex-1">
<h3 className="mb-0 font-semibold">Reorganized settings</h3>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been out for a while… so one hand it's true that the change is related, but may be confusing since it's the only thing unchanged by the 3000 feature flag

<span>
An improved organization of the project settings page for easier access and management
</span>
</div>
</li>
</ul>

<div className="flex items-center gap-2 mt-8">
<LemonButton to={blogPostUrl} size="large" type="secondary">
Tell me more
</LemonButton>
<LemonButton size="large" type="primary" onClick={() => closeSidePanel()}>
Get started
</LemonButton>
</div>
</div>
)
}
37 changes: 35 additions & 2 deletions frontend/src/layout/navigation-3000/sidepanel/sidePanelLogic.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { connect, kea, path, selectors } from 'kea'
import { afterMount, connect, kea, path, reducers, selectors } from 'kea'
import { activationLogic } from 'lib/components/ActivationSidebar/activationLogic'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
Expand All @@ -9,7 +9,7 @@ import { SidePanelTab } from '~/types'
import type { sidePanelLogicType } from './sidePanelLogicType'
import { sidePanelStateLogic } from './sidePanelStateLogic'

const SECRET_TABS = [SidePanelTab.Settings, SidePanelTab.FeaturePreviews]
const SECRET_TABS = [SidePanelTab.Settings, SidePanelTab.FeaturePreviews, SidePanelTab.Welcome]

export const sidePanelLogic = kea<sidePanelLogicType>([
path(['scenes', 'navigation', 'sidepanel', 'sidePanelLogic']),
Expand All @@ -24,9 +24,35 @@ export const sidePanelLogic = kea<sidePanelLogicType>([
sidePanelStateLogic,
['selectedTab', 'sidePanelOpen'],
],
actions: [sidePanelStateLogic, ['closeSidePanel']],
}),

reducers(() => ({
welcomeAnnouncementAcknowledged: [
false,
{ persist: true },
benjackwhite marked this conversation as resolved.
Show resolved Hide resolved
{
closeSidePanel: () => true,
},
],
})),

selectors({
shouldShowWelcomeAnnouncement: [
(s) => [s.welcomeAnnouncementAcknowledged, s.featureFlags],
(welcomeAnnouncementAcknowledged, featureFlags) => {
if (
featureFlags[FEATURE_FLAGS.POSTHOG_3000] &&
featureFlags[FEATURE_FLAGS.POSTHOG_3000_WELCOME_ANNOUNCEMENT] &&
!welcomeAnnouncementAcknowledged
) {
return true
}

return false
},
],

enabledTabs: [
(s) => [s.featureFlags, s.isCloudOrDev],
(featureFlags, isCloudOrDev) => {
Expand All @@ -43,6 +69,7 @@ export const sidePanelLogic = kea<sidePanelLogicType>([
tabs.push(SidePanelTab.Docs)
tabs.push(SidePanelTab.Settings)
tabs.push(SidePanelTab.Activation)
tabs.push(SidePanelTab.Welcome)

if (featureFlags[FEATURE_FLAGS.EARLY_ACCESS_FEATURE_SITE_BUTTON]) {
tabs.push(SidePanelTab.FeaturePreviews)
Expand Down Expand Up @@ -74,4 +101,10 @@ export const sidePanelLogic = kea<sidePanelLogicType>([
},
],
}),

afterMount(({ values }) => {
if (values.shouldShowWelcomeAnnouncement) {
sidePanelStateLogic.findMounted()?.actions.openSidePanel(SidePanelTab.Welcome)
}
}),
])
1 change: 1 addition & 0 deletions frontend/src/lib/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export const FEATURE_FLAGS = {
QUERY_ASYNC: 'query-async', // owner: @webjunkie
POSTHOG_3000: 'posthog-3000', // owner: @Twixes
POSTHOG_3000_NAV: 'posthog-3000-nav', // owner: @Twixes
POSTHOG_3000_WELCOME_ANNOUNCEMENT: 'posthog-3000-welcome-announcement', // owner: #posthog-3000
ENABLE_PROMPTS: 'enable-prompts', // owner: @lharries
FEEDBACK_SCENE: 'feedback-scene', // owner: @lharries
NOTEBOOKS: 'notebooks', // owner: #team-monitoring
Expand Down
13 changes: 11 additions & 2 deletions frontend/src/lib/lemon-ui/LemonBanner/LemonBanner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
border: solid 1px var(--border-3000);
border-radius: var(--radius);

&.LemonBanner--compact {
flex-direction: column;
padding: 0.5rem;
}

&.LemonBanner--info {
background-color: var(--primary-alt-highlight);
}
Expand All @@ -29,13 +34,17 @@
background-color: var(--success-highlight);
}

p {
margin-bottom: 0.25em;
.LemonBanner__icon {
line-height: 0;
}

> .LemonIcon {
flex-shrink: 0;
font-size: 1.5rem;
line-height: 0;
}

p {
margin-bottom: 0.25em;
}
}
19 changes: 19 additions & 0 deletions frontend/src/lib/lemon-ui/LemonBanner/LemonBanner.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,22 @@ Dismissable.args = {
dismissKey: 'storybook-banner',
onClose: () => alert('👋'),
}

export const Small: Story = Template.bind({})
Small.args = {
type: 'info',
children: 'This is a one-time message. Acknowledge it and move on with your life.',
className: 'w-50 resize-x overflow-hidden',
}

export const SmallWithButtons: Story = Template.bind({})
SmallWithButtons.args = {
type: 'info',
children: 'This is a one-time message. Acknowledge it and move on with your life.',
onClose: () => alert('👋'),
action: {
children: 'Acknowledge',
onClick: () => alert('👋'),
},
className: 'w-50 resize-x overflow-hidden',
}
46 changes: 33 additions & 13 deletions frontend/src/lib/lemon-ui/LemonBanner/LemonBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import './LemonBanner.scss'

import clsx from 'clsx'
import { useActions, useValues } from 'kea'
import { useResizeBreakpoints } from 'lib/hooks/useResizeObserver'
import { IconClose, IconInfo, IconWarning } from 'lib/lemon-ui/icons'
import { LemonButton, SideAction } from 'lib/lemon-ui/LemonButton'
import { LemonButtonPropsBase } from 'lib/lemon-ui/LemonButton/LemonButton'
Expand Down Expand Up @@ -46,20 +47,39 @@ export function LemonBanner({
return <></>
}

const { ref: wrapperRef, size } = useResizeBreakpoints({
0: 'compact',
400: 'normal',
})

const isCompact = size === 'compact'

return (
<div className={clsx('LemonBanner', `LemonBanner--${type}`, className)}>
{type === 'warning' || type === 'error' ? <IconWarning /> : <IconInfo />}
<div className="flex-1">{children}</div>
{action && <LemonButton type="secondary" {...action} />}
{showCloseButton && (
<LemonButton
status="primary-alt"
size="small"
icon={<IconClose />}
onClick={_onClose}
aria-label="close"
/>
)}
<div
className={clsx('LemonBanner', `LemonBanner--${type}`, isCompact && 'LemonBanner--compact', className)}
ref={wrapperRef}
>
<div className="flex items-center gap-2 grow">
{!isCompact ? (
type === 'warning' || type === 'error' ? (
<IconWarning className="LemonBanner__icon" />
) : (
<IconInfo className="LemonBanner__icon" />
)
) : null}
<div className="grow">{children}</div>
{!isCompact && action && <LemonButton type="secondary" {...action} />}
{showCloseButton && (
<LemonButton
status="primary-alt"
size="small"
icon={<IconClose />}
onClick={_onClose}
aria-label="close"
/>
)}
</div>
{isCompact && action && <LemonButton type="secondary" fullWidth {...action} />}
</div>
)
}
Loading