Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.4 KB
Raw Blame
'use client'

import type { VariantProps } from 'class-variance-authority'
import type * as React from 'react'
import { cva } from 'class-variance-authority'
import { cn } from '../cn'

const kbdVariants = cva(
  'pointer-events-none inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-sm px-px font-sans system-kbd capitalize not-italic select-none',
  {
    variants: {
      color: {
        gray: 'bg-components-kbd-bg-gray text-text-tertiary',
        white: 'bg-components-kbd-bg-white text-text-primary-on-surface',
      },
      disabled: {
        true: 'opacity-30',
        false: '',
      },
    },
    defaultVariants: {
      color: 'gray',
      disabled: false,
    },
  },
)

type KbdColor = NonNullable<VariantProps<typeof kbdVariants>['color']>

type KbdProps = Omit<React.ComponentProps<'kbd'>, 'color'> & VariantProps<typeof kbdVariants>

function Kbd({ className, color, disabled, ...props }: KbdProps) {
  return (
    <kbd
      data-disabled={disabled ? '' : undefined}
      className={cn(kbdVariants({ color, disabled, className }))}
      {...props}
    />
  )
}

type KbdGroupProps = React.ComponentProps<'span'>

function KbdGroup({ className, ...props }: KbdGroupProps) {
  return (
    <span
      className={cn('inline-flex shrink-0 items-center gap-0.5 align-middle', className)}
      {...props}
    />
  )
}

export { Kbd, KbdGroup }
export type { KbdColor, KbdGroupProps, KbdProps }