-
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 #685 from oceanbase/dengfuping-dev
fix(codemod): normal function and anonymous function should use token object
- Loading branch information
Showing
8 changed files
with
177 additions
and
9 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
37 changes: 37 additions & 0 deletions
37
packages/codemod/transforms/__testfixtures__/style-to-token/function.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,37 @@ | ||
import React from 'react'; | ||
import { Alert, Button, Tooltip } from '@oceanbase/design'; | ||
|
||
function getComponent1() { | ||
const tokenList = ['rgb(0 0 0 / 45%)', '#006AFF', '#f3f6fc']; | ||
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> | ||
); | ||
}; | ||
|
||
const getComponent2 = () => { | ||
const tokenList = ['rgb(0 0 0 / 45%)', '#006AFF', '#f3f6fc']; | ||
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 () => { | ||
const tokenList = ['rgb(0 0 0 / 45%)', '#006AFF', '#f3f6fc']; | ||
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 { getComponent1, getComponent2 }; |
37 changes: 37 additions & 0 deletions
37
packages/codemod/transforms/__testfixtures__/style-to-token/function.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,37 @@ | ||
import React from 'react'; | ||
import { Alert, Button, token, Tooltip } from '@oceanbase/design'; | ||
|
||
function getComponent1() { | ||
const tokenList = [token.colorTextTertiary, token.colorInfo, 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> | ||
<Tooltip color={token.colorBgContainer} backgroundColor={token.colorErrorBg} borderColor={token.colorBgLayout} border={`1px solid ${token.colorBgLayout}`} /> | ||
</div>) | ||
); | ||
}; | ||
|
||
const getComponent2 = () => { | ||
const tokenList = [token.colorTextTertiary, token.colorInfo, 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> | ||
<Tooltip color={token.colorBgContainer} backgroundColor={token.colorErrorBg} borderColor={token.colorBgLayout} border={`1px solid ${token.colorBgLayout}`} /> | ||
</div>) | ||
); | ||
}; | ||
|
||
export default () => { | ||
const tokenList = [token.colorTextTertiary, token.colorInfo, 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> | ||
<Tooltip color={token.colorBgContainer} backgroundColor={token.colorErrorBg} borderColor={token.colorBgLayout} border={`1px solid ${token.colorBgLayout}`} /> | ||
</div>) | ||
); | ||
}; | ||
|
||
export { getComponent1, getComponent2 }; |
26 changes: 26 additions & 0 deletions
26
packages/codemod/transforms/__testfixtures__/style-to-token/hooks.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,26 @@ | ||
import React from 'react'; | ||
import { Alert, Button, Tooltip } from '@oceanbase/design'; | ||
|
||
function useComponent1 () { | ||
const tokenList = ['rgb(0 0 0 / 45%)', '#006AFF', '#f3f6fc']; | ||
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> | ||
); | ||
}; | ||
|
||
const useComponent2 = () => { | ||
const tokenList = ['rgb(0 0 0 / 45%)', '#006AFF', '#f3f6fc']; | ||
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 { useComponent1, useComponent2 }; |
28 changes: 28 additions & 0 deletions
28
packages/codemod/transforms/__testfixtures__/style-to-token/hooks.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,28 @@ | ||
import React from 'react'; | ||
import { Alert, Button, theme, Tooltip } from '@oceanbase/design'; | ||
|
||
function useComponent1 () { | ||
const { token } = theme.useToken(); | ||
const tokenList = [token.colorTextTertiary, token.colorInfo, 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> | ||
<Tooltip color={token.colorBgContainer} backgroundColor={token.colorErrorBg} borderColor={token.colorBgLayout} border={`1px solid ${token.colorBgLayout}`} /> | ||
</div>) | ||
); | ||
}; | ||
|
||
const useComponent2 = () => { | ||
const { token } = theme.useToken(); | ||
const tokenList = [token.colorTextTertiary, token.colorInfo, 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> | ||
<Tooltip color={token.colorBgContainer} backgroundColor={token.colorErrorBg} borderColor={token.colorBgLayout} border={`1px solid ${token.colorBgLayout}`} /> | ||
</div>) | ||
); | ||
}; | ||
|
||
export { useComponent1, useComponent2 }; |
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