Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/wet-hands-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'posthog-js': patch
---

add animation option for tour banners
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,17 @@ function StaticWrapper({ class: className, children }: BannerWrapperProps): h.JS
return <div class={className}>{children}</div>
}

export function ProductTourBanner({
export function ProductTourBanner(props: ProductTourBannerProps) {
return (
<div class="ph-tour-banner-wrapper">
<div class="ph-tour-banner-slide">
<ProductTourBannerInner {...props} />
</div>
</div>
)
}

function ProductTourBannerInner({
step,
onDismiss,
onActionClick,
Expand Down
19 changes: 19 additions & 0 deletions packages/browser/src/extensions/product-tours/product-tour.css
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,25 @@
}

/* Banner styles */
@keyframes ph-tour-banner-slide-in {
from {
grid-template-rows: 0fr;
}
to {
grid-template-rows: 1fr;
}
}

.ph-tour-banner-wrapper {
display: grid;
animation: ph-tour-banner-slide-in var(--ph-tour-banner-animation-duration, 300ms) ease-out forwards;
}

.ph-tour-banner-slide {
overflow: hidden;
min-height: 0;
}

.ph-tour-banner {
display: flex;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { createLogger } from '../../utils/logger'
import { document as _document, window as _window } from '../../utils/globals'
import { localStore, sessionStore } from '../../storage'
import { addEventListener } from '../../utils'
import { isNull, SurveyMatchType } from '@posthog/core'
import { isNull, isUndefined, SurveyMatchType } from '@posthog/core'
import { propertyComparisons } from '../../utils/property-utils'
import {
TOUR_SHOWN_KEY_PREFIX,
Expand Down Expand Up @@ -154,6 +154,10 @@ function retrieveBannerShadow(

addProductTourCSSVariablesToElement(div, tour.appearance)

if (!isUndefined(bannerConfig?.animation?.duration)) {
div.style.setProperty('--ph-tour-banner-animation-duration', `${bannerConfig.animation.duration}ms`)
}

const shadow = div.attachShadow({ mode: 'open' })

const stylesheet = getProductTourStylesheet()
Expand Down
3 changes: 3 additions & 0 deletions packages/browser/src/posthog-product-tours-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export interface ProductTourBannerConfig {
link?: string
tourId?: string
}
animation?: {
duration?: number
}
}

/** Button actions available on modal steps */
Expand Down
2 changes: 2 additions & 0 deletions playground/nextjs/pages/product-tours.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export default function ProductTours() {

return (
<div className="p-6 max-w-4xl mx-auto">
<div id="playground-banner-container"></div>

<h1 className="text-2xl font-bold mb-6">Product Tours Playground</h1>

{/* Tour Controls */}
Expand Down
Loading