webamp/js/components/Character.tsx
Jordan Eldredge 2df185b1a3
Upgrade React (#727)
* Upgrade React

type hooks

* Fix type for passthrough props

* Fix some react typings

* Fix type error with MouseEvent
2019-02-17 14:42:35 -08:00

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;