From e8ebb871898c7845fc2eb6bb86bfe53dc76377ea Mon Sep 17 00:00:00 2001 From: Treycos <19551067+Treycos@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:54:30 +0200 Subject: [PATCH] Convert Label to TypeScript (cherry picked from commit 3eca63a67c898256b711d37607f07cbabb9ed323) --- frontend/src/Components/Label.js | 48 ------------------------------- frontend/src/Components/Label.tsx | 33 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 48 deletions(-) delete mode 100644 frontend/src/Components/Label.js create mode 100644 frontend/src/Components/Label.tsx diff --git a/frontend/src/Components/Label.js b/frontend/src/Components/Label.js deleted file mode 100644 index 844da8165..000000000 --- a/frontend/src/Components/Label.js +++ /dev/null @@ -1,48 +0,0 @@ -import classNames from 'classnames'; -import PropTypes from 'prop-types'; -import React from 'react'; -import { kinds, sizes } from 'Helpers/Props'; -import styles from './Label.css'; - -function Label(props) { - const { - className, - kind, - size, - outline, - children, - ...otherProps - } = props; - - return ( - - {children} - - ); -} - -Label.propTypes = { - className: PropTypes.string.isRequired, - title: PropTypes.string, - kind: PropTypes.oneOf(kinds.all).isRequired, - size: PropTypes.oneOf(sizes.all).isRequired, - outline: PropTypes.bool.isRequired, - children: PropTypes.node.isRequired -}; - -Label.defaultProps = { - className: styles.label, - kind: kinds.DEFAULT, - size: sizes.SMALL, - outline: false -}; - -export default Label; diff --git a/frontend/src/Components/Label.tsx b/frontend/src/Components/Label.tsx new file mode 100644 index 000000000..9ab360f42 --- /dev/null +++ b/frontend/src/Components/Label.tsx @@ -0,0 +1,33 @@ +import classNames from 'classnames'; +import React, { ComponentProps, ReactNode } from 'react'; +import { kinds, sizes } from 'Helpers/Props'; +import { Kind } from 'Helpers/Props/kinds'; +import { Size } from 'Helpers/Props/sizes'; +import styles from './Label.css'; + +export interface LabelProps extends ComponentProps<'span'> { + kind?: Extract; + size?: Extract; + outline?: boolean; + children: ReactNode; +} + +export default function Label({ + className = styles.label, + kind = kinds.DEFAULT, + size = sizes.SMALL, + outline = false, + ...otherProps +}: LabelProps) { + return ( + + ); +}