Skip to content

Commit

Permalink
Feature docs color (#1796)
Browse files Browse the repository at this point in the history
* feat: 添加支持暗夜模式

* feat: 添加支持暗夜模式

* chore: 更新依赖包版本

* chore: 更新react-router-dom依赖版本至5.3.4

* fix: 修复 pathname 不存在的问题

---------

Co-authored-by: mhpei <[email protected]>
  • Loading branch information
robinv8 and mhpei authored May 19, 2024
1 parent 0730714 commit 73a514a
Show file tree
Hide file tree
Showing 4 changed files with 281 additions and 59 deletions.
35 changes: 23 additions & 12 deletions packages/taro-ui-docs/app.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { createRoot } from 'react-dom/client'
import { HashRouter as Router, Switch, Route } from 'react-router-dom'
import { HashRouter as Router, Route, Switch } from 'react-router-dom'

import 'at-ui-style'

Expand All @@ -13,14 +13,14 @@ class App extends React.Component {
super(...args)
this.state = {
visible: false,
mode: 'light',
mode: 'light'
}
}
componentDidMount() {
const _mode = localStorage.getItem('mode')
this.setState({
visible: true,
mode: _mode || 'light',
mode: _mode || 'light'
})
}

Expand All @@ -31,29 +31,40 @@ class App extends React.Component {
handleMode() {
const _mode = this.state.mode
const modeVal = _mode === 'light' ? 'dark' : 'light'
this.setState({
mode: modeVal
}, () => {
localStorage.setItem('mode', modeVal)
})
this.setState(
{
mode: modeVal
},
() => {
localStorage.setItem('mode', modeVal)
}
)
}

render() {
const { mode } = this.state

return (
<div className='wrapper' style={{ backgroundColor: mode === 'light' ? '#F8FAFF' : '#434242' }}>
<div
className='wrapper'
style={{ backgroundColor: mode === 'light' ? '#F8FAFF' : '#434242' }}
>
<Switch>
<Route path='/' exact component={Index} />
<Route path='/docs' render={() => <Docs handleMode={this.handleMode.bind(this)} />} />
<Route
path='/docs'
render={props => (
<Docs {...props} handleMode={this.handleMode.bind(this)} />
)}
/>
<Route path='/guide' component={Guide} />
</Switch>
</div>
)
}
}
const container = document.getElementById('container');
const root = createRoot(container);
const container = document.getElementById('container')
const root = createRoot(container)
root.render(
<Router>
<App />
Expand Down
3 changes: 3 additions & 0 deletions packages/taro-ui-docs/assets/style/docs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ $drop-shadow: 0 4px 30px 0 rgba(223, 225, 230, 0.5);

.darkbox {
background-color: #23272f;
&.at-container {
box-shadow: none;
}
}

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/taro-ui-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
"copy-to-clipboard": "^3.3.1",
"highlight.js": "^10.7.2",
"qrcode.react": "^1.0.0",
"react-router-dom": "^5.1.2",
"react-router-dom": "^5.3.4",
"regenerator-runtime": "^0.13.5",
"taro-ui-demo": "workspace:^"
},
"devDependencies": {
"@types/classnames": "^2.2.10",
"@types/react-router-dom": "5.1.5",
"@types/webpack-env": "^1.15.1",
"babel-loader": "^8.1.0",
"chalk": "^4.0.0",
Expand Down
Loading

0 comments on commit 73a514a

Please sign in to comment.