Extract capitalize method
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { Flex, Text } from '@theme-ui/components'
|
import { Flex, Text } from '@theme-ui/components'
|
||||||
|
import { capitalize } from '../../lib/string'
|
||||||
import SquareImageBox from './SquareImageBox'
|
import SquareImageBox from './SquareImageBox'
|
||||||
|
|
||||||
interface TypeLabelProps {
|
interface TypeLabelProps {
|
||||||
@@ -6,7 +7,8 @@ interface TypeLabelProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const TypeLabel = ({ type }: TypeLabelProps) => {
|
const TypeLabel = ({ type }: TypeLabelProps) => {
|
||||||
const label = type.replace(/^\w/, (c) => c.toUpperCase())
|
const label = capitalize(type)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex sx={{ alignItems: 'center' }}>
|
<Flex sx={{ alignItems: 'center' }}>
|
||||||
{isValidType(type) && (
|
{isValidType(type) && (
|
||||||
|
|||||||
@@ -34,3 +34,7 @@ export function addDateToDateString(dateString: string, duration: Duration) {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function capitalize(value: string) {
|
||||||
|
return value.replace(/^\w/, (c) => c.toUpperCase())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user