'use client'; import React from 'react'; import classNames from 'classnames'; import { ContentKitClientElementProps } from './types'; import { ContentKitCard } from '@gitbook/api'; import { useContentKitClientContext } from './context'; /** * Interactive card element. */ export function ElementCard( props: React.PropsWithChildren< ContentKitClientElementProps & { icon: React.ReactNode | null; hint: React.ReactNode | null; buttons: React.ReactNode[]; } >, ) { const { element, children, icon, hint, buttons } = props; const clientContext = useContentKitClientContext(); return (
{ if (element.onPress) { clientContext.dispatchAction(element.onPress); } }} > {element.title ? (
{icon ?
{icon}
: null}
{element.title}
{hint ? (
{hint}
) : null}
{buttons && buttons.length > 0 ? (
{buttons}
) : null}
) : null} {children ?
{children}
: null}
); }