Skip to content

Commit

Permalink
feat: add inner ring toggle prop to kbd component
Browse files Browse the repository at this point in the history
  • Loading branch information
lovrozagar committed Oct 14, 2024
1 parent 6033d9f commit 3cd0963
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/components/kbd/components/kbd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

import { cn, polymorphic } from '@renderui/utils'

import { DEFAULT_KBD_CLASSNAME } from '@/components/kbd/constants/constants'
import { DEFAULT_KBD_CLASSNAME, KBD_INNER_RING_CLASSNAME } from '@/components/kbd/constants/constants'
import type { KbdProps } from '@/components/kbd/types/kbd'
import type { CSSProperties } from 'react'

const Kbd = (props: KbdProps) => {
const { asChild, children, className, style, color = 'mode-accent', ...restProps } = props
const { asChild, children, className, style, hasInnerRing = true, color = 'mode-accent', ...restProps } = props

const Component = polymorphic(asChild, 'kbd')

return (
<Component
className={cn(DEFAULT_KBD_CLASSNAME, className)}
className={cn(DEFAULT_KBD_CLASSNAME, hasInnerRing ? KBD_INNER_RING_CLASSNAME : undefined, className)}
style={
{
...style,
Expand Down
6 changes: 3 additions & 3 deletions src/components/kbd/constants/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const DEFAULT_KBD_CLASSNAME =
'_kbd flex justify-center items-center gap-1 text-xs text-[rgba(var(--kbd-color))] bg-[rgba(var(--kbd-bg))] font-[unset] font-medium rounded-md px-2 py-1.5 duration-fast transition-[background-color,box-shadow] shadow-[inset_0_-0.05em_0.5em_#00005506,inset_0_0.05em_hsla(0,0%,100%,0.95),inset_0_0.25em_0.5em_#00005506,inset_0_-0.05em_#00002f26,0_0_0_0.05em_#0009321f,0_0.08em_0.17em_#00062e32] dark:shadow-[inset_0_-0.05em_0.5em_#ddeaf814,inset_0_0.05em_#f1f7feb5,inset_0_0.25em_0.5em_#d8f4f609,inset_0_-0.1em_rgba(0,0,0,0.9),0_0_0_0.075em_#d9edff40,0_0.08em_0.17em_rgba(0,0,0,0.95)]'
'_kbd flex justify-center items-center gap-1 text-xs text-[rgba(var(--kbd-color))] bg-[rgba(var(--kbd-bg))] font-[unset] font-medium rounded-md px-2 py-1.5 duration-fast transition-[background-color,box-shadow]'

const DEFAULT_KBD_ICON_CLASSNAME = 'block h-4 w-4 fill-none stroke-current stroke-[1px]'
const KBD_INNER_RING_CLASSNAME = 'shadow-[inset_0_-0.05em_0.5em_#00005506,inset_0_0.05em_hsla(0,0%,100%,0.95),inset_0_0.25em_0.5em_#00005506,inset_0_-0.05em_#00002f26,0_0_0_0.05em_#0009321f,0_0.08em_0.17em_#00062e32] dark:shadow-[inset_0_-0.05em_0.5em_#ddeaf814,inset_0_0.05em_#f1f7feb5,inset_0_0.25em_0.5em_#d8f4f609,inset_0_-0.1em_rgba(0,0,0,0.9),0_0_0_0.075em_#d9edff40,0_0.08em_0.17em_rgba(0,0,0,0.95)]'

export { DEFAULT_KBD_CLASSNAME, DEFAULT_KBD_ICON_CLASSNAME }
export { DEFAULT_KBD_CLASSNAME, KBD_INNER_RING_CLASSNAME }
1 change: 1 addition & 0 deletions src/components/kbd/types/kbd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type KbdCustomProps = {
asChild?: boolean
color?: Color
hasIcon?: boolean
hasInnerRing?: boolean
iconPosition?: 'start' | 'end'
}

Expand Down

0 comments on commit 3cd0963

Please sign in to comment.