-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
feat(CardGrid): rename props
spaced
to padding
1 parent
1d408a5
commit daec1b4
Showing
18 changed files
with
150 additions
and
26 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
packages/codemods/src/transforms/v7/__testfixtures__/card-grid/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,45 @@ | ||
import { Card, CardGrid } from '@vkontakte/vkui'; | ||
import React from 'react'; | ||
|
||
const App = () => { | ||
return ( | ||
<React.Fragment> | ||
{/* spaced=false -> padding=false */} | ||
<CardGrid | ||
size="s" | ||
spaced={false} | ||
> | ||
<Card> | ||
<div style={{ paddingBottom: '66%' }} /> | ||
</Card> | ||
<Card> | ||
<div style={{ paddingBottom: '66%' }} /> | ||
</Card> | ||
</CardGrid> | ||
{/* spaced=true -> padding=true */} | ||
<CardGrid | ||
size="s" | ||
spaced={true} | ||
> | ||
<Card> | ||
<div style={{ paddingBottom: '66%' }} /> | ||
</Card> | ||
<Card> | ||
<div style={{ paddingBottom: '66%' }} /> | ||
</Card> | ||
</CardGrid> | ||
{/* spaced -> padding */} | ||
<CardGrid | ||
size="s" | ||
spaced | ||
> | ||
<Card> | ||
<div style={{ paddingBottom: '66%' }} /> | ||
</Card> | ||
<Card> | ||
<div style={{ paddingBottom: '66%' }} /> | ||
</Card> | ||
</CardGrid> | ||
</React.Fragment> | ||
); | ||
}; |
49 changes: 49 additions & 0 deletions
49
packages/codemods/src/transforms/v7/__tests__/__snapshots__/card-grid.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,49 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`card-grid transforms correctly 1`] = ` | ||
"import { Card, CardGrid } from '@vkontakte/vkui'; | ||
import React from 'react'; | ||
const App = () => { | ||
return ( | ||
(<React.Fragment> | ||
{/* spaced=false -> padding=false */} | ||
<CardGrid | ||
size="s" | ||
padding={false} | ||
> | ||
<Card> | ||
<div style={{ paddingBottom: '66%' }} /> | ||
</Card> | ||
<Card> | ||
<div style={{ paddingBottom: '66%' }} /> | ||
</Card> | ||
</CardGrid> | ||
{/* spaced=true -> padding=true */} | ||
<CardGrid | ||
size="s" | ||
padding={true} | ||
> | ||
<Card> | ||
<div style={{ paddingBottom: '66%' }} /> | ||
</Card> | ||
<Card> | ||
<div style={{ paddingBottom: '66%' }} /> | ||
</Card> | ||
</CardGrid> | ||
{/* spaced -> padding */} | ||
<CardGrid | ||
size="s" | ||
padding | ||
> | ||
<Card> | ||
<div style={{ paddingBottom: '66%' }} /> | ||
</Card> | ||
<Card> | ||
<div style={{ paddingBottom: '66%' }} /> | ||
</Card> | ||
</CardGrid> | ||
</React.Fragment>) | ||
); | ||
};" | ||
`; |
12 changes: 12 additions & 0 deletions
12
packages/codemods/src/transforms/v7/__tests__/card-grid.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 = 'card-grid'; | ||
const fixtures = ['basic'] as const; | ||
|
||
describe(name, () => { | ||
fixtures.forEach((test) => | ||
defineSnapshotTestFromFixture(__dirname, name, global.TRANSFORM_OPTIONS, `${name}/${test}`), | ||
); | ||
}); |
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,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, 'CardGrid', alias); | ||
|
||
if (localName) { | ||
renameProp(j, source, localName, { spaced: 'padding' }); | ||
} | ||
|
||
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
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
...mponents/CardGrid/__image_snapshots__/cardgrid-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
...ponents/CardGrid/__image_snapshots__/cardgrid-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
...src/components/CardGrid/__image_snapshots__/cardgrid-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
...rc/components/CardGrid/__image_snapshots__/cardgrid-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
...components/CardGrid/__image_snapshots__/cardgrid-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
...omponents/CardGrid/__image_snapshots__/cardgrid-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.
4 changes: 2 additions & 2 deletions
4
.../components/CardGrid/__image_snapshots__/cardgrid-vkcom-firefox-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
...components/CardGrid/__image_snapshots__/cardgrid-vkcom-firefox-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
...c/components/CardGrid/__image_snapshots__/cardgrid-vkcom-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
.../components/CardGrid/__image_snapshots__/cardgrid-vkcom-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.