File tree Expand file tree Collapse file tree 6 files changed +88
-0
lines changed
packages/ui/src/components/custom Expand file tree Collapse file tree 6 files changed +88
-0
lines changed Original file line number Diff line number Diff line change 11import { DocsLayout } from "@ux-patterns/ui/components/custom/layout-notebook" ;
2+ import {
3+ TrackedLargeSearchToggle ,
4+ TrackedSearchToggle ,
5+ } from "@ux-patterns/ui/components/custom/tracked-search-toggle" ;
26import { baseOptions , linkItems } from "@/lib/layout.shared" ;
37import { source } from "@/lib/source" ;
8+ import { TRACKING_EVENTS } from "@/lib/tracking" ;
49
510export default function Layout ( { children } : LayoutProps < "/docs" > ) {
611 const { nav, ...base } = baseOptions ( ) ;
@@ -13,6 +18,19 @@ export default function Layout({ children }: LayoutProps<"/docs">) {
1318 tree = { source . pageTree }
1419 links = { linkItems }
1520 themeSwitch = { { enabled : false } }
21+ searchToggle = { {
22+ enabled : true ,
23+ components : {
24+ lg : (
25+ < TrackedLargeSearchToggle
26+ trackingEvent = { TRACKING_EVENTS . SEARCH_OPEN }
27+ />
28+ ) ,
29+ sm : (
30+ < TrackedSearchToggle trackingEvent = { TRACKING_EVENTS . SEARCH_OPEN } />
31+ ) ,
32+ } ,
33+ } }
1634 >
1735 { children }
1836 </ DocsLayout >
Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ export const TRACKING_EVENTS = {
2828
2929 // Documentation Events
3030 COPY_CODE_BLOCK : "Copy Code Block" ,
31+
32+ // Search Events
33+ SEARCH_OPEN : "Search Open" ,
3134 VIEW_API_REFERENCE : "View API Reference" ,
3235
3336 GET_STARTED_CLICK : "Get Started Click" ,
Original file line number Diff line number Diff line change 11import { DocsLayout } from "@ux-patterns/ui/components/custom/layout-notebook" ;
2+ import {
3+ TrackedLargeSearchToggle ,
4+ TrackedSearchToggle ,
5+ } from "@ux-patterns/ui/components/custom/tracked-search-toggle" ;
26import type { ReactNode } from "react" ;
37import { baseOptions , linkItems } from "@/lib/layout.shared" ;
48import { source } from "@/lib/source" ;
9+ import { TRACKING_EVENTS } from "@/lib/tracking" ;
510
611export default function Layout ( { children } : { children : ReactNode } ) {
712 const { nav, ...base } = baseOptions ( ) ;
@@ -14,6 +19,19 @@ export default function Layout({ children }: { children: ReactNode }) {
1419 tree = { source . pageTree }
1520 links = { linkItems }
1621 themeSwitch = { { enabled : false } }
22+ searchToggle = { {
23+ enabled : true ,
24+ components : {
25+ lg : (
26+ < TrackedLargeSearchToggle
27+ trackingEvent = { TRACKING_EVENTS . SEARCH_OPEN }
28+ />
29+ ) ,
30+ sm : (
31+ < TrackedSearchToggle trackingEvent = { TRACKING_EVENTS . SEARCH_OPEN } />
32+ ) ,
33+ } ,
34+ } }
1735 >
1836 { children }
1937 </ DocsLayout >
Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ export const TRACKING_EVENTS = {
2828 // External Links
2929 CANIUSE_LINK_CLICK : "CanIUse Link Click" ,
3030
31+ // Search Events
32+ SEARCH_OPEN : "Search Open" ,
33+
3134 // Pattern Navigation
3235 PATTERN_NEXT_CLICK : "Pattern Next Click" ,
3336 PATTERN_PREV_CLICK : "Pattern Previous Click" ,
Original file line number Diff line number Diff line change 1+ "use client" ;
2+
3+ import {
4+ LargeSearchToggle ,
5+ SearchToggle ,
6+ } from "fumadocs-ui/components/layout/search-toggle" ;
7+ import { usePlausible } from "next-plausible" ;
8+ import type { ComponentProps } from "react" ;
9+
10+ interface TrackedSearchProps {
11+ trackingEvent ?: string ;
12+ }
13+
14+ export function TrackedLargeSearchToggle ( {
15+ trackingEvent = "Search Open" ,
16+ ...props
17+ } : ComponentProps < typeof LargeSearchToggle > & TrackedSearchProps ) {
18+ const plausible = usePlausible ( ) ;
19+
20+ const handleClick = ( ) => {
21+ plausible ( trackingEvent ) ;
22+ } ;
23+
24+ return (
25+ < div onClick = { handleClick } >
26+ < LargeSearchToggle { ...props } />
27+ </ div >
28+ ) ;
29+ }
30+
31+ export function TrackedSearchToggle ( {
32+ trackingEvent = "Search Open" ,
33+ ...props
34+ } : ComponentProps < typeof SearchToggle > & TrackedSearchProps ) {
35+ const plausible = usePlausible ( ) ;
36+
37+ const handleClick = ( ) => {
38+ plausible ( trackingEvent ) ;
39+ } ;
40+
41+ return (
42+ < div onClick = { handleClick } >
43+ < SearchToggle { ...props } />
44+ </ div >
45+ ) ;
46+ }
You can’t perform that action at this time.
0 commit comments