Skip to content

Commit 73a514a

Browse files
robinv8mhpei
andauthored
Feature docs color (#1796)
* feat: 添加支持暗夜模式 * feat: 添加支持暗夜模式 * chore: 更新依赖包版本 * chore: 更新react-router-dom依赖版本至5.3.4 * fix: 修复 pathname 不存在的问题 --------- Co-authored-by: mhpei <[email protected]>
1 parent 0730714 commit 73a514a

File tree

4 files changed

+281
-59
lines changed

4 files changed

+281
-59
lines changed

packages/taro-ui-docs/app.jsx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { createRoot } from 'react-dom/client'
3-
import { HashRouter as Router, Switch, Route } from 'react-router-dom'
3+
import { HashRouter as Router, Route, Switch } from 'react-router-dom'
44

55
import 'at-ui-style'
66

@@ -13,14 +13,14 @@ class App extends React.Component {
1313
super(...args)
1414
this.state = {
1515
visible: false,
16-
mode: 'light',
16+
mode: 'light'
1717
}
1818
}
1919
componentDidMount() {
2020
const _mode = localStorage.getItem('mode')
2121
this.setState({
2222
visible: true,
23-
mode: _mode || 'light',
23+
mode: _mode || 'light'
2424
})
2525
}
2626

@@ -31,29 +31,40 @@ class App extends React.Component {
3131
handleMode() {
3232
const _mode = this.state.mode
3333
const modeVal = _mode === 'light' ? 'dark' : 'light'
34-
this.setState({
35-
mode: modeVal
36-
}, () => {
37-
localStorage.setItem('mode', modeVal)
38-
})
34+
this.setState(
35+
{
36+
mode: modeVal
37+
},
38+
() => {
39+
localStorage.setItem('mode', modeVal)
40+
}
41+
)
3942
}
4043

4144
render() {
4245
const { mode } = this.state
4346

4447
return (
45-
<div className='wrapper' style={{ backgroundColor: mode === 'light' ? '#F8FAFF' : '#434242' }}>
48+
<div
49+
className='wrapper'
50+
style={{ backgroundColor: mode === 'light' ? '#F8FAFF' : '#434242' }}
51+
>
4652
<Switch>
4753
<Route path='/' exact component={Index} />
48-
<Route path='/docs' render={() => <Docs handleMode={this.handleMode.bind(this)} />} />
54+
<Route
55+
path='/docs'
56+
render={props => (
57+
<Docs {...props} handleMode={this.handleMode.bind(this)} />
58+
)}
59+
/>
4960
<Route path='/guide' component={Guide} />
5061
</Switch>
5162
</div>
5263
)
5364
}
5465
}
55-
const container = document.getElementById('container');
56-
const root = createRoot(container);
66+
const container = document.getElementById('container')
67+
const root = createRoot(container)
5768
root.render(
5869
<Router>
5970
<App />

packages/taro-ui-docs/assets/style/docs.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ $drop-shadow: 0 4px 30px 0 rgba(223, 225, 230, 0.5);
5656

5757
.darkbox {
5858
background-color: #23272f;
59+
&.at-container {
60+
box-shadow: none;
61+
}
5962
}
6063

6164
/**

packages/taro-ui-docs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@
2828
"copy-to-clipboard": "^3.3.1",
2929
"highlight.js": "^10.7.2",
3030
"qrcode.react": "^1.0.0",
31-
"react-router-dom": "^5.1.2",
31+
"react-router-dom": "^5.3.4",
3232
"regenerator-runtime": "^0.13.5",
3333
"taro-ui-demo": "workspace:^"
3434
},
3535
"devDependencies": {
3636
"@types/classnames": "^2.2.10",
37+
"@types/react-router-dom": "5.1.5",
3738
"@types/webpack-env": "^1.15.1",
3839
"babel-loader": "^8.1.0",
3940
"chalk": "^4.0.0",

0 commit comments

Comments
 (0)