-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lili.21
committed
Sep 4, 2023
1 parent
e2c5aa8
commit 9a167e2
Showing
5 changed files
with
61 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { Table } from 'antd' | ||
import { Table, Space } from 'antd' | ||
|
||
export const test = () => { | ||
const paginationProps = { current: 1, showTotal: (t) => `${t}条` } | ||
return <Table pagination={paginationProps} /> | ||
return <Space direction="horizon" /> | ||
} |
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,27 @@ | ||
const { removeAntdImportAndAddSemiImport } = require('./utils') | ||
module.exports = function transformer(file, api) { | ||
const j = api.jscodeshift | ||
const root = j(file.source) | ||
|
||
removeAntdImportAndAddSemiImport(j, root, 'Popconfirm', 'Popconfirm') | ||
|
||
// Find all JSXElements with the name "Popconfirm" | ||
root.findJSXElements('Popconfirm').forEach((path) => { | ||
const { openingElement } = path.value | ||
|
||
// Find the "placement" attribute and replace it with "position" | ||
const placementAttribute = openingElement.attributes.find( | ||
(attr) => attr.name.name === 'placement' | ||
) | ||
if (placementAttribute) { | ||
placementAttribute.name.name = 'position' | ||
} else { | ||
// semi的默认position为bottom,antd为top,所以需要默认添加 position="top" 属性 | ||
openingElement.attributes.push( | ||
j.jsxAttribute(j.jsxIdentifier('position'), j.literal('top')) | ||
) | ||
} | ||
}) | ||
|
||
return root.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,29 @@ | ||
const { removeAntdImportAndAddSemiImport } = require('./utils') | ||
module.exports = function transformer(file, api) { | ||
const j = api.jscodeshift | ||
const root = j(file.source) | ||
|
||
removeAntdImportAndAddSemiImport(j, root, 'Space', 'Space') | ||
|
||
// Find all JSXElements with the name "Space" | ||
root.findJSXElements('Space').forEach((path) => { | ||
const { openingElement } = path.value | ||
|
||
// Find the "direction" attribute and replace it with "vertical" | ||
const directionAttribute = openingElement.attributes.find( | ||
(attr) => attr.name.name === 'direction' | ||
) | ||
if (directionAttribute) { | ||
if (directionAttribute.value.value === 'vertical') { | ||
openingElement.attributes.push( | ||
j.jsxAttribute(j.jsxIdentifier('vertical')) | ||
) | ||
} | ||
openingElement.attributes = openingElement.attributes.filter( | ||
(attr) => attr.name.name !== 'direction' | ||
) | ||
} | ||
}) | ||
|
||
return root.toSource() | ||
} |