mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
toggleVisibility on mount instead event
This commit is contained in:
parent
c460f95775
commit
dbcb39357c
@ -23,13 +23,9 @@ export default class Header extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount = async () => {
|
componentDidMount = async () => {
|
||||||
// wait to app finish of load
|
setTimeout(() => {
|
||||||
app.eventBus.on(`app.initialization.finish`, () => {
|
this.controller.toggleVisibility(true)
|
||||||
// create an fade in animation
|
}, 100)
|
||||||
setTimeout(() => {
|
|
||||||
this.controller.toggleVisibility(true)
|
|
||||||
}, 400)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import classnames from "classnames"
|
import classnames from "classnames"
|
||||||
import * as antd from "antd"
|
import * as antd from "antd"
|
||||||
|
import progressBar from "nprogress"
|
||||||
|
|
||||||
import Sidebar from "./sidebar"
|
import Sidebar from "./sidebar"
|
||||||
import Header from "./header"
|
import Header from "./header"
|
||||||
@ -14,7 +15,7 @@ const LayoutRenders = {
|
|||||||
<antd.Layout className="content_layout">
|
<antd.Layout className="content_layout">
|
||||||
<antd.Layout.Content className={classnames("layout_page", ...props.layoutPageModesClassnames ?? [])}>
|
<antd.Layout.Content className={classnames("layout_page", ...props.layoutPageModesClassnames ?? [])}>
|
||||||
<div className={classnames("fade-transverse-active", { "fade-transverse-leave": props.isOnTransition })}>
|
<div className={classnames("fade-transverse-active", { "fade-transverse-leave": props.isOnTransition })}>
|
||||||
{props.children}
|
{React.cloneElement(props.children, props)}
|
||||||
</div>
|
</div>
|
||||||
</antd.Layout.Content>
|
</antd.Layout.Content>
|
||||||
</antd.Layout>
|
</antd.Layout>
|
||||||
@ -31,7 +32,7 @@ const LayoutRenders = {
|
|||||||
<Header />
|
<Header />
|
||||||
<antd.Layout.Content className={classnames("layout_page", ...props.layoutPageModesClassnames ?? [])}>
|
<antd.Layout.Content className={classnames("layout_page", ...props.layoutPageModesClassnames ?? [])}>
|
||||||
<div className={classnames("fade-transverse-active", { "fade-transverse-leave": props.isOnTransition })}>
|
<div className={classnames("fade-transverse-active", { "fade-transverse-leave": props.isOnTransition })}>
|
||||||
{props.children}
|
{React.cloneElement(props.children, props)}
|
||||||
</div>
|
</div>
|
||||||
</antd.Layout.Content>
|
</antd.Layout.Content>
|
||||||
</antd.Layout>
|
</antd.Layout>
|
||||||
@ -40,10 +41,14 @@ const LayoutRenders = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class Layout extends React.Component {
|
export default class Layout extends React.Component {
|
||||||
|
progressBar = progressBar.configure({ parent: "html", showSpinner: false })
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
layoutType: "default",
|
layoutType: "default",
|
||||||
isOnTransition: false,
|
isOnTransition: false,
|
||||||
compactMode: false,
|
compactMode: false,
|
||||||
|
renderLock: true,
|
||||||
|
renderError: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
setLayout = (layout) => {
|
setLayout = (layout) => {
|
||||||
@ -57,12 +62,17 @@ export default class Layout extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
window.app.eventBus.on("transitionStart", () => {
|
window.app.eventBus.on("app.initialization.start", () => {
|
||||||
this.setState({ isOnTransition: true })
|
this.setState({
|
||||||
|
renderLock: true,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
window.app.eventBus.on("transitionDone", () => {
|
window.app.eventBus.on("app.initialization.finish", () => {
|
||||||
this.setState({ isOnTransition: false })
|
this.setState({
|
||||||
|
renderLock: false,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
window.app.eventBus.on("toogleCompactMode", (to) => {
|
window.app.eventBus.on("toogleCompactMode", (to) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
compactMode: to ?? !this.state.compactMode,
|
compactMode: to ?? !this.state.compactMode,
|
||||||
@ -87,13 +97,48 @@ export default class Layout extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onTransitionStart = () => {
|
||||||
|
progressBar.start()
|
||||||
|
|
||||||
|
this.setState({ isOnTransition: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
onTransitionFinish = () => {
|
||||||
|
progressBar.done()
|
||||||
|
|
||||||
|
this.setState({ isOnTransition: false })
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidCatch(info, stack) {
|
||||||
|
this.setState({ renderError: { info, stack } })
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
if (this.state.renderLock) {
|
||||||
|
if (this.props.staticRenders?.Initialization) {
|
||||||
|
return React.createElement(this.props.staticRenders.Initialization)
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state.renderError) {
|
||||||
|
if (this.props.staticRenders?.RenderError) {
|
||||||
|
return React.createElement(this.props.staticRenders?.RenderError, { error: this.state.renderError })
|
||||||
|
}
|
||||||
|
|
||||||
|
return JSON.stringify(this.state.renderError)
|
||||||
|
}
|
||||||
|
|
||||||
const layoutComponentProps = {
|
const layoutComponentProps = {
|
||||||
...this.props,
|
...this.props.bindProps,
|
||||||
...this.state,
|
...this.state,
|
||||||
|
children: this.props.children,
|
||||||
layoutPageModesClassnames: [{
|
layoutPageModesClassnames: [{
|
||||||
["noMargin"]: this.state.compactMode,
|
["noMargin"]: this.state.compactMode,
|
||||||
}]
|
}],
|
||||||
|
onTransitionStart: this.onTransitionStart,
|
||||||
|
onTransitionFinish: this.onTransitionFinish,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LayoutRenders[this.state.layoutType]) {
|
if (LayoutRenders[this.state.layoutType]) {
|
||||||
|
@ -66,13 +66,9 @@ export default class Sidebar extends React.Component {
|
|||||||
componentDidMount = async () => {
|
componentDidMount = async () => {
|
||||||
await this.loadSidebarItems()
|
await this.loadSidebarItems()
|
||||||
|
|
||||||
// wait to app finish of load
|
setTimeout(() => {
|
||||||
app.eventBus.on(`app.initialization.finish`, () => {
|
this.controller.toggleVisibility(true)
|
||||||
// create an fade in animation
|
}, 100)
|
||||||
setTimeout(() => {
|
|
||||||
this.controller.toggleVisibility(true)
|
|
||||||
}, 400)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getStoragedKeys = () => {
|
getStoragedKeys = () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user