Skip to content

Commit

Permalink
feat: Col, Row支持
Browse files Browse the repository at this point in the history
  • Loading branch information
lili.21 committed Aug 1, 2023
1 parent 1f57369 commit 853f2ff
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 57 deletions.
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
const TRANSFORMER_INQUIRER_CHOICES = [
...,
// 新增在这里即可
{
name: 'Notification',
value: 'Notification'
}
'Notification'
]
```

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ Replacing `<path>` and `<transform>` with appropriate values.
- [ ] Modal
- [x] Slider
- [x] Popover
- [ ] Col
- [ ] Row
- [x] Col
- [x] Row
- [ ] Tag
- [ ] Timeline
- [ ] Pagination
- [ ] Form相关
64 changes: 19 additions & 45 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,51 +46,25 @@ function runTransform({ files, flags, transformer }) {
}

const TRANSFORMER_INQUIRER_CHOICES = [
{
name: 'Divider',
value: 'Divider'
},
{
name: 'Breadcrumb',
value: 'Breadcrumb'
},
{
name: 'Notification',
value: 'Notification'
},
{
name: 'Table',
value: 'Table'
},
{
name: 'Tabs',
value: 'Tabs'
},
{
name: 'Message',
value: 'Message'
},
{
name: 'Drawer',
value: 'Drawer'
},
{
name: 'Spin',
value: 'Spin'
},
{
name: 'Empty',
value: 'Empty'
},
{
name: 'Slider',
value: 'Slider'
},
{
name: 'Popover',
value: 'Popover'
}
].sort((a, b) => a.name.localeCompare(b.name))
'Divider',
'Breadcrumb',
'Notification',
'Table',
'Tabs',
'Message',
'Drawer',
'Spin',
'Empty',
'Slider',
'Popover',
'Col',
'Row'
]
.sort((a, b) => a.localeCompare(b))
.map((v) => ({
name: v,
value: v
}))

function expandFilePathsIfNeeded(filesBeforeExpansion) {
const shouldExpandFiles = filesBeforeExpansion.some((file) =>
Expand Down
10 changes: 4 additions & 6 deletions test.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Button, Empty, Popover } from 'antd'

import { Divider, Tabs, TabPane } from '@douyinfe/semi-ui'
import { Row, Col } from 'antd'

function Test() {
return (
<Popover placement="bottom">
<button>hello</button>
</Popover>
<Row>
<Col span={24}>col</Col>
</Row>
)
}
9 changes: 9 additions & 0 deletions transforms/Col.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { removeAntdImportAndAddSemiImport } = require('./utils')
module.exports = function transformer(file, api) {
const j = api.jscodeshift
const root = j(file.source)

removeAntdImportAndAddSemiImport(j, root, 'Col', 'Col')

return root.toSource()
}
9 changes: 9 additions & 0 deletions transforms/Row.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { removeAntdImportAndAddSemiImport } = require('./utils')
module.exports = function transformer(file, api) {
const j = api.jscodeshift
const root = j(file.source)

removeAntdImportAndAddSemiImport(j, root, 'Row', 'Row')

return root.toSource()
}

0 comments on commit 853f2ff

Please sign in to comment.