@hanzo/ui

Glimpse

import { Glimpse, GlimpseContent, GlimpseDescription, GlimpseImage, GlimpseTitle, GlimpseTrigger } from '@hanzo/ui'

Default

Rest a pointer on the link to see the page it points to before you follow it.

export function Default() {
  return (
    <Glimpse>
      <GlimpseTrigger asChild>
        <Anchor href="https://www.hanzo.ai" target="_blank" rel="noopener noreferrer">
          hanzo.ai
        </Anchor>
      </GlimpseTrigger>
      <GlimpseContent>
        <GlimpseImage
          src="https://images.unsplash.com/photo-1451187580459-43490279c0fa?w=640&h=360&fit=crop"
          alt="Hanzo AI"
        />
        <GlimpseTitle>Hanzo AI</GlimpseTitle>
        <GlimpseDescription>
          Frontier AI models, agent infrastructure, and the compute to run them.
        </GlimpseDescription>
      </GlimpseContent>
    </Glimpse>
  )
}

No image

A preview with only a title and description still lays out edge to edge.

export function TextOnly() {
  return (
    <Glimpse>
      <GlimpseTrigger asChild>
        <Anchor href="https://lux.network" target="_blank" rel="noopener noreferrer">
          lux.network
        </Anchor>
      </GlimpseTrigger>
      <GlimpseContent>
        <GlimpseTitle>Lux Network</GlimpseTitle>
        <GlimpseDescription>
          A post-quantum, multi-consensus blockchain built for cross-chain interoperability.
        </GlimpseDescription>
      </GlimpseContent>
    </Glimpse>
  )
}

Broken image

A `src` that fails to load falls back to a glyph instead of the browser's own icon.

export function BrokenImage() {
  return (
    <Glimpse>
      <GlimpseTrigger asChild>
        <Anchor href="https://example.com" target="_blank" rel="noopener noreferrer">
          example.com
        </Anchor>
      </GlimpseTrigger>
      <GlimpseContent>
        <GlimpseImage src="https://example.com/does-not-exist.png" alt="" />
        <GlimpseTitle>Example Domain</GlimpseTitle>
        <GlimpseDescription>Reserved for use in illustrative examples.</GlimpseDescription>
      </GlimpseContent>
    </Glimpse>
  )
}

Placement

The panel can open on any side of the trigger, with a shorter open delay.

export function Placement() {
  return (
    <XStack gap="$6">
      <Glimpse openDelay={0}>
        <GlimpseTrigger asChild>
          <Anchor href="https://zoo.ngo" target="_blank" rel="noopener noreferrer">
            zoo.ngo
          </Anchor>
        </GlimpseTrigger>
        <GlimpseContent side="top">
          <GlimpseTitle>Zoo Labs Foundation</GlimpseTitle>
          <GlimpseDescription>
            Open, community-governed AI and science research.
          </GlimpseDescription>
        </GlimpseContent>
      </Glimpse>
    </XStack>
  )
}

Types

export type GlimpseProps = Omit<
  ComponentProps<typeof GuiPopover>,
  'hoverable' | 'placement' | 'offset'
> & {
  openDelay?: number
  closeDelay?: number
}
export type GlimpseTriggerProps = ComponentProps<typeof GuiPopover.Trigger>
export type GlimpseContentProps = ComponentProps<typeof GuiPopover.Content> & {
  side?: Side
  align?: Align
  sideOffset?: number
}
export type GlimpseImageProps = Omit<ImageProps, 'width' | 'height' | 'onError'> & {
  /** Width divided by height of the preview frame. 16:9 by default. */
  ratio?: number
  /**
   * The `src` failed to load and the frame now shows the fallback glyph. The
   * platform event is not passed on: gui's `Image` types `onError` as the
   * intersection of React Native's and the web's handler, and a value drawn
   * from one of two incompatible signatures cannot be handed back to the other.
   */
  onError?: () => void
}
export type GlimpseTitleProps = ComponentProps<typeof SizableText>
export type GlimpseDescriptionProps = ComponentProps<typeof SizableText>

Exports

GlimpseGlimpseContentGlimpseDescriptionGlimpseImageGlimpseTitleGlimpseTriggertype GlimpseContentPropstype GlimpseDescriptionPropstype GlimpseImagePropstype GlimpsePropstype GlimpseTitlePropstype GlimpseTriggerProps