App, Routes and Sidebar components are migrated to functional ones
This commit is contained in:
parent
24ea00d9ec
commit
18997a0d3e
|
@ -1,4 +1,4 @@
|
||||||
import React, { Component } from 'react'
|
import React from 'react'
|
||||||
import { createGlobalStyle } from 'styled-components'
|
import { createGlobalStyle } from 'styled-components'
|
||||||
import { Helmet } from 'react-helmet'
|
import { Helmet } from 'react-helmet'
|
||||||
import Routes from './components/routes/Routes'
|
import Routes from './components/routes/Routes'
|
||||||
|
@ -23,8 +23,7 @@ const GlobalStyle = createGlobalStyle`
|
||||||
|
|
||||||
import 'semantic-ui-css/semantic.min.css'
|
import 'semantic-ui-css/semantic.min.css'
|
||||||
|
|
||||||
class App extends Component {
|
const App = () => {
|
||||||
render() {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Helmet>
|
<Helmet>
|
||||||
|
@ -39,6 +38,5 @@ class App extends Component {
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export default App
|
export default App
|
||||||
|
|
|
@ -24,8 +24,7 @@ const SettingsPage = React.lazy(() =>
|
||||||
import('../../Pages/SettingsPage/SettingsPage')
|
import('../../Pages/SettingsPage/SettingsPage')
|
||||||
)
|
)
|
||||||
|
|
||||||
class Routes extends React.Component {
|
const Routes = () => {
|
||||||
render() {
|
|
||||||
return (
|
return (
|
||||||
<React.Suspense
|
<React.Suspense
|
||||||
fallback={
|
fallback={
|
||||||
|
@ -55,6 +54,5 @@ class Routes extends React.Component {
|
||||||
</React.Suspense>
|
</React.Suspense>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export default Routes
|
export default Routes
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { createContext } from 'react'
|
import React, { createContext, useState } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import { Icon } from 'semantic-ui-react'
|
import { Icon } from 'semantic-ui-react'
|
||||||
|
@ -41,25 +41,20 @@ const SidebarDismissButton = styled(Icon)`
|
||||||
export const SidebarContext = createContext()
|
export const SidebarContext = createContext()
|
||||||
SidebarContext.displayName = 'SidebarContext'
|
SidebarContext.displayName = 'SidebarContext'
|
||||||
|
|
||||||
class Sidebar extends React.Component {
|
const Sidebar = ({ children }) => {
|
||||||
constructor(props) {
|
const [state, setState] = useState({
|
||||||
super(props)
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
content: null,
|
content: null,
|
||||||
|
})
|
||||||
|
|
||||||
|
const update = content => {
|
||||||
|
setState({ content })
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update = content => {
|
|
||||||
this.setState({ content })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
return (
|
||||||
<SidebarContext.Provider
|
<SidebarContext.Provider
|
||||||
value={{ updateSidebar: this.update, content: this.state.content }}
|
value={{ updateSidebar: update, content: state.content }}
|
||||||
>
|
>
|
||||||
{this.props.children}
|
{children}
|
||||||
<SidebarContext.Consumer>
|
<SidebarContext.Consumer>
|
||||||
{value => (
|
{value => (
|
||||||
<SidebarContainer highlighted={value.content != null}>
|
<SidebarContainer highlighted={value.content != null}>
|
||||||
|
@ -68,7 +63,7 @@ class Sidebar extends React.Component {
|
||||||
name="angle double right"
|
name="angle double right"
|
||||||
size="big"
|
size="big"
|
||||||
link
|
link
|
||||||
onClick={() => this.setState({ content: null })}
|
onClick={() => setState({ content: null })}
|
||||||
/>
|
/>
|
||||||
<div style={{ height: 100 }}></div>
|
<div style={{ height: 100 }}></div>
|
||||||
</SidebarContainer>
|
</SidebarContainer>
|
||||||
|
@ -77,7 +72,6 @@ class Sidebar extends React.Component {
|
||||||
</SidebarContext.Provider>
|
</SidebarContext.Provider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Sidebar.propTypes = {
|
Sidebar.propTypes = {
|
||||||
children: PropTypes.element,
|
children: PropTypes.element,
|
||||||
|
|
Loading…
Reference in New Issue