From 3081d6cac837e80a70f8ab1b28f51a6264e827cc Mon Sep 17 00:00:00 2001 From: Daniil Suvorov Date: Mon, 6 Jul 2026 16:35:29 +0300 Subject: [PATCH] feat(Alert): sync vkcom and android platforms --- .../src/components/Alert/Alert.module.css | 28 ------------- .../vkui/src/components/Alert/Alert.test.tsx | 39 ------------------- .../vkui/src/components/Alert/AlertAction.tsx | 19 +-------- .../src/components/Alert/AlertActions.tsx | 10 +---- .../vkui/src/components/Alert/AlertBase.tsx | 1 - .../src/components/Alert/AlertTypography.tsx | 21 ++++------ ...ert-desktop-vkcom-chromium-dark-1-snap.png | 4 +- ...rt-desktop-vkcom-chromium-light-1-snap.png | 4 +- ...lert-desktop-vkcom-firefox-dark-1-snap.png | 4 +- ...ert-desktop-vkcom-firefox-light-1-snap.png | 4 +- ...alert-desktop-vkcom-webkit-dark-1-snap.png | 4 +- ...lert-desktop-vkcom-webkit-light-1-snap.png | 4 +- ...ong-word-android-chromium-light-1-snap.png | 4 +- ...-long-word-vkcom-chromium-light-1-snap.png | 4 +- ...t-long-word-vkcom-firefox-light-1-snap.png | 4 +- ...rt-long-word-vkcom-webkit-light-1-snap.png | 4 +- ...rt-mobile-android-chromium-dark-1-snap.png | 4 +- ...t-mobile-android-chromium-light-1-snap.png | 4 +- 18 files changed, 35 insertions(+), 131 deletions(-) diff --git a/packages/vkui/src/components/Alert/Alert.module.css b/packages/vkui/src/components/Alert/Alert.module.css index 56c5eb86b5f..3d586a768f7 100644 --- a/packages/vkui/src/components/Alert/Alert.module.css +++ b/packages/vkui/src/components/Alert/Alert.module.css @@ -251,34 +251,6 @@ color: var(--vkui--color_text_negative); } -/** - * VKCOM - */ - -.vkcom { - inline-size: 400px; - box-shadow: - 0 0 2px rgb(0, 0, 0, 0.12), - 0 0 96px rgb(0, 0, 0, 0.16); -} - -.vkcom .content { - padding-block-end: 20px; -} - -.vkcom .actions { - padding-block: 0 12px; - padding-inline: 20px; -} - -.vkcom .button { - order: 2; -} - -.vkcom .buttonModeCancel { - order: 1; -} - .dismiss { position: absolute; inset-block-start: 8px; diff --git a/packages/vkui/src/components/Alert/Alert.test.tsx b/packages/vkui/src/components/Alert/Alert.test.tsx index 4fa21673d6c..2fa44d8eca7 100644 --- a/packages/vkui/src/components/Alert/Alert.test.tsx +++ b/packages/vkui/src/components/Alert/Alert.test.tsx @@ -16,11 +16,9 @@ import { AdaptivityProvider } from '../AdaptivityProvider/AdaptivityProvider'; import { ConfigProvider } from '../ConfigProvider/ConfigProvider'; import { Alert, type AlertProps } from './Alert'; import styles from './Alert.module.css'; -import buttonStyles from '../Button/Button.module.css'; import modalDismissButtonStyles from '../ModalDismissButton/ModalDismissButton.module.css'; import popoutWrapperStyles from '../PopoutWrapper/PopoutWrapper.module.css'; import captionStyles from '../Typography/Caption/Caption.module.css'; -import footnoteStyles from '../Typography/Footnote/Footnote.module.css'; import titleStyles from '../Typography/Title/Title.module.css'; import typographyStyles from '../Typography/Typography.module.css'; @@ -393,36 +391,6 @@ describe('Alert', () => { }), ); - it.each([ - { - mode: 'cancel' as const, - className: styles.buttonModeCancel, - buttonClassName: buttonStyles.modeSecondary, - }, - { - mode: 'destructive' as const, - className: undefined, - buttonClassName: buttonStyles.modePrimary, - }, - ])( - 'should have className "$className" ans "$buttonClassName" with mode "$mode" in VKCOM platform', - withFakeTimers(async ({ mode, className, buttonClassName }) => { - const result = render( - - - , - ); - await waitCSSKeyframesAnimation(result.getByRole('alertdialog'), { - runOnlyPendingTimers: true, - }); - className && expect(screen.getByTestId('allow-test-id')).toHaveClass(className); - expect(screen.getByTestId('allow-test-id')).toHaveClass(buttonClassName); - }), - ); - describe('handles dismissButtonMode', () => { fakeTimersForScope(); it.each([ @@ -493,13 +461,6 @@ describe('Alert', () => { descriptionClassNames: [captionStyles.level1], platform: Platform.IOS, }, - { - title: 'Header', - titleClassNames: [titleStyles.level2, typographyStyles.weight2], - description: 'Text', - descriptionClassNames: [footnoteStyles.host], - platform: Platform.VKCOM, - }, { title: 'Header', titleClassNames: [titleStyles.level2, typographyStyles.weight2], diff --git a/packages/vkui/src/components/Alert/AlertAction.tsx b/packages/vkui/src/components/Alert/AlertAction.tsx index 87e2ebd5e4a..85f621f73c8 100644 --- a/packages/vkui/src/components/Alert/AlertAction.tsx +++ b/packages/vkui/src/components/Alert/AlertAction.tsx @@ -4,7 +4,7 @@ import type * as React from 'react'; import { classNames } from '@vkontakte/vkjs'; import { usePlatform } from '../../hooks/usePlatform'; import type { AnchorHTMLAttributesOnly } from '../../types'; -import { Button, type ButtonProps } from '../Button/Button'; +import { Button } from '../Button/Button'; import { Tappable } from '../Tappable/Tappable'; import type { AlertActionInterface } from './Alert'; import styles from './Alert.module.css'; @@ -37,22 +37,7 @@ const AlertActionIos = ({ mode, ...restProps }: AlertActionProps) => { }; const AlertActionBase = ({ mode, ...restProps }: AlertActionProps) => { - const platform = usePlatform(); - - let buttonMode: ButtonProps['mode'] = 'tertiary'; - - if (platform === 'vkcom') { - buttonMode = mode === 'cancel' ? 'secondary' : 'primary'; - } - - return ( -