Skip to content

Commit e0473ea

Browse files
authored
Merge pull request #133 from qqxs/develop
feat: update theme docs
2 parents e9a08aa + 30b0efc commit e0473ea

4 files changed

Lines changed: 12 additions & 52 deletions

File tree

README.md

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ If it is necessary to modify the [antd5 theme](https://ant.design/docs/react/cus
109109
// default.scss
110110
:root {
111111
--color-primary: #00b96b; // -> colorPrimary: #00b96b
112-
--border-radius: 4px; // -> borderRadius: 4px
112+
--border-radius: 4px; // -> borderRadius: 4
113113
}
114114
```
115115

@@ -121,11 +121,11 @@ If it is necessary to modify the [antd5 theme](https://ant.design/docs/react/cus
121121
"tokens": {
122122
"dark": {
123123
"colorPrimary": "#000",
124-
"borderRadius": "4px",
124+
"borderRadius": "4",
125125
},
126126
"default": {
127127
"colorPrimary": "#00b96b",
128-
"borderRadius": "4px"
128+
"borderRadius": "4"
129129
}
130130
},
131131
"vars": {
@@ -150,51 +150,6 @@ css 变量在切换主题时自动注入到 `head` 下,保证 [antd@5.x](https
150150
</style>
151151
```
152152

153-
警告⚠️: 主题文夹下文件中仅支持 css 变量
154-
155-
<!-- 如果使用`less`, 请安装 [less-vars-to-js](https://www.npmjs.com/package/less-vars-to-js) 按照下面 👇 代码自行调试。
156-
157-
If using `less`, please install [less-vars-to-js](https://www.npmjs.com/package/less-vars-to-js) According to the following 👇 Code self debugging.
158-
159-
````ts
160-
import lessToJs from 'less-vars-to-js';
161-
import { lowerCamel } from '@skax/camel';
162-
import fs from 'fs';
163-
164-
/**
165-
* less 变量转成 json 格式 (更改 antd 主题样式更新需要重启)
166-
* Convert the less variable to JSON format
167-
*
168-
* @example
169-
*
170-
* ```less
171-
* $color-primary: #00b96b;
172-
* $border-radius: 2px;
173-
* ```
174-
*
175-
* ```js
176-
* lessVar2JSON() // -> {"colorPrimary": "#00b96b", "borderRadius": "2px"}
177-
* ```
178-
*
179-
* @returns {Object}
180-
*/
181-
function lessVar2JSON() {
182-
// Read the less file in as string
183-
const paletteLess = fs.readFileSync('./src/styles/antd-theme.less', 'utf-8');
184-
// Pass in file contents
185-
const palette = lessToJs(paletteLess, {
186-
resolveVariables: true,
187-
stripPrefix: true,
188-
});
189-
190-
return Object.keys(palette).reduce((pre, cur) => {
191-
pre[lowerCamel(cur, '-')] = palette[cur];
192-
return pre;
193-
}, {});
194-
}
195-
export default lessVar2JSON;
196-
```` -->
197-
198153
## Api
199154

200155
[gin_serve api](https://github.com/freeshineit/gin_serve)

scripts/sass-to-json.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import { lowerCamel } from '@skax/camel';
1414
* ```scss
1515
* // -> colorPrimary: #000
1616
* --color-primary: #000;
17-
* // -> borderRadius: 4px
17+
* // -> borderRadius: 4
1818
* --border-radius: 4px;
1919
* ```
2020
*
2121
* ```ts
22-
* sassVar2JSON() // -> {"colorPrimary": "#00b96b, borderRadius: '2px'}
22+
* sassVar2JSON() // -> {"colorPrimary": "#00b96b", borderRadius: 4}
2323
* ```
2424
*
2525
* @returns {Object}

src/pages/home/home.module.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
}
2525
}
2626

27+
.logoWrapper {
28+
a {
29+
display: inline-block;
30+
}
31+
}
32+
2733
.logo {
2834
height: 6em;
2935
padding: 1.5em;

src/pages/home/home.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ const Home = () => {
1717

1818
return (
1919
<div className={styles.home}>
20-
<div>
20+
<div className={styles.logoWrapper}>
2121
<Popover
2222
content="This project is built with Vite + React + TypeScript + Redux"
2323
placement="top"
24-
open={true}
2524
>
2625
<a href="https://vitejs.dev" target="_blank" rel="noreferrer">
2726
<img src="/vite.svg" className={styles.logo} alt="Vite logo" />

0 commit comments

Comments
 (0)