Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Format code by prettier #219

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
color: rgba(0, 0, 0, 0.85);
background: rgba(0, 0, 0,0.65);
background-color: rgba(0,0,0,0.45);
border-color: #fafafa;
border: 1px solid #fafafa;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
color: @colorText;
background: @colorTextSecondary;
background-color: @colorTextTertiary;
border-color: @colorBgLayout;
border: 1px solid @colorBgLayout;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
color: rgba(0, 0, 0, 0.85);
background: rgba(0, 0, 0,0.65);
background-color: rgba(0,0,0,0.45);
border-color: #fafafa;
border: 1px solid #fafafa;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
color: @colorText;
background: @colorTextSecondary;
background-color: @colorTextTertiary;
border-color: @colorBgLayout;
border: 1px solid @colorBgLayout;
}
}
11 changes: 8 additions & 3 deletions packages/codemod/transforms/__tests__/less-to-token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ const tests = ['antd-v4-less-to-token', 'obui-less-to-token'];
describe(testUnit, () => {
tests.forEach(test => {
it(test, async () => {
const result = await transform(path.join(__dirname, `../__testfixtures__/less-to-token/${test}.input.less`))
const output = fs.readFileSync(path.join(__dirname, `../__testfixtures__/less-to-token/${test}.output.less`), 'utf-8');
const result = await transform(
path.join(__dirname, `../__testfixtures__/less-to-token/${test}.input.less`)
);
const output = fs.readFileSync(
path.join(__dirname, `../__testfixtures__/less-to-token/${test}.output.less`),
'utf-8'
);
expect(result).toEqual(output);
})
});
});
});
24 changes: 18 additions & 6 deletions packages/codemod/transforms/utils/token.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
const { toLower } = require('lodash');

const TOKEN_MAP = {
// antd fixed style => antd v5 token
'#f0f2f5': 'colorBgLayout',
'#fafafa': 'colorBgLayout',
'#fff': 'colorBgContainer',
'#ffffff': 'colorBgContainer',
// antd style => token
'#1677ff': 'colorInfo',
'#1890ff': 'colorInfo',
'#52c41a': 'colorSuccess',
'#73d13d': 'colorSuccess',
'#52c41a': 'colorSuccess',
'#faad14': 'colorWarning',
'#ff4d4f': 'colorError',
'#F5222D': 'colorError',
'#F8636B': 'colorError',
'#d9d9d9': 'colorBorder',
'#bfbfbf': 'colorBorder',
'#f0f2f5': 'colorBgLayout',
'#fafafa': 'colorBgLayout',
'#fff': 'colorBgContainer',
'#ffffff': 'colorBgContainer',
'rgba(0,0,0,0.85)': 'colorText',
'rgba(0,0,0,0.65)': 'colorTextSecondary',
'rgba(0,0,0,0.45)': 'colorTextTertiary',
'rgba(0,0,0,0.25)': 'colorTextQuaternary',
'rgba(0,0,0,0.2)': 'colorFillQuaternary',
'rgba(0,0,0,0.04)': 'colorBgLayout',
// obui style => token
'#006aff': 'colorInfo',
'#0ac185': 'colorSuccess',
'#ffac33': 'colorWarning',
'#ff4b4b': 'colorError',
'#CDD5E4': 'colorBorder',
'#F5F8FE': 'colorBgLayout',
'#132039': 'colorText',
'#364563': 'colorTextSecondary',
'#8592AD': 'colorTextTertiary',
'#F8FAFE': 'colorFillQuaternary',
};

function trimAll(str) {
Expand Down
59 changes: 28 additions & 31 deletions packages/ui/src/BasicLayout/style/Header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,78 +4,76 @@ import { genComponentStyleHook } from '../../_util/genComponentStyleHook';

export type HeaderToken = FullToken<any>;

export const genHeaderStyle: GenerateStyle<HeaderToken> = (
token: HeaderToken
): CSSObject => {
export const genHeaderStyle: GenerateStyle<HeaderToken> = (token: HeaderToken): CSSObject => {
const { antCls, componentCls } = token;

return {
[`${componentCls}`]: {
position: "fixed",
position: 'fixed',
zIndex: 10,
width: "100%",
width: '100%',
height: 48,
padding: "10px 24px",
padding: '10px 24px',
lineHeight: '48px',
backgroundColor: token.colorBgLayout,
boxShadow: `inset 0 -1px 0 0 ${token.colorBorderSecondary}`,

[`${componentCls}-content`]: {
display: "flex",
alignItems: "center",
justifyContent: "space-between",
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
maxWidth: token.maxWidth,
height: "100%",
margin: "0 auto",
height: '100%',
margin: '0 auto',
},

[`${componentCls}-logo`]: {
height: 24,
cursor: 'pointer'
cursor: 'pointer',
},
[`${componentCls}-icon`]: {
width: 52,
height: 48,
lineHeight: '48px',
textAlign: "center",
textAlign: 'center',
borderRight: `1px solid ${token.colorBorderSecondary}`,
borderBottom: `1px solid ${token.colorBorderSecondary}`,
cursor: "pointer",
cursor: 'pointer',
img: {
height: 32,
marginTop: 8
marginTop: 8,
},
},
[`${componentCls}-title`]: {
/* 占据剩余的全部空间 */
flex: 1,
margin: "0 16px",
margin: '0 16px',
},

[`${componentCls}-extra`]: {
display: "flex",
alignItems: "center",
justifyContent: "space-between",
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
[`${componentCls}-extra-item`]: {
display: "inline-flex",
display: 'inline-flex',
fontSize: 12,
cursor: "pointer",
cursor: 'pointer',
'&:not(:last-child)': {
marginRight: 24
marginRight: 24,
},
[`${componentCls}-extra-icon-wrapper`]: {
width: 28,
height: 28,
lineHeight: '28px',
textAlign: "center",
border: "0.88px solid #ced4e1",
textAlign: 'center',
border: '0.88px solid #ced4e1',
borderRadius: 14,
},
[`${componentCls}-extra-user-wrapper`]: {
height: 28,
padding: "0 10px",
padding: '0 10px',
lineHeight: '28px',
border: "0.88px solid #ced4e1",
border: '0.88px solid #ced4e1',
borderRadius: 14,
[`${componentCls}-extra-user-icon`]: {
marginRight: 6,
Expand All @@ -87,9 +85,9 @@ export const genHeaderStyle: GenerateStyle<HeaderToken> = (
[`${componentCls}-extra-with-label`]: {
[`${componentCls}-extra-item`]: {
'&:not(:last-child)': {
marginRight: '24px !important'
}
}
marginRight: '24px !important',
},
},
},
},

Expand All @@ -113,8 +111,7 @@ export const genHeaderStyle: GenerateStyle<HeaderToken> = (
fontSize: 12,
color: token.colorTextTertiary,
},
}

},
};
};

Expand Down
Loading
Loading