Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixes #1621
- Loading branch information
Showing
12 changed files
with
267 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/client/rsg-components/ComplexType/ComplexType.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import { render, fireEvent } from '@testing-library/react'; | ||
import ComplexType from './ComplexTypeRenderder'; | ||
|
||
function renderComponent(name = 'color', raw = 'red | blue') { | ||
return render(<ComplexType name={name} raw={raw} />); | ||
} | ||
|
||
describe('ComplexType', () => { | ||
test('should render name', () => { | ||
const { getByRole } = renderComponent(); | ||
expect(getByRole('button')).toHaveTextContent('color'); | ||
}); | ||
|
||
test('should render raw text in the tooltip', () => { | ||
const { container, getByRole } = renderComponent(); | ||
fireEvent.focus(getByRole('button')); | ||
expect(container.querySelector('[data-tippy-root]')).toHaveTextContent('red | blue'); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
src/client/rsg-components/ComplexType/ComplexTypeRenderder.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import Styled, { JssInjectedProps } from 'rsg-components/Styled'; | ||
import { MdInfoOutline } from 'react-icons/md'; | ||
import Text from 'rsg-components/Text'; | ||
import Tooltip from 'rsg-components/Tooltip'; | ||
import * as Rsg from '../../../typings'; | ||
|
||
export const styles = ({ space }: Rsg.Theme) => ({ | ||
complexType: { | ||
alignItems: 'center', | ||
display: 'inline-flex', | ||
}, | ||
icon: { | ||
marginLeft: space[0], | ||
}, | ||
}); | ||
|
||
export interface ComplexTypeProps extends JssInjectedProps { | ||
name: string; | ||
raw: string; | ||
} | ||
|
||
function ComplexTypeRenderer({ classes, name, raw }: ComplexTypeProps) { | ||
return ( | ||
<Tooltip placement="right" content={raw}> | ||
<span className={classes.complexType}> | ||
<Text>{name}</Text> | ||
<MdInfoOutline className={classes.icon} /> | ||
</span> | ||
</Tooltip> | ||
); | ||
} | ||
|
||
export default Styled<ComplexTypeProps>(styles)(ComplexTypeRenderer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'rsg-components/ComplexType/ComplexTypeRenderder'; |
Oops, something went wrong.