diff --git a/packages/codemods/src/transforms/v7/__testfixtures__/panel-header-content/basic.input.tsx b/packages/codemods/src/transforms/v7/__testfixtures__/panel-header-content/basic.input.tsx new file mode 100644 index 0000000000..fdc90f0e1c --- /dev/null +++ b/packages/codemods/src/transforms/v7/__testfixtures__/panel-header-content/basic.input.tsx @@ -0,0 +1,22 @@ +import { Avatar, PanelHeader, PanelHeaderBack, PanelHeaderButton, PanelHeaderContent } from '@vkontakte/vkui'; +import React from 'react'; + +const App = () => { + return ( + + {}} />} + after={ + {}}/> + } + > + } + > + Влад Анесов + + + + ); +}; diff --git a/packages/codemods/src/transforms/v7/__tests__/__snapshots__/panel-header-content.ts.snap b/packages/codemods/src/transforms/v7/__tests__/__snapshots__/panel-header-content.ts.snap new file mode 100644 index 0000000000..d97cf39a51 --- /dev/null +++ b/packages/codemods/src/transforms/v7/__tests__/__snapshots__/panel-header-content.ts.snap @@ -0,0 +1,26 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`panel-header-content transforms correctly 1`] = ` +"import { Avatar, PanelHeader, PanelHeaderBack, PanelHeaderButton, PanelHeaderContent } from '@vkontakte/vkui'; +import React from 'react'; + +const App = () => { + return ( + ( + {}} />} + after={ + {}}/> + } + > + } + > + Влад Анесов + + + ) + ); +};" +`; diff --git a/packages/codemods/src/transforms/v7/__tests__/panel-header-content.ts b/packages/codemods/src/transforms/v7/__tests__/panel-header-content.ts new file mode 100644 index 0000000000..e5f675ba4b --- /dev/null +++ b/packages/codemods/src/transforms/v7/__tests__/panel-header-content.ts @@ -0,0 +1,12 @@ +jest.autoMockOff(); + +import { defineSnapshotTestFromFixture } from '../../../testHelpers/testHelper'; + +const name = 'panel-header-content'; +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/panel-header-content.ts b/packages/codemods/src/transforms/v7/panel-header-content.ts new file mode 100644 index 0000000000..e189876cc7 --- /dev/null +++ b/packages/codemods/src/transforms/v7/panel-header-content.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, 'PanelHeaderContent', alias); + + if (localName) { + renameProp(j, source, localName, { status: 'subtitle' }); + } + + return source.toSource(); +} diff --git a/packages/vkui/src/components/PanelHeader/Readme.md b/packages/vkui/src/components/PanelHeader/Readme.md index b5d65e54f6..f4616f2632 100644 --- a/packages/vkui/src/components/PanelHeader/Readme.md +++ b/packages/vkui/src/components/PanelHeader/Readme.md @@ -140,7 +140,7 @@ const Example = () => { /> } > - } status="Был в сети вчера"> + } subtitle="Был в сети вчера"> Влад Анесов diff --git a/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.e2e-playground.tsx b/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.e2e-playground.tsx index b85656e07b..c006fe1da3 100644 --- a/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.e2e-playground.tsx +++ b/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.e2e-playground.tsx @@ -9,7 +9,7 @@ export const PanelHeaderContentPlayground = (props: ComponentPlaygroundProps) => propSets={[ { before: [, undefined], - status: ['Был в сети вчера', undefined], + subtitle: ['Был в сети вчера', undefined], children: ['Влад Анесов'], aside: ['Подробнее', undefined], }, diff --git a/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.module.css b/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.module.css index b58d57e9c3..156cc2925a 100644 --- a/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.module.css +++ b/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.module.css @@ -24,7 +24,7 @@ block-size: 100%; } -.status, +.subtitle, .childrenIn, .childrenText { overflow: hidden; @@ -32,7 +32,7 @@ text-overflow: ellipsis; } -.status { +.subtitle { order: 1; margin-block-start: 1px; max-inline-size: 100%; diff --git a/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.stories.tsx b/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.stories.tsx index 41df9f06af..a17d88c5ba 100644 --- a/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.stories.tsx +++ b/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.stories.tsx @@ -36,7 +36,7 @@ export const Example: Story = { } > - } status="Был в сети вчера"> + } subtitle="Был в сети вчера"> Влад Анесов diff --git a/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.tsx b/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.tsx index cdbbab4268..d89f82534d 100644 --- a/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.tsx +++ b/packages/vkui/src/components/PanelHeaderContent/PanelHeaderContent.tsx @@ -25,18 +25,18 @@ const sizeYClassNames = { export interface PanelHeaderContentProps extends HTMLAttributesWithRootRef { aside?: React.ReactNode; before?: React.ReactNode; - status?: React.ReactNode; + subtitle?: React.ReactNode; } interface PanelHeaderChildrenProps extends HasChildren { - hasStatus: boolean; + hasSubtitle: boolean; hasBefore: boolean; } -const PanelHeaderChildren = ({ hasStatus, hasBefore, children }: PanelHeaderChildrenProps) => { +const PanelHeaderChildren = ({ hasSubtitle, hasBefore, children }: PanelHeaderChildrenProps) => { const platform = usePlatform(); - return hasStatus || hasBefore ? ( + return hasSubtitle || hasBefore ? ( - {hasReactNode(status) && {status}} + {hasReactNode(subtitle) && {subtitle}}
- + {children} {hasReactNode(aside) &&
{aside}
} diff --git a/packages/vkui/src/components/PanelHeaderContent/Readme.md b/packages/vkui/src/components/PanelHeaderContent/Readme.md index d88f66f362..5401b256c4 100644 --- a/packages/vkui/src/components/PanelHeaderContent/Readme.md +++ b/packages/vkui/src/components/PanelHeaderContent/Readme.md @@ -23,7 +23,7 @@ const Example = () => { } > } > Влад Анесов diff --git a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-android-chromium-dark-1-snap.png b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-android-chromium-dark-1-snap.png index f433aefaf5..12618d00c7 100644 --- a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-android-chromium-dark-1-snap.png +++ b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-android-chromium-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bad2e2864bbfec448ce4b8628773e7fffeba977675c8c530911cee6147df7e16 -size 69999 +oid sha256:20444fd2543962b8fca65358d516d272f1352f52f1f234773d3ea37887b28fcd +size 69615 diff --git a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-android-chromium-light-1-snap.png b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-android-chromium-light-1-snap.png index ab67ffd328..431ca1bebe 100644 --- a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-android-chromium-light-1-snap.png +++ b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-android-chromium-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a922bbbc707d80a96c747f84aa39b528b550849d6d3d4b95981a01145b6da7bd -size 64128 +oid sha256:2b433bcf1954257d2904aed7bfda32a4aa3af34eb1369da4e43ec86834b43017 +size 63702 diff --git a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-ios-webkit-dark-1-snap.png b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-ios-webkit-dark-1-snap.png index 78bf6cac33..e39c24f3da 100644 --- a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-ios-webkit-dark-1-snap.png +++ b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-ios-webkit-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:194b453248d0d9cf2f57c566599fdf4fc0815cc173e937551bac0a6c69b53625 -size 71094 +oid sha256:dd4b3d46e1dff85885f421774e9394e5dbae65946d2c2f569d725b57bfafb69c +size 70790 diff --git a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-ios-webkit-light-1-snap.png b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-ios-webkit-light-1-snap.png index 1408887292..c3d1a07080 100644 --- a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-ios-webkit-light-1-snap.png +++ b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-ios-webkit-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a013c196b0827ee37f54c467b850796322eae0d8bf9b0f1a23e394ea4ec094d8 -size 65152 +oid sha256:817d27d97d785cb193b5fc34e41c7c3c6b879cabbbb3b513d836b7fe524a600b +size 64955 diff --git a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-chromium-dark-1-snap.png b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-chromium-dark-1-snap.png index b057b3aaaa..f719e58c0a 100644 --- a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-chromium-dark-1-snap.png +++ b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-chromium-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6d450dff5c0586a27f8f6263255bdfd0025ef21d00782b2e747419603bfae40d -size 63831 +oid sha256:04e8900d72de666c8b4362f7b8d77e84aa5e8f4f6e8f65c24f7e7800d826e754 +size 63873 diff --git a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-chromium-light-1-snap.png b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-chromium-light-1-snap.png index da7e9bf162..0a549668fc 100644 --- a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-chromium-light-1-snap.png +++ b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-chromium-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2857335c2f85a1a796969adaa842c7f3c27f98174a71521f2e7cd430149a20bd -size 64116 +oid sha256:ee74c7361b294bebf07fbc184ca1e83951bad8bafb5f37966cd74ae5fcef5c25 +size 64275 diff --git a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-firefox-dark-1-snap.png b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-firefox-dark-1-snap.png index 3ec51d24bf..e561caa428 100644 --- a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-firefox-dark-1-snap.png +++ b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-firefox-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:012fd7e92f68b42a0ae120095b77caa70beaaf890617c7d25a2d9c6ecff65bc6 -size 93786 +oid sha256:5294847e611b90b8d0dee64268efbba7d4775c31b72e4cbd3057b6cd31f12571 +size 93047 diff --git a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-firefox-light-1-snap.png b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-firefox-light-1-snap.png index fefaa8c839..74ca896722 100644 --- a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-firefox-light-1-snap.png +++ b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-firefox-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c05bdc210bbdb336987b41d1821abde9b9e9fde0ef6d0e4eed4c44f15d7d3d24 -size 92891 +oid sha256:1267390a9357cf07a353efab04374cfda58a79359293aabf8618cd62ca4c207e +size 92189 diff --git a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-webkit-dark-1-snap.png b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-webkit-dark-1-snap.png index ada07e2742..f28fe6b6d0 100644 --- a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-webkit-dark-1-snap.png +++ b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-webkit-dark-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f2753af0c144c8bf1fd88d91a99fc1a3ff6d1ce799d5f957ba40c4ca058145b5 -size 66001 +oid sha256:26db017fcc734ab46100e8041aff929fdf9f7772336692f3f5d6ac2af773aca7 +size 66038 diff --git a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-webkit-light-1-snap.png b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-webkit-light-1-snap.png index 4a68b4bbfd..e61b0a474f 100644 --- a/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-webkit-light-1-snap.png +++ b/packages/vkui/src/components/PanelHeaderContent/__image_snapshots__/panelheadercontent-vkcom-webkit-light-1-snap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:88dc47f9d3b9f87db73bb181a6e080b16f6e5b45d1254514701e04401466cd90 -size 66346 +oid sha256:650834f95086e4b5bc80f361a23fd2c9e151596453cc7479821dec4f6d687226 +size 66311