-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEQ]-[P2PS]- nada/fix: console error, firefox testlink, ellipsis iss…
…ue, character count (#75) * fix: console error, firefox testlink, ellipsis issue, character count issue * fix: added blocked user count modal * fix: payment methods dropdown shadow, missing rating, ui scroll issues * fix: tab title fix * fix: reuse variable for text size * fix: add eslint ignore * fix: height for app * fix: remove px
- Loading branch information
1 parent
8412f82
commit 14e980f
Showing
27 changed files
with
270 additions
and
48 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
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
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,19 @@ | ||
.block-user-count { | ||
& .deriv-tooltip-container { | ||
display: flex; | ||
align-items: center; | ||
gap: 0.1rem; | ||
} | ||
&__tooltip { | ||
padding: 0.8rem; | ||
gap: 0; | ||
|
||
@include mobile { | ||
display: none; | ||
} | ||
} | ||
|
||
&__button { | ||
padding: 0; | ||
} | ||
} |
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,60 @@ | ||
import { TLocalize } from 'types'; | ||
import { useModalManager } from '@/hooks'; | ||
import { LabelPairedCircleUserSlashSmRegularIcon } from '@deriv/quill-icons'; | ||
import { useTranslations } from '@deriv-com/translations'; | ||
import { Button, Text, Tooltip, useDevice } from '@deriv-com/ui'; | ||
import { BlockUserCountModal } from '../Modals'; | ||
import './BlockUserCount.scss'; | ||
|
||
type TBlockUserCount = { | ||
count?: number; | ||
}; | ||
|
||
const getMessage = (localize: TLocalize, count = 0) => { | ||
switch (count) { | ||
case 0: | ||
return localize('Nobody has blocked you. Yay!'); | ||
case 1: | ||
return localize('{{count}} person has blocked you', { | ||
count, | ||
}); | ||
default: | ||
return localize('{{count}} people have blocked you', { | ||
count, | ||
}); | ||
} | ||
}; | ||
|
||
const BlockUserCount = ({ count }: TBlockUserCount) => { | ||
const { localize } = useTranslations(); | ||
const { hideModal, isModalOpenFor, showModal } = useModalManager(); | ||
const { isMobile } = useDevice(); | ||
return ( | ||
<div className='block-user-count'> | ||
<Tooltip | ||
className='block-user-count__tooltip' | ||
message={<Text size='xs'>{getMessage(localize, count)}</Text>} | ||
> | ||
<Button | ||
className='block-user-count__button' | ||
color='white' | ||
data-testid='dt_block_user_count_button' | ||
onClick={() => { | ||
isMobile ? showModal('BlockUserCountModal') : undefined; | ||
}} | ||
variant='outlined' | ||
> | ||
<LabelPairedCircleUserSlashSmRegularIcon /> | ||
</Button> | ||
<Text color='less-prominent' size='sm'> | ||
{count ?? 0} | ||
</Text> | ||
</Tooltip> | ||
{!!isModalOpenFor('BlockUserCountModal') && ( | ||
<BlockUserCountModal isModalOpen message={getMessage(localize, count)} onRequestClose={hideModal} /> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default BlockUserCount; |
50 changes: 50 additions & 0 deletions
50
src/components/AdvertiserName/__tests__/BlockUserCount.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,50 @@ | ||
import { useDevice } from '@deriv-com/ui'; | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import BlockUserCount from '../BlockUserCount'; | ||
|
||
const modalManager = { | ||
hideModal: jest.fn(), | ||
isModalOpenFor: jest.fn(), | ||
showModal: jest.fn(), | ||
}; | ||
modalManager.showModal.mockImplementation(() => { | ||
modalManager.isModalOpenFor.mockReturnValue(true); | ||
}); | ||
|
||
jest.mock('@/hooks', () => ({ | ||
...jest.requireActual('@/hooks'), | ||
useModalManager: jest.fn(() => modalManager), | ||
})); | ||
|
||
jest.mock('@deriv-com/ui', () => ({ | ||
...jest.requireActual('@deriv-com/ui'), | ||
useDevice: jest.fn(() => ({ isMobile: false })), | ||
})); | ||
|
||
describe('BlockUserCount', () => { | ||
it('should render the component as expected', () => { | ||
render(<BlockUserCount count={0} />); | ||
expect(screen.getByText('0')).toBeInTheDocument(); | ||
expect(screen.getByTestId('dt_block_user_count_button')).toBeInTheDocument(); | ||
}); | ||
it('should display the tooltip message on hovering', async () => { | ||
render(<BlockUserCount count={0} />); | ||
const button = screen.getByTestId('dt_block_user_count_button'); | ||
await userEvent.hover(button); | ||
expect(screen.getByText('Nobody has blocked you. Yay!')).toBeInTheDocument(); | ||
}); | ||
it('should display the count in the tooltip message', async () => { | ||
render(<BlockUserCount count={1} />); | ||
const button = screen.getByTestId('dt_block_user_count_button'); | ||
await userEvent.hover(button); | ||
expect(screen.getByText('1 person has blocked you')).toBeInTheDocument(); | ||
}); | ||
it('should open the modal on clicking the button in mobile view', async () => { | ||
(useDevice as jest.Mock).mockReturnValue({ isMobile: true }); | ||
render(<BlockUserCount count={0} />); | ||
await userEvent.click(screen.getByTestId('dt_block_user_count_button')); | ||
expect(modalManager.showModal).toHaveBeenCalledWith('BlockUserCountModal'); | ||
expect(modalManager.isModalOpenFor()).toBe(true); | ||
}); | ||
}); |
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
3 changes: 3 additions & 0 deletions
3
src/components/Modals/BlockUserCountModal/BlockUserCountModal.scss
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,3 @@ | ||
.block-user-count-modal { | ||
@include default-modal; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/components/Modals/BlockUserCountModal/BlockUserCountModal.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,32 @@ | ||
import { Localize } from '@deriv-com/translations'; | ||
import { Button, Modal, Text } from '@deriv-com/ui'; | ||
import './BlockUserCountModal.scss'; | ||
|
||
type TBlockUserCountModalProps = { | ||
isModalOpen: boolean; | ||
message: string; | ||
onRequestClose: () => void; | ||
}; | ||
|
||
const BlockUserCountModal = ({ isModalOpen, message, onRequestClose }: TBlockUserCountModalProps) => { | ||
return ( | ||
<Modal | ||
ariaHideApp={false} | ||
className='block-user-count-modal' | ||
isOpen={isModalOpen} | ||
onRequestClose={onRequestClose} | ||
shouldCloseOnOverlayClick={false} | ||
> | ||
<Modal.Body className='p-[2.4rem] pb-[0.8rem]'> | ||
<Text>{message}</Text> | ||
</Modal.Body> | ||
<Modal.Footer className='p-[1.6rem]' hideBorder> | ||
<Button onClick={onRequestClose} size='lg' textSize='md'> | ||
<Localize i18n_default_text='Ok' /> | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default BlockUserCountModal; |
21 changes: 21 additions & 0 deletions
21
src/components/Modals/BlockUserCountModal/__tests__/BlockUserCountModal.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,21 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import BlockUserCountModal from '../BlockUserCountModal'; | ||
|
||
const mockProps = { | ||
isModalOpen: true, | ||
message: 'test', | ||
onRequestClose: jest.fn(), | ||
}; | ||
|
||
describe('BlockUserCountModal', () => { | ||
it('should render the modal component as expected', () => { | ||
render(<BlockUserCountModal {...mockProps} />); | ||
expect(screen.getByText('test')).toBeInTheDocument(); | ||
}); | ||
it('should handle the onclick event for the ok button', async () => { | ||
render(<BlockUserCountModal {...mockProps} />); | ||
await userEvent.click(screen.getByText('Ok')); | ||
expect(mockProps.onRequestClose).toHaveBeenCalled(); | ||
}); | ||
}); |
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 as BlockUserCountModal } from './BlockUserCountModal'; |
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
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.