added panels to home

This commit is contained in:
srgooglo 2022-09-08 18:41:04 +02:00
parent 44db4fc2c7
commit aaf5454b3a
2 changed files with 122 additions and 21 deletions

View File

@ -1,15 +1,110 @@
import React from "react" import React from "react"
import { PostCreator, PostsFeed } from "components" import * as antd from "antd"
import classnames from "classnames"
import { Icons, createIconRender } from "components/Icons"
import { PostCreator, PostsFeed, LivestreamsBrowser } from "components"
import "./index.less" import "./index.less"
export default class PostsExplorer extends React.Component { const Tabs = {
render() { "feed": {
return <div className="explore"> title: "Feed",
<div className="header"> icon: "Rss",
component: (props) => {
return <>
<PostCreator /> <PostCreator />
<PostsFeed />
</>
}
},
"livestrems": {
title: "Livestrems",
icon: "Tv",
component: (props) => {
return <>
<LivestreamsBrowser />
</>
}
},
}
export default class Dashboard extends React.Component {
state = {
activeTab: "feed"
}
primaryPanelRef = React.createRef()
componentDidMount() {
app.eventBus.emit("style.compactMode", false)
}
renderActiveTab() {
const tab = Tabs[this.state.activeTab]
if (!tab) {
return null
}
return React.createElement(tab.component)
}
handleTabChange = (key) => {
if (this.state.activeTab === key) return
// set to primary panel fade-opacity-leave class
this.primaryPanelRef.current.classList.add("fade-opacity-leave")
setTimeout(() => {
this.setState({ activeTab: key })
}, 200)
// remove fade-opacity-leave class after animation
setTimeout(() => {
this.primaryPanelRef.current.classList.remove("fade-opacity-leave")
}, 300)
}
render() {
return <div className="dashboard">
<div></div>
<div
ref={this.primaryPanelRef}
className={classnames("panel", "fade-opacity-active")}
style={{ width: "102%" }}
>
{this.renderActiveTab()}
</div>
<div className="panel">
<div className="card">
<div>
<h2><Icons.Compass /> Browse</h2>
<antd.Menu
mode="inline"
selectedKeys={[this.state.activeTab]}
activeKey={this.state.activeTab}
onClick={({ key }) => this.handleTabChange(key)}
>
{Object.keys(Tabs).map((key) => {
const tab = Tabs[key]
return <antd.Menu.Item
key={key}
icon={createIconRender(tab.icon)}
>
{tab.title}
</antd.Menu.Item>
})}
</antd.Menu>
</div>
</div>
</div> </div>
<PostsFeed />
</div> </div>
} }
} }

View File

@ -1,22 +1,28 @@
.explore { .dashboard {
display : flex; display: grid;
flex-direction : column; grid-template-columns: repeat(3, 1fr);
align-items : center; grid-template-rows: 1fr;
justify-content: center; grid-column-gap: 20px;
grid-row-gap: 0px;
width: 100%; width: 100%;
.header { .panel {
display : flex; display: flex;
flex-direction : column; flex-direction: column;
align-items : center;
justify-content: center;
width : 100%; align-items: center;
max-width: 40vw;
}
>div { >div {
margin-bottom: 15px; margin-bottom: 15px;
}
.card {
background-color: var(--background-color-accent);
border-radius: 12px;
padding: 20px;
min-width: 20vw;
}
} }
} }