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-610] Converting Loading Inline kit to Typescrit #2328

Merged
merged 3 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* @flow */

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

import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
import { globalProps } from '../utilities/globalProps'

import Body from '../pb_body/_body'
import Icon from '../pb_icon/_icon'

type LoadingInlineProps = {
align?: "left" | "center" | "right",
aria?: { [key: string]: string },
className?: string,
data?: { [key: string]: string },
id?: string,
}

const LoadingInline = (props: LoadingInlineProps) => {
const {
align = 'left',
aria = {},
className,
data = {},
id,
} = props

const ariaProps = buildAriaProps(aria)
const dataProps = buildDataProps(data)
const classes = classnames(
buildCss(`pb_loading_inline_kit_${align}`),
globalProps(props),
className
)

return (
<div
{...ariaProps}
{...dataProps}
className={classes}
id={id}
>
<Body color="light">
<Icon
aria={{ label: 'loading icon' }}
fixedWidth
icon="spinner"
pulse
/>
{' Loading'}
</Body>
</div>
)
}

export default LoadingInline
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react'
import { render, screen } from '../utilities/test-utils'
import LoadingInline from './_loading_inline'

const testId = "loadingInline"

test('should render custom class and data', () => {
render(
<LoadingInline
className='custom-class'
data={{ testid: testId }}
/>
)

const kit = screen.getByTestId(testId)
expect(kit).toHaveClass('custom-class')
})

test('should render id', () => {
render(
<LoadingInline
data={{ testid: testId }}
id={testId}
/>
)

const kit = screen.getByTestId(testId)
expect(kit).toHaveProperty('id', testId)
})

test('should render aria-label', () => {
render(
<LoadingInline
aria={{ label: testId }}
data={{ testid: testId }}
/>
)

const kit = screen.getByTestId(testId)
expect(kit).toHaveAttribute('aria-label', testId)
})