mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
split hooks
This commit is contained in:
parent
1819edb154
commit
17850b8b40
@ -2,32 +2,11 @@ import React from "react"
|
||||
import classnames from "classnames"
|
||||
import { Motion, spring } from "react-motion"
|
||||
|
||||
import useLayoutInterface from "hooks/useLayoutInterface"
|
||||
import useDefaultVisibility from "hooks/useDefaultVisibility"
|
||||
|
||||
import "./index.less"
|
||||
|
||||
const useLayoutInterface = (namespace, ctx) => {
|
||||
React.useEffect(() => {
|
||||
if (app.layout["namespace"] === "object") {
|
||||
throw new Error(`Layout namespace [${namespace}] already exists`)
|
||||
}
|
||||
|
||||
app.layout[namespace] = ctx
|
||||
}, [])
|
||||
|
||||
return app.layout[namespace]
|
||||
}
|
||||
|
||||
const useDefaultVisibility = (defaultValue) => {
|
||||
const [visible, setVisible] = React.useState(defaultValue ?? false)
|
||||
|
||||
React.useEffect(() => {
|
||||
setTimeout(() => {
|
||||
setVisible(true)
|
||||
}, 10)
|
||||
}, [])
|
||||
|
||||
return [visible, setVisible]
|
||||
}
|
||||
|
||||
export const UseTopBar = (props) => {
|
||||
app.layout.top_bar.render(
|
||||
<React.Fragment>
|
||||
@ -124,8 +103,6 @@ export default (props) => {
|
||||
|
||||
const heightValue = visible ? Number(app.cores.style.defaultVar("top-bar-height").replace("px", "")) : 0
|
||||
|
||||
console.log(render)
|
||||
|
||||
return <Motion style={{
|
||||
y: spring(visible ? 0 : 300,),
|
||||
height: spring(heightValue,),
|
||||
|
@ -8,9 +8,6 @@
|
||||
width: 100%;
|
||||
height: calc(@top_bar_height + @top_bar_padding * 2);
|
||||
min-height: calc(@top_bar_height + @top_bar_padding * 2);
|
||||
|
||||
//height: 0;
|
||||
//min-height: 0;
|
||||
}
|
||||
|
||||
.top-bar_wrapper {
|
||||
@ -44,7 +41,7 @@
|
||||
|
||||
padding: 10px;
|
||||
|
||||
box-shadow: @card-shadow-top;
|
||||
box-shadow: @card-shadow;
|
||||
|
||||
transition: all 150ms ease-in-out;
|
||||
|
||||
|
13
packages/app/src/hooks/useDefaultVisibility/index.js
Normal file
13
packages/app/src/hooks/useDefaultVisibility/index.js
Normal file
@ -0,0 +1,13 @@
|
||||
import React from "react"
|
||||
|
||||
export default (defaultValue) => {
|
||||
const [visible, setVisible] = React.useState(defaultValue ?? false)
|
||||
|
||||
React.useEffect(() => {
|
||||
setTimeout(() => {
|
||||
setVisible(true)
|
||||
}, 10)
|
||||
}, [])
|
||||
|
||||
return [visible, setVisible]
|
||||
}
|
13
packages/app/src/hooks/useLayoutInterface/index.js
Normal file
13
packages/app/src/hooks/useLayoutInterface/index.js
Normal file
@ -0,0 +1,13 @@
|
||||
import React from "react"
|
||||
|
||||
export default (namespace, ctx) => {
|
||||
React.useEffect(() => {
|
||||
if (app.layout["namespace"] === "object") {
|
||||
throw new Error(`Layout namespace [${namespace}] already exists`)
|
||||
}
|
||||
|
||||
app.layout[namespace] = ctx
|
||||
}, [])
|
||||
|
||||
return app.layout[namespace]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user