-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add tooltip which display when user hover in tag (#879)
* chore: Add tooltip which display when user hover in tag
- Loading branch information
1 parent
bdf01a1
commit 4a1bfea
Showing
14 changed files
with
547 additions
and
273 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
25 changes: 25 additions & 0 deletions
25
packages/elements/src/components/DropdownSelect/__stubs__/options.ts
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,25 @@ | ||
import { SelectOption } from '../' | ||
|
||
export const options: SelectOption[] = [ | ||
{ | ||
value: 'Property', | ||
label: 'Property', | ||
description: `The type of Property will be given to an application that can be launched for a | ||
specific property from Agency Cloud. `, | ||
link: 'https://foundations-documentation.reapit.cloud/api/desktop-api#property-1', | ||
}, | ||
{ | ||
value: 'Applicant', | ||
label: 'Applicant', | ||
description: `The type of Applicant will be given to an application that can be launched for a | ||
specific applicant from Agency Cloud.`, | ||
link: 'https://foundations-documentation.reapit.cloud/api/desktop-api#applicant', | ||
}, | ||
{ | ||
value: 'idCheck', | ||
label: 'Id Check', | ||
description: `The type of ID Check will be given to an application that can be used to replace | ||
the ID Check screen in Agency Cloud.`, | ||
link: 'https://foundations-documentation.reapit.cloud/api/desktop-api#id-check', | ||
}, | ||
] |
105 changes: 0 additions & 105 deletions
105
packages/elements/src/components/DropdownSelect/__test__/index.tsx
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
packages/elements/src/components/DropdownSelect/__tests__/__snapshots__/custom-tag.tsx.snap
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,36 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`CustomTag should match a snapshot 1`] = ` | ||
<ForwardRef(Tooltip) | ||
overlay={ | ||
<span | ||
className="reapit-tooltip-content" | ||
> | ||
The type of Property will be given to an application that can be launched for a | ||
specific property from Agency Cloud. | ||
<a | ||
href="https://foundations-documentation.reapit.cloud/api/desktop-api#property-1" | ||
> | ||
More Info | ||
</a> | ||
</span> | ||
} | ||
placement="bottomLeft" | ||
prefixCls="reapit-tooltip" | ||
> | ||
<div | ||
className="custom-tag tags has-addons" | ||
> | ||
<span | ||
className="tag is-light" | ||
> | ||
Property | ||
</span> | ||
<a | ||
className="tag is-light is-delete" | ||
href="" | ||
onClick={[Function]} | ||
/> | ||
</div> | ||
</ForwardRef(Tooltip)> | ||
`; |
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
24 changes: 24 additions & 0 deletions
24
packages/elements/src/components/DropdownSelect/__tests__/custom-tag.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,24 @@ | ||
import * as React from 'react' | ||
import { shallow } from 'enzyme' | ||
import { CustomTag, CustomTagProps } from '../custom-tag' | ||
|
||
const props: CustomTagProps = { | ||
label: 'Property', | ||
description: `The type of Property will be given to an application that can be launched for a | ||
specific property from Agency Cloud.`, | ||
link: 'https://foundations-documentation.reapit.cloud/api/desktop-api#property-1', | ||
onClose: jest.fn(), | ||
} | ||
|
||
describe('CustomTag', () => { | ||
it('should match a snapshot', () => { | ||
expect(shallow(<CustomTag {...props} />)).toMatchSnapshot() | ||
}) | ||
|
||
it('should call onClose when click remove', () => { | ||
const wrapper = shallow(<CustomTag {...props} />) | ||
const element = wrapper.find('a') | ||
element.simulate('click') | ||
expect(props.onClose).toHaveBeenCalled() | ||
}) | ||
}) |
44 changes: 44 additions & 0 deletions
44
packages/elements/src/components/DropdownSelect/__tests__/index.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,44 @@ | ||
import * as React from 'react' | ||
import { shallow, mount } from 'enzyme' | ||
import { DropdownSelect, DropdownSelectProps } from '../index' | ||
import { Formik, Form } from 'formik' | ||
import toJson from 'enzyme-to-json' | ||
import { options as mockOptions } from '../__stubs__/options' | ||
|
||
const dropdownSelectProps: DropdownSelectProps = { | ||
name: 'demo', | ||
labelText: 'demo', | ||
options: mockOptions, | ||
} | ||
|
||
const createFormikWrapper = () => { | ||
const wrapper = mount( | ||
<Formik onSubmit={jest.fn()} initialValues={{ demo: 'b' }}> | ||
{() => ( | ||
<Form> | ||
<div className="column is-half-desktop"> | ||
<DropdownSelect name="demo" mode="tags" labelText="Demo" options={mockOptions} /> | ||
</div> | ||
</Form> | ||
)} | ||
</Formik>, | ||
) | ||
|
||
return wrapper | ||
} | ||
|
||
describe('Dropdown-select', () => { | ||
it('should match a snapshot', () => { | ||
expect(toJson(shallow(<DropdownSelect {...dropdownSelectProps} />))).toMatchSnapshot() | ||
}) | ||
|
||
it('Render label correctly', () => { | ||
const wrapper = createFormikWrapper() | ||
const label = wrapper.find('label').first() | ||
expect(label.text()).toBe('Demo') | ||
}) | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks() | ||
}) | ||
}) |
36 changes: 36 additions & 0 deletions
36
packages/elements/src/components/DropdownSelect/custom-tag.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,36 @@ | ||
import * as React from 'react' | ||
import Tooltip from 'rc-tooltip' | ||
|
||
export interface CustomTagProps { | ||
label: string | ||
description: string | ||
link: string | ||
onClose: (event?: React.MouseEvent<HTMLElement, MouseEvent>) => void | ||
} | ||
|
||
export const CustomTag: React.FC<CustomTagProps> = ({ label, description, link, onClose }) => { | ||
const handleRemoveTag = (event: React.SyntheticEvent) => { | ||
event?.preventDefault() | ||
onClose() | ||
} | ||
|
||
return ( | ||
<Tooltip | ||
prefixCls="reapit-tooltip" | ||
placement="bottomLeft" | ||
overlay={ | ||
<span className="reapit-tooltip-content"> | ||
{description} | ||
{link && <a href={link}>More Info</a>} | ||
</span> | ||
} | ||
> | ||
<div className="custom-tag tags has-addons"> | ||
<span className="tag is-light">{label}</span> | ||
<a href="" onClick={handleRemoveTag} className="tag is-light is-delete"></a> | ||
</div> | ||
</Tooltip> | ||
) | ||
} | ||
|
||
export default CustomTag |
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
45 changes: 34 additions & 11 deletions
45
packages/elements/src/components/DropdownSelect/index.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
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
Oops, something went wrong.