From 9af33b2e807e85ef085a05322e7096d17dfd9538 Mon Sep 17 00:00:00 2001 From: EldarMuhamethanov <61377022+EldarMuhamethanov@users.noreply.github.com> Date: Fri, 18 Oct 2024 13:07:56 +0300 Subject: [PATCH] feat(ActionSheet): rename `header` to `title`, `text` to `description` (#7785) --- .../action-sheet/basic.input.tsx | 16 +++++++++++++++ .../__snapshots__/action-sheet.ts.snap | 20 +++++++++++++++++++ .../transforms/v7/__tests__/action-sheet.ts | 12 +++++++++++ .../src/transforms/v7/action-sheet.ts | 18 +++++++++++++++++ .../ActionSheet.e2e-playground.tsx | 2 +- .../ActionSheet/ActionSheet.module.css | 4 ++-- .../ActionSheet/ActionSheet.stories.tsx | 6 +++--- .../ActionSheet/ActionSheet.test.tsx | 2 +- .../components/ActionSheet/ActionSheet.tsx | 18 ++++++++--------- .../vkui/src/components/ActionSheet/Readme.md | 4 ++-- ...zey-regular-vkcom-chromium-dark-1-snap.png | 4 ++-- ...ey-regular-vkcom-chromium-light-1-snap.png | 4 ++-- ...izey-regular-vkcom-firefox-dark-1-snap.png | 4 ++-- ...zey-regular-vkcom-firefox-light-1-snap.png | 4 ++-- ...sizey-regular-vkcom-webkit-dark-1-snap.png | 4 ++-- ...izey-regular-vkcom-webkit-light-1-snap.png | 4 ++-- ...y-regular-android-chromium-dark-1-snap.png | 4 ++-- ...-regular-android-chromium-light-1-snap.png | 4 ++-- ...e-sizey-regular-ios-webkit-dark-1-snap.png | 4 ++-- ...-sizey-regular-ios-webkit-light-1-snap.png | 4 ++-- 20 files changed, 104 insertions(+), 38 deletions(-) create mode 100644 packages/codemods/src/transforms/v7/__testfixtures__/action-sheet/basic.input.tsx create mode 100644 packages/codemods/src/transforms/v7/__tests__/__snapshots__/action-sheet.ts.snap create mode 100644 packages/codemods/src/transforms/v7/__tests__/action-sheet.ts create mode 100644 packages/codemods/src/transforms/v7/action-sheet.ts diff --git a/packages/codemods/src/transforms/v7/__testfixtures__/action-sheet/basic.input.tsx b/packages/codemods/src/transforms/v7/__testfixtures__/action-sheet/basic.input.tsx new file mode 100644 index 0000000000..1884e5d002 --- /dev/null +++ b/packages/codemods/src/transforms/v7/__testfixtures__/action-sheet/basic.input.tsx @@ -0,0 +1,16 @@ +import { ActionSheet, ActionSheetItem } from '@vkontakte/vkui'; +import React from 'react'; + +const App = () => { + return ( + + {}} + header="Вы действительно хотите удалить это видео из Ваших видео?" + text="Данное действие реально удалит видео, подумайте!" + > + Удалить видео + + + ); +}; diff --git a/packages/codemods/src/transforms/v7/__tests__/__snapshots__/action-sheet.ts.snap b/packages/codemods/src/transforms/v7/__tests__/__snapshots__/action-sheet.ts.snap new file mode 100644 index 0000000000..d6652d6e25 --- /dev/null +++ b/packages/codemods/src/transforms/v7/__tests__/__snapshots__/action-sheet.ts.snap @@ -0,0 +1,20 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`action-sheet transforms correctly 1`] = ` +"import { ActionSheet, ActionSheetItem } from '@vkontakte/vkui'; +import React from 'react'; + +const App = () => { + return ( + ( + {}} + title="Вы действительно хотите удалить это видео из Ваших видео?" + description="Данное действие реально удалит видео, подумайте!" + > + Удалить видео + + ) + ); +};" +`; diff --git a/packages/codemods/src/transforms/v7/__tests__/action-sheet.ts b/packages/codemods/src/transforms/v7/__tests__/action-sheet.ts new file mode 100644 index 0000000000..8621cd5870 --- /dev/null +++ b/packages/codemods/src/transforms/v7/__tests__/action-sheet.ts @@ -0,0 +1,12 @@ +jest.autoMockOff(); + +import { defineSnapshotTestFromFixture } from '../../../testHelpers/testHelper'; + +const name = 'action-sheet'; +const fixtures = ['basic'] as const; + +describe(name, () => { + fixtures.forEach((test) => + defineSnapshotTestFromFixture(__dirname, name, global.TRANSFORM_OPTIONS, `${name}/${test}`), + ); +}); diff --git a/packages/codemods/src/transforms/v7/action-sheet.ts b/packages/codemods/src/transforms/v7/action-sheet.ts new file mode 100644 index 0000000000..40deb68771 --- /dev/null +++ b/packages/codemods/src/transforms/v7/action-sheet.ts @@ -0,0 +1,18 @@ +import { API, FileInfo } from 'jscodeshift'; +import { getImportInfo, renameProp } from '../../codemod-helpers'; +import { JSCodeShiftOptions } from '../../types'; + +export const parser = 'tsx'; + +export default function transformer(file: FileInfo, api: API, options: JSCodeShiftOptions) { + const { alias } = options; + const j = api.jscodeshift; + const source = j(file.source); + const { localName } = getImportInfo(j, file, 'ActionSheet', alias); + + if (localName) { + renameProp(j, source, localName, { header: 'title', text: 'description' }); + } + + return source.toSource(); +} diff --git a/packages/vkui/src/components/ActionSheet/ActionSheet.e2e-playground.tsx b/packages/vkui/src/components/ActionSheet/ActionSheet.e2e-playground.tsx index 1b7aa26135..764189725e 100644 --- a/packages/vkui/src/components/ActionSheet/ActionSheet.e2e-playground.tsx +++ b/packages/vkui/src/components/ActionSheet/ActionSheet.e2e-playground.tsx @@ -84,7 +84,7 @@ const propSets = [ , ], ], - header: ['Заголовок'], + title: ['Заголовок'], }, ]; diff --git a/packages/vkui/src/components/ActionSheet/ActionSheet.module.css b/packages/vkui/src/components/ActionSheet/ActionSheet.module.css index 532afe65f4..ee4acdd0c2 100644 --- a/packages/vkui/src/components/ActionSheet/ActionSheet.module.css +++ b/packages/vkui/src/components/ActionSheet/ActionSheet.module.css @@ -41,7 +41,7 @@ animation: animation-actionsheet-slide-down var(--vkui--animation_duration_m) var(--vkui--animation_easing_platform); } -.title + .text { +.title + .description { margin-block-start: 8px; } @@ -79,7 +79,7 @@ position: relative; } -.ios .text { +.ios .description { position: relative; } diff --git a/packages/vkui/src/components/ActionSheet/ActionSheet.stories.tsx b/packages/vkui/src/components/ActionSheet/ActionSheet.stories.tsx index ddc40118a7..5d4ed7cd66 100644 --- a/packages/vkui/src/components/ActionSheet/ActionSheet.stories.tsx +++ b/packages/vkui/src/components/ActionSheet/ActionSheet.stories.tsx @@ -23,8 +23,8 @@ const story: Meta = { component: ActionSheet, parameters: { ...CanvasFullLayout, ...DisableCartesianParam }, argTypes: { - header: StringArg, - text: StringArg, + title: StringArg, + description: StringArg, }, }; @@ -109,7 +109,7 @@ export const WithSubtitle: Story = { export const WithTitle: Story = { ...Base, args: { - header: 'Вы действительно хотите удалить это видео из Ваших видео?', + title: 'Вы действительно хотите удалить это видео из Ваших видео?', items: [{ mode: 'destructive', children: 'Удалить видео' }], }, }; diff --git a/packages/vkui/src/components/ActionSheet/ActionSheet.test.tsx b/packages/vkui/src/components/ActionSheet/ActionSheet.test.tsx index 89f8e99d59..13c6ffe7cc 100644 --- a/packages/vkui/src/components/ActionSheet/ActionSheet.test.tsx +++ b/packages/vkui/src/components/ActionSheet/ActionSheet.test.tsx @@ -206,7 +206,7 @@ describe(ActionSheet, () => { }); it('renders header and text', () => { - render(); + render(); act(jest.runAllTimers); expect(screen.queryByText('The header title')).toBeTruthy(); expect(screen.queryByText('Text footnote')).toBeTruthy(); diff --git a/packages/vkui/src/components/ActionSheet/ActionSheet.tsx b/packages/vkui/src/components/ActionSheet/ActionSheet.tsx index 0f7c070a89..00acc1dbb1 100644 --- a/packages/vkui/src/components/ActionSheet/ActionSheet.tsx +++ b/packages/vkui/src/components/ActionSheet/ActionSheet.tsx @@ -26,9 +26,9 @@ export interface ActionSheetProps SharedDropdownProps, 'toggleRef' | 'popupOffsetDistance' | 'placement' | 'autoFocus' >, - Omit, 'autoFocus'> { - header?: React.ReactNode; - text?: React.ReactNode; + Omit, 'autoFocus' | 'title'> { + title?: React.ReactNode; + description?: React.ReactNode; /** * Закрыть попап по клику снаружи. */ @@ -46,8 +46,8 @@ export interface ActionSheetProps export const ActionSheet = ({ children, className, - header, - text, + title, + description, style, iosCloseItem, popupOffsetDistance, @@ -114,14 +114,14 @@ export const ActionSheet = ({ style={mode === 'menu' ? style : undefined} >
- {(header || text) && ( + {(title || description) && (
- {header && ( + {title && ( - {header} + {title} )} - {text && {text}} + {description && {description}}
)} {children} diff --git a/packages/vkui/src/components/ActionSheet/Readme.md b/packages/vkui/src/components/ActionSheet/Readme.md index 7400c27dde..91c101da5d 100644 --- a/packages/vkui/src/components/ActionSheet/Readme.md +++ b/packages/vkui/src/components/ActionSheet/Readme.md @@ -147,7 +147,7 @@ const SelectableActionSheet = () => { const speeds = ['0.25x', '0.5x', '0.75x', 'Нормальная', '1.25x', '1.5x', '2x', '3x']; return ( - + {speeds.map((speed) => ( 'title', Удалить видео diff --git a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-chromium-dark-1-snap.png b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-chromium-dark-1-snap.png index bff29ee42b..77e9240ba7 100644 --- a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-chromium-dark-1-snap.png +++ b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-chromium-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5132a92a880905f3a02341adf7d549c00a1bc7e6f1421df046e155b683d57259 -size 50868 +oid sha256:3887de3da8cbad39ffa90ca19883932afcd96490675c9ee20179ec7b6cda417c +size 50874 diff --git a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-chromium-light-1-snap.png b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-chromium-light-1-snap.png index 9917cacfae..f62c81196b 100644 --- a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-chromium-light-1-snap.png +++ b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-chromium-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:32098b22213a674bcd9e679d7119cb0c64647727cd91ada94e8243c49dfc2592 -size 51391 +oid sha256:1b229ebbb6a703fc0d298233be33ccdb00815b097c52f0209c238b374add2dd6 +size 51411 diff --git a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-firefox-dark-1-snap.png b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-firefox-dark-1-snap.png index 33676a20aa..afb7ad47fc 100644 --- a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-firefox-dark-1-snap.png +++ b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-firefox-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6322fe9712c18d30cbd3c77dcee3ab22b176d3cd704a41a52371aac754afd56a -size 85878 +oid sha256:6389d10a377075f54445bd8f844d7fe003c7cdbade03fece2b45107dc4ca828c +size 85629 diff --git a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-firefox-light-1-snap.png b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-firefox-light-1-snap.png index 549f626bc0..3ee9938304 100644 --- a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-firefox-light-1-snap.png +++ b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-firefox-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e14c007550f0485df250b0aa07866786be432cca8095cb6f0b81395cea71420f -size 86123 +oid sha256:75b21c1e428e2b0e29e9bdb93fdc7d1dbad10436c16707d344301a4785cee741 +size 85905 diff --git a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-webkit-dark-1-snap.png b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-webkit-dark-1-snap.png index 9bb8821bad..6c7e4b525b 100644 --- a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-webkit-dark-1-snap.png +++ b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-webkit-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6a6c2472601656dcf3807b796e6b02471233cbfe88dbab05e7bf40feb064ca93 -size 52106 +oid sha256:485aa2dad0c74575145fd6752bd9b69aa511c3c671863395bbbd8c68a97b6106 +size 52111 diff --git a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-webkit-light-1-snap.png b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-webkit-light-1-snap.png index 01d242d4cb..c670ebac05 100644 --- a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-webkit-light-1-snap.png +++ b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-desktop-sizey-regular-vkcom-webkit-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8092758c168960a2d6af7cd426076569a83387ed7294389459ec4022667a12f9 -size 52714 +oid sha256:e439a954e13e833e1d6342fff88ac7928009e8a71f77387cfdde60951525c786 +size 52748 diff --git a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-android-chromium-dark-1-snap.png b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-android-chromium-dark-1-snap.png index 167c679620..675dbe5c57 100644 --- a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-android-chromium-dark-1-snap.png +++ b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-android-chromium-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f80eb895db735c8953483ee1116d3de1303a2a519dffc6a5a4d3e7fd0a4be35e -size 44766 +oid sha256:1d3a5f6caa39d9449e32e190543d2fac9f0ecd8a2a1a1d04cbd79e81c3d48979 +size 44771 diff --git a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-android-chromium-light-1-snap.png b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-android-chromium-light-1-snap.png index 905fa1f5e6..3f9c0c25ef 100644 --- a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-android-chromium-light-1-snap.png +++ b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-android-chromium-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c4742c63b80712b8c09aff5e80fdf8452d17b5d579d586fb657d3b33e7626ac3 -size 44313 +oid sha256:9d54ba14b90c1ded7290bad7a3d5e57e7537bbf8f98a2ab9a271ce8f47d8aacb +size 44326 diff --git a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-ios-webkit-dark-1-snap.png b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-ios-webkit-dark-1-snap.png index 539cff107b..361e159cd8 100644 --- a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-ios-webkit-dark-1-snap.png +++ b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-ios-webkit-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b34cfe3682cec1d5715b1627c9205d361ae59b6fa435710bf5f1ce4bb5f3f2d4 -size 50229 +oid sha256:b8e6d29c5967fb806813836a5cf481b7517cdc36fd80280e7149c937ef067030 +size 50426 diff --git a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-ios-webkit-light-1-snap.png b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-ios-webkit-light-1-snap.png index f949e0c8b7..0be91dd831 100644 --- a/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-ios-webkit-light-1-snap.png +++ b/packages/vkui/src/components/ActionSheet/__image_snapshots__/actionsheet-viewwidth-mobile-sizey-regular-ios-webkit-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:88a87b7521c28242312d28fd365c1feb1acf25c00d624eecd44efcd6e8023b85 -size 50009 +oid sha256:eb109a2fdc6fe9396f7ba97f55116303fc578fb0cd729d7ef6cb128d5fe915c6 +size 50145