Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Play-529] Typescript Conversion Stat Value #2294

Merged
merged 2 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* @flow */

import React from 'react'
import classnames from 'classnames'

Expand All @@ -10,18 +8,18 @@ type StatValueProps = {
className?: string,
id?: string,
unit?: string,
value: string | number
value: string | number,
}

const StatValue = (props: StatValueProps) => {
const StatValue = (props: StatValueProps): React.ReactElement => {
const {
className,
id,
unit,
value = 0,
} = props

const displayValue = function(value) {
const displayValue = function(value: string | number) {
if (value || value === 0) {
return (
<Title
Expand All @@ -33,7 +31,7 @@ const StatValue = (props: StatValueProps) => {
}
}

const displayUnit = function(unit) {
const displayUnit = function(unit: string) {
if (unit) {
return (
<Title
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import StatValue from '../_stat_value.jsx'
import StatValue from '../_stat_value'

const StatValueUnit = (props) => {
return (
Expand Down
27 changes: 27 additions & 0 deletions playbook/app/pb_kits/playbook/pb_stat_value/stat_value.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react'
import { render, screen } from '../utilities/test-utils'

import StatValue from './_stat_value'

test('it renders the component with the value', () => {
render(
<StatValue
value={1048}
/>
)

const kit = screen.getByText('1048')
expect(kit).toBeTruthy()
})

test('it renders the component with the unit', () => {
render(
<StatValue
unit="appt"
value="5,294"
/>
)

const kit = screen.getByText('appt')
expect(kit).toBeTruthy()
})