-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ModalPage, ModalCard): add outside buttons support (#8214)
- Loading branch information
1 parent
8df2db2
commit 6e09949
Showing
33 changed files
with
376 additions
and
104 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
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
3 changes: 3 additions & 0 deletions
3
...d/__image_snapshots__/modalcard-outsidebutton-android-chromium-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...dalCard/__image_snapshots__/modalcard-outsidebutton-ios-webkit-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
51 changes: 0 additions & 51 deletions
51
packages/vkui/src/components/ModalCardBase/ModalCardBaseCloseButton.tsx
This file was deleted.
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: 11 additions & 9 deletions
20
packages/vkui/src/components/ModalDismissButton/ModalDismissButton.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 |
---|---|---|
@@ -1,27 +1,29 @@ | ||
import * as React from 'react'; | ||
import { Icon20Cancel } from '@vkontakte/icons'; | ||
import { Tappable, type TappableProps } from '../Tappable/Tappable'; | ||
import { classNames } from '@vkontakte/vkjs'; | ||
import { | ||
ModalOutsideButton, | ||
type ModalOutsideButtonProps, | ||
} from '../ModalOutsideButton/ModalOutsideButton'; | ||
import { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden'; | ||
import styles from './ModalDismissButton.module.css'; | ||
|
||
export type ModalDismissButtonProps = Omit<TappableProps, 'mode' | 'onClose'>; | ||
export interface ModalDismissButtonProps extends Omit<ModalOutsideButtonProps, 'children'> { | ||
children?: React.ReactNode; | ||
} | ||
|
||
/** | ||
* @see https://vkcom.github.io/VKUI/#/ModalDismissButton | ||
*/ | ||
export const ModalDismissButton = ({ | ||
children = 'Закрыть', | ||
className, | ||
...restProps | ||
}: ModalDismissButtonProps): React.ReactNode => { | ||
return ( | ||
<Tappable | ||
baseClassName={styles.host} | ||
{...restProps} | ||
activeMode={styles.active} | ||
hoverMode={styles.hover} | ||
> | ||
<ModalOutsideButton className={classNames(styles.host, className)} {...restProps}> | ||
{children && <VisuallyHidden>{children}</VisuallyHidden>} | ||
<Icon20Cancel /> | ||
</Tappable> | ||
</ModalOutsideButton> | ||
); | ||
}; |
22 changes: 22 additions & 0 deletions
22
packages/vkui/src/components/ModalOutsideButton/ModalOutsideButton.e2e-playground.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,22 @@ | ||
import { Icon20More } from '@vkontakte/icons'; | ||
import { noop } from '@vkontakte/vkjs'; | ||
import { ComponentPlayground, type ComponentPlaygroundProps } from '@vkui-e2e/playground-helpers'; | ||
import { ModalOutsideButton, type ModalOutsideButtonProps } from './ModalOutsideButton'; | ||
|
||
export const ModalOutsideButtonPlayground = (props: ComponentPlaygroundProps) => ( | ||
<ComponentPlayground {...props}> | ||
{(props: ModalOutsideButtonProps) => ( | ||
<div style={{ width: 60, display: 'flex', flexDirection: 'column' }}> | ||
<ModalOutsideButton aria-label="Больше" {...props}> | ||
<Icon20More /> | ||
</ModalOutsideButton> | ||
<ModalOutsideButton aria-label="Больше" {...props} onClick={noop} hovered> | ||
<Icon20More /> | ||
</ModalOutsideButton> | ||
<ModalOutsideButton aria-label="Больше" {...props} onClick={noop} activated> | ||
<Icon20More /> | ||
</ModalOutsideButton> | ||
</div> | ||
)} | ||
</ComponentPlayground> | ||
); |
11 changes: 11 additions & 0 deletions
11
packages/vkui/src/components/ModalOutsideButton/ModalOutsideButton.e2e.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,11 @@ | ||
import { test } from '@vkui-e2e/test'; | ||
import { ModalOutsideButtonPlayground } from './ModalOutsideButton.e2e-playground'; | ||
|
||
test('ModalOutsideButton', async ({ | ||
mount, | ||
expectScreenshotClippedToContent, | ||
componentPlaygroundProps, | ||
}) => { | ||
await mount(<ModalOutsideButtonPlayground {...componentPlaygroundProps} />); | ||
await expectScreenshotClippedToContent(); | ||
}); |
Oops, something went wrong.