Extract capitalize method

This commit is contained in:
Sakura Knoll
2022-01-02 14:49:23 +09:00 Unverified
parent dc24bd9617
commit 315f52ce3a
2 changed files with 7 additions and 1 deletions
+3 -1
View File
@@ -1,4 +1,5 @@
import { Flex, Text } from '@theme-ui/components'
import { capitalize } from '../../lib/string'
import SquareImageBox from './SquareImageBox'
interface TypeLabelProps {
@@ -6,7 +7,8 @@ interface TypeLabelProps {
}
const TypeLabel = ({ type }: TypeLabelProps) => {
const label = type.replace(/^\w/, (c) => c.toUpperCase())
const label = capitalize(type)
return (
<Flex sx={{ alignItems: 'center' }}>
{isValidType(type) && (
+4
View File
@@ -34,3 +34,7 @@ export function addDateToDateString(dateString: string, duration: Duration) {
})
)
}
export function capitalize(value: string) {
return value.replace(/^\w/, (c) => c.toUpperCase())
}