mirror of
https://github.com/captbaritone/webamp.git
synced 2026-01-24 02:36:00 +00:00
* Upgrade React type hooks * Fix type for passthrough props * Fix some react typings * Fix type error with MouseEvent
23 lines
561 B
TypeScript
23 lines
561 B
TypeScript
import React from "react";
|
|
import deburr from "lodash/deburr";
|
|
|
|
interface Props extends React.HTMLAttributes<HTMLSpanElement> {
|
|
children: string | number;
|
|
className?: string;
|
|
}
|
|
|
|
export const characterClassName = (char: string | number) =>
|
|
`character-${deburr(char.toString())
|
|
.toLowerCase()
|
|
.charCodeAt(0)}`;
|
|
|
|
const Character = ({ children: char, className, ...passThrough }: Props) => (
|
|
<span
|
|
{...passThrough}
|
|
className={`${className || ""} character ${characterClassName(char)}`}
|
|
>
|
|
{char}
|
|
</span>
|
|
);
|
|
|
|
export default Character;
|