mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 17:47:16 +00:00
Convert Character component to Typescript
This commit is contained in:
parent
1ec6a886b8
commit
71b0ed79b1
3 changed files with 43 additions and 7 deletions
|
|
@ -1,13 +1,17 @@
|
|||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
export const characterClassName = char =>
|
||||
interface Props {
|
||||
children: string | number;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export const characterClassName = (char: string | number) =>
|
||||
`character-${char
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
.charCodeAt(0)}`;
|
||||
|
||||
const Character = ({ children: char, className, ...passThrough }) => (
|
||||
const Character = ({ children: char, className, ...passThrough }: Props) => (
|
||||
<span
|
||||
{...passThrough}
|
||||
className={`${className || ""} character ${characterClassName(char)}`}
|
||||
|
|
@ -16,8 +20,4 @@ const Character = ({ children: char, className, ...passThrough }) => (
|
|||
</span>
|
||||
);
|
||||
|
||||
Character.propTypes = {
|
||||
children: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
|
||||
};
|
||||
|
||||
export default Character;
|
||||
|
|
@ -58,6 +58,10 @@
|
|||
"@babel/preset-react": "^7.0.0",
|
||||
"@babel/preset-typescript": "^7.0.0",
|
||||
"@babel/runtime": "^7.0.0",
|
||||
"@types/classnames": "^2.2.6",
|
||||
"@types/invariant": "^2.2.29",
|
||||
"@types/react": "^16.4.14",
|
||||
"@types/react-redux": "^6.0.8",
|
||||
"babel-core": "7.0.0-bridge.0",
|
||||
"babel-eslint": "^9.0.0-beta.3",
|
||||
"babel-jest": "^23.4.2",
|
||||
|
|
|
|||
32
yarn.lock
32
yarn.lock
|
|
@ -721,10 +721,38 @@
|
|||
lodash "^4.17.10"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@types/classnames@^2.2.6":
|
||||
version "2.2.6"
|
||||
resolved "https://registry.yarnpkg.com/@types/classnames/-/classnames-2.2.6.tgz#dbe8a666156d556ed018e15a4c65f08937c3f628"
|
||||
|
||||
"@types/invariant@^2.2.29":
|
||||
version "2.2.29"
|
||||
resolved "https://registry.yarnpkg.com/@types/invariant/-/invariant-2.2.29.tgz#aa845204cd0a289f65d47e0de63a6a815e30cc66"
|
||||
|
||||
"@types/node@*":
|
||||
version "10.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.1.0.tgz#2783ee1b6c47cbd4044f4a233976c1ac5fa9e942"
|
||||
|
||||
"@types/prop-types@*":
|
||||
version "15.5.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.5.5.tgz#17038dd322c2325f5da650a94d5f9974943625e3"
|
||||
dependencies:
|
||||
"@types/react" "*"
|
||||
|
||||
"@types/react-redux@^6.0.8":
|
||||
version "6.0.8"
|
||||
resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-6.0.8.tgz#29c884174516f0cfab6638d2236fd7d53f45640e"
|
||||
dependencies:
|
||||
"@types/react" "*"
|
||||
redux "^4.0.0"
|
||||
|
||||
"@types/react@*", "@types/react@^16.4.14":
|
||||
version "16.4.14"
|
||||
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.4.14.tgz#47c604c8e46ed674bbdf4aabf82b34b9041c6a04"
|
||||
dependencies:
|
||||
"@types/prop-types" "*"
|
||||
csstype "^2.2.0"
|
||||
|
||||
abab@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e"
|
||||
|
|
@ -2318,6 +2346,10 @@ cssom@0.3.x, "cssom@>= 0.3.2 < 0.4.0":
|
|||
dependencies:
|
||||
cssom "0.3.x"
|
||||
|
||||
csstype@^2.2.0:
|
||||
version "2.5.6"
|
||||
resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.5.6.tgz#2ae1db2319642d8b80a668d2d025c6196071e788"
|
||||
|
||||
currently-unhandled@^0.4.1:
|
||||
version "0.4.1"
|
||||
resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue