Skip to content

Commit

Permalink
fix(react): file tree's files to indicate selected state (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio authored Aug 20, 2024
1 parent bcbffe6 commit bd8a3be
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/components/react/src/core/FileTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ function File({ file: { depth, name }, onClick, selected }: FileProps) {
'text-tk-elements-fileTree-file-iconColorSelected': selected,
})}
onClick={onClick}
aria-pressed={selected}
>
{name}
</NodeButton>
Expand All @@ -162,14 +163,16 @@ interface ButtonProps {
children: ReactNode;
className?: string;
onClick?: () => void;
'aria-pressed'?: boolean;
}

function NodeButton({ depth, iconClasses, onClick, className, children }: ButtonProps) {
function NodeButton({ depth, iconClasses, onClick, className, 'aria-pressed': ariaPressed, children }: ButtonProps) {
return (
<button
className={`flex items-center gap-2 w-full pr-2 border-2 border-transparent text-faded ${className ?? ''}`}
style={{ paddingLeft: `${12 + depth * NODE_PADDING_LEFT}px` }}
onClick={() => onClick?.()}
aria-pressed={ariaPressed === true ? 'true' : undefined}
>
<div className={classNames('scale-120 shrink-0', iconClasses)}></div>
<span>{children}</span>
Expand Down

0 comments on commit bd8a3be

Please sign in to comment.