-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(HorizontalScroll): remove inline prop (#7582)
* feat(HorizontalScroll): remove inline prop * fix: readme clean up + screenshots update * feat: add codemod tests * feat(HorizontalCellShowMore): remove compensateLastCellIndent prop * fix: update wrongly generate snapshot * fix: update codemod test
- Loading branch information
1 parent
010a3da
commit 7460804
Showing
36 changed files
with
263 additions
and
127 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...ges/codemods/src/transforms/v7/__testfixtures__/horizontal-cell-show-more/basic.input.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 { HorizontalCellShowMore, HorizontalScroll } from '@vkontakte/vkui'; | ||
import React from 'react'; | ||
import '@vkontakte/vkui/dist/vkui.css'; | ||
|
||
const App = () => { | ||
return ( | ||
<React.Fragment> | ||
<HorizontalScroll> | ||
<div /> | ||
<div /> | ||
<div /> | ||
<HorizontalCellShowMore onClick={() => {}} compensateLastCellIndent size="m" height={88} /> | ||
</HorizontalScroll> | ||
<HorizontalScroll> | ||
<div /> | ||
<div /> | ||
<div /> | ||
<HorizontalCellShowMore onClick={() => {}} compensateLastCellIndent={true} size="m" height={88} /> | ||
</HorizontalScroll> | ||
</React.Fragment> | ||
); | ||
}; |
20 changes: 20 additions & 0 deletions
20
packages/codemods/src/transforms/v7/__testfixtures__/horizontal-scroll/basic.input.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,20 @@ | ||
import { HorizontalScroll } from '@vkontakte/vkui'; | ||
import React from 'react'; | ||
import '@vkontakte/vkui/dist/vkui.css'; | ||
|
||
const App = () => { | ||
return ( | ||
<React.Fragment> | ||
<HorizontalScroll inline> | ||
<div /> | ||
<div /> | ||
<div /> | ||
</HorizontalScroll> | ||
<HorizontalScroll arrowSize="m" inline={true}> | ||
<div /> | ||
<div /> | ||
<div /> | ||
</HorizontalScroll> | ||
</React.Fragment> | ||
); | ||
}; |
26 changes: 26 additions & 0 deletions
26
...ages/codemods/src/transforms/v7/__tests__/__snapshots__/horizontal-cell-show-more.ts.snap
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,26 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`horizontal-cell-show-more transforms correctly 1`] = ` | ||
"import { HorizontalCellShowMore, HorizontalScroll } from '@vkontakte/vkui'; | ||
import React from 'react'; | ||
import '@vkontakte/vkui/dist/vkui.css'; | ||
const App = () => { | ||
return ( | ||
(<React.Fragment> | ||
<HorizontalScroll> | ||
<div /> | ||
<div /> | ||
<div /> | ||
<HorizontalCellShowMore onClick={() => {}} size="m" height={88} /> | ||
</HorizontalScroll> | ||
<HorizontalScroll> | ||
<div /> | ||
<div /> | ||
<div /> | ||
<HorizontalCellShowMore onClick={() => {}} size="m" height={88} /> | ||
</HorizontalScroll> | ||
</React.Fragment>) | ||
); | ||
};" | ||
`; |
24 changes: 24 additions & 0 deletions
24
packages/codemods/src/transforms/v7/__tests__/__snapshots__/horizontal-scroll.ts.snap
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,24 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`horizontal-scroll transforms correctly 1`] = ` | ||
"import { HorizontalScroll } from '@vkontakte/vkui'; | ||
import React from 'react'; | ||
import '@vkontakte/vkui/dist/vkui.css'; | ||
const App = () => { | ||
return ( | ||
(<React.Fragment> | ||
<HorizontalScroll> | ||
<div /> | ||
<div /> | ||
<div /> | ||
</HorizontalScroll> | ||
<HorizontalScroll arrowSize="m"> | ||
<div /> | ||
<div /> | ||
<div /> | ||
</HorizontalScroll> | ||
</React.Fragment>) | ||
); | ||
};" | ||
`; |
12 changes: 12 additions & 0 deletions
12
packages/codemods/src/transforms/v7/__tests__/horizontal-cell-show-more.ts
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,12 @@ | ||
jest.autoMockOff(); | ||
|
||
import { defineSnapshotTestFromFixture } from '../../../testHelpers/testHelper'; | ||
|
||
const name = 'horizontal-cell-show-more'; | ||
const fixtures = ['basic'] as const; | ||
|
||
describe(name, () => { | ||
fixtures.forEach((test) => | ||
defineSnapshotTestFromFixture(__dirname, name, global.TRANSFORM_OPTIONS, `${name}/${test}`), | ||
); | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/codemods/src/transforms/v7/__tests__/horizontal-scroll.ts
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,12 @@ | ||
jest.autoMockOff(); | ||
|
||
import { defineSnapshotTestFromFixture } from '../../../testHelpers/testHelper'; | ||
|
||
const name = 'horizontal-scroll'; | ||
const fixtures = ['basic'] as const; | ||
|
||
describe(name, () => { | ||
fixtures.forEach((test) => | ||
defineSnapshotTestFromFixture(__dirname, name, global.TRANSFORM_OPTIONS, `${name}/${test}`), | ||
); | ||
}); |
47 changes: 47 additions & 0 deletions
47
packages/codemods/src/transforms/v7/horizontal-cell-show-more.ts
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,47 @@ | ||
import { API, FileInfo } from 'jscodeshift'; | ||
import { getImportInfo } from '../../codemod-helpers'; | ||
import { report } from '../../report'; | ||
import { JSCodeShiftOptions } from '../../types'; | ||
|
||
export const parser = 'tsx'; | ||
|
||
const componentName = 'HorizontalCellShowMore'; | ||
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, componentName, alias); | ||
|
||
if (!localName) { | ||
return source.toSource(); | ||
} | ||
|
||
source | ||
.find(j.JSXOpeningElement) | ||
.filter( | ||
(path) => path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName, | ||
) | ||
.find(j.JSXAttribute) | ||
.filter((attribute) => attribute.node.name.name === 'compensateLastCellIndent') | ||
.forEach((attribute) => { | ||
const node = attribute.node; | ||
|
||
if (!node.value) { | ||
j(attribute).remove(); | ||
} else if ( | ||
node.value.type === 'JSXExpressionContainer' && | ||
node.value.expression.type === 'BooleanLiteral' | ||
) { | ||
if (node.value.expression.value) { | ||
j(attribute).remove(); | ||
} else { | ||
report( | ||
api, | ||
`Manual changes required for ${componentName}'s "compensateLastCellIndent" prop. You might not need it anymore.`, | ||
); | ||
} | ||
} | ||
}); | ||
|
||
return source.toSource(); | ||
} |
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,44 @@ | ||
import { API, FileInfo } from 'jscodeshift'; | ||
import { getImportInfo } from '../../codemod-helpers'; | ||
import { report } from '../../report'; | ||
import { JSCodeShiftOptions } from '../../types'; | ||
|
||
export const parser = 'tsx'; | ||
|
||
const componentName = 'HorizontalScroll'; | ||
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, componentName, alias); | ||
|
||
if (!localName) { | ||
return source.toSource(); | ||
} | ||
|
||
source | ||
.find(j.JSXOpeningElement) | ||
.filter( | ||
(path) => path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName, | ||
) | ||
.find(j.JSXAttribute) | ||
.filter((attribute) => attribute.node.name.name === 'inline') | ||
.forEach((attribute) => { | ||
const node = attribute.node; | ||
|
||
if (!node.value) { | ||
j(attribute).remove(); | ||
} else if ( | ||
node.value.type === 'JSXExpressionContainer' && | ||
node.value.expression.type === 'BooleanLiteral' | ||
) { | ||
if (node.value.expression.value) { | ||
j(attribute).remove(); | ||
} else { | ||
report(api, `Manual changes required for ${componentName}'s "inline" prop.`); | ||
} | ||
} | ||
}); | ||
|
||
return source.toSource(); | ||
} |
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
.CardScroll__in { | ||
display: flex; | ||
align-items: stretch; | ||
inline-size: 100%; | ||
} | ||
|
||
.CardScroll__gap { | ||
|
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
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
4 changes: 2 additions & 2 deletions
4
..._snapshots__/horizontalcellshowmore-small-size-android-chromium-dark-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.
4 changes: 2 additions & 2 deletions
4
...snapshots__/horizontalcellshowmore-small-size-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.
4 changes: 2 additions & 2 deletions
4
..._image_snapshots__/horizontalcellshowmore-small-size-ios-webkit-dark-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.
4 changes: 2 additions & 2 deletions
4
...image_snapshots__/horizontalcellshowmore-small-size-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.
4 changes: 2 additions & 2 deletions
4
...ge_snapshots__/horizontalcellshowmore-small-size-vkcom-chromium-dark-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.
4 changes: 2 additions & 2 deletions
4
...e_snapshots__/horizontalcellshowmore-small-size-vkcom-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.
Oops, something went wrong.