Skip to content

Commit

Permalink
use clsx instead of classnames for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
sqs committed Dec 29, 2023
1 parent 2f95772 commit fb4119f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/ui-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@opencodegraph/schema": "workspace:*",
"@opencodegraph/ui-standalone": "workspace:*",
"classnames": "^2.3.2"
"clsx": "^2.0.0"
},
"devDependencies": {
"@types/react": "18.2.37",
Expand Down
8 changes: 4 additions & 4 deletions lib/ui-react/src/chip/Chip.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Annotation } from '@opencodegraph/schema'
import classNames from 'classnames'
import clsx from 'clsx'
import { useCallback, useRef, useState, type FunctionComponent } from 'react'
import styles from './Chip.module.css'
import { Popover } from './Popover'
Expand All @@ -19,14 +19,14 @@ export const Chip: FunctionComponent<{
const anchorRef = useRef<HTMLElement>(null)

return (
<aside className={classNames(styles.chip, className)} ref={anchorRef}>
<aside className={clsx(styles.chip, className)} ref={anchorRef}>
<header onMouseEnter={showPopover} onMouseLeave={hidePopover} onFocus={showPopover} onBlur={hidePopover}>
<h4 className={styles.title}>{annotation.title}</h4>
{annotation.url && <a className={styles.stretchedLink} aria-hidden={true} href={annotation.url} />}
</header>
{annotation.ui?.detail && anchorRef.current && (
<Popover anchor={anchorRef.current} visible={popoverVisible}>
<aside className={classNames(styles.popoverContent, popoverClassName)}>
<aside className={clsx(styles.popoverContent, popoverClassName)}>
{/* TODO(sqs): support markdown */}
<p className={styles.detail}>{annotation.ui?.detail}</p>
</aside>
Expand All @@ -45,7 +45,7 @@ export const ChipList: FunctionComponent<{
chipClassName?: string
popoverClassName?: string
}> = ({ annotations, className, chipClassName, popoverClassName }) => (
<div className={classNames(styles.list, className)}>
<div className={clsx(styles.list, className)}>
{annotations.map((annotation, i) => (
<Chip
key={annotation.url ?? i}
Expand Down
22 changes: 9 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fb4119f

Please sign in to comment.