-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from oceanbase/dengfuping-dev
fix(codemod): should avoid duplicate `const { token } = theme.useToken();`
- Loading branch information
Showing
6 changed files
with
126 additions
and
29 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
packages/codemod/transforms/__testfixtures__/style-to-token/existed-useToken.input.js
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,15 @@ | ||
import React from 'react'; | ||
import { Alert, Button, theme, Tooltip } from '@oceanbase/design'; | ||
|
||
const Demo = () => { | ||
const { token } = theme.useToken(); | ||
return ( | ||
<div> | ||
<Alert style={{ color: 'rgba(0, 0, 0, 0.85)', background: 'rgba(0, 0, 0,0.65)', backgroundColor: 'rgba(0,0,0,0.45)', border: '1px solid #d9d9d9' }} /> | ||
<Button style={{ color: '#1890ff', background: '#52c41a', backgroundColor: '#faad14', borderColor: '#ff4D4F' }}></Button> | ||
<Tooltip color="#ffffff" backgroundColor="#fff1f0" borderColor="#fafafa" border="1px solid #fafafa" /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Demo; |
15 changes: 15 additions & 0 deletions
15
packages/codemod/transforms/__testfixtures__/style-to-token/existed-useToken.output.js
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,15 @@ | ||
import React from 'react'; | ||
import { Alert, Button, theme, Tooltip } from '@oceanbase/design'; | ||
|
||
const Demo = () => { | ||
const { token } = theme.useToken(); | ||
return ( | ||
(<div> | ||
<Alert style={{ color: token.colorText, background: token.colorTextSecondary, backgroundColor: token.colorTextTertiary, border: `1px solid ${token.colorBorder}` }} /> | ||
<Button style={{ color: token.colorInfo, background: token.colorSuccess, backgroundColor: token.colorWarning, borderColor: token.colorError }}></Button> | ||
<Tooltip color={token.colorBgContainer} backgroundColor="#fff1f0" borderColor={token.colorBgLayout} border={`1px solid ${token.colorBgLayout}`} /> | ||
</div>) | ||
); | ||
}; | ||
|
||
export default Demo; |
18 changes: 18 additions & 0 deletions
18
...ages/codemod/transforms/__testfixtures__/style-to-token/multiple-block-statement.input.js
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 React from 'react'; | ||
import { Alert, Button, Tooltip } from '@oceanbase/design'; | ||
|
||
const Demo = () => { | ||
const columns = [{ | ||
render: () => { | ||
return <Tooltip color="#ffffff" backgroundColor="#fff1f0" borderColor="#fafafa" border="1px solid #fafafa" />; | ||
}, | ||
}]; | ||
return ( | ||
<div> | ||
<Alert style={{ color: 'rgba(0, 0, 0, 0.85)', background: 'rgba(0, 0, 0,0.65)', backgroundColor: 'rgba(0,0,0,0.45)', border: '1px solid #d9d9d9' }} /> | ||
<Button style={{ color: '#1890ff', background: '#52c41a', backgroundColor: '#faad14', borderColor: '#ff4D4F' }}></Button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Demo; |
19 changes: 19 additions & 0 deletions
19
...ges/codemod/transforms/__testfixtures__/style-to-token/multiple-block-statement.output.js
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,19 @@ | ||
import React from 'react'; | ||
import { Alert, Button, theme, Tooltip } from '@oceanbase/design'; | ||
|
||
const Demo = () => { | ||
const { token } = theme.useToken(); | ||
const columns = [{ | ||
render: () => { | ||
return <Tooltip color={token.colorBgContainer} backgroundColor="#fff1f0" borderColor={token.colorBgLayout} border={`1px solid ${token.colorBgLayout}`} />; | ||
}, | ||
}]; | ||
return ( | ||
(<div> | ||
<Alert style={{ color: token.colorText, background: token.colorTextSecondary, backgroundColor: token.colorTextTertiary, border: `1px solid ${token.colorBorder}` }} /> | ||
<Button style={{ color: token.colorInfo, background: token.colorSuccess, backgroundColor: token.colorWarning, borderColor: token.colorError }}></Button> | ||
</div>) | ||
); | ||
}; | ||
|
||
export default Demo; |
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