Skip to content

Commit 2a4be70

Browse files
committed
Add nonhover state headers
1 parent 4b75e17 commit 2a4be70

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/keyboard/Key.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ interface KeyProps {
99
onClick?: () => void;
1010
}
1111

12+
const shortenHeader = (header: string) => {
13+
if(header.length > 9){
14+
return header?.split(/[\s,-]+/).map((word) => (word.substring(0,3))).join("");
15+
}else {
16+
return header;
17+
}
18+
}
19+
1220
export const Key = ({
1321
selected = false,
1422
width,
@@ -31,6 +39,7 @@ export const Key = ({
3139
}}
3240
onClick={onClick}
3341
>
42+
<div className={`absolute text-xs ${selected ? "text-primary-content" : "z1text-base-content"} opacity-80 group-hover:opacity-0 top-1 text-nowrap left-1/2 font-light -translate-x-1/2 text-center transition-opacity`}>{header ? shortenHeader(header) : ""}</div>
3443
<div className={`absolute text-xs ${selected ? "text-primary-content" : "z1text-base-content"} opacity-0 group-hover:opacity-80 top-1 text-nowrap left-1/2 font-light -translate-x-1/2 text-center transition-opacity`}>{header}</div>
3544
{children}
3645
</button>

0 commit comments

Comments
 (0)