added mobile style & layout

This commit is contained in:
SrGooglo 2023-06-27 00:11:36 +00:00
parent 616a2da2c5
commit 16876811a5
5 changed files with 183 additions and 19 deletions

View File

@ -1,3 +1,14 @@
#root {
&.mobile {
.userCard {
width: 100%;
filter: none;
box-shadow: none;
min-width: 0;
}
}
}
.userCard { .userCard {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View File

@ -0,0 +1,8 @@
import React from "react"
import Account from "./index.mobile"
export default (props) => {
const username = props.params.username
return <Account username={username} />
}

View File

@ -0,0 +1,154 @@
import React from "react"
import * as antd from "antd"
import classnames from "classnames"
import { Translation } from "react-i18next"
import { createIconRender, Icons } from "components/Icons"
import { Skeleton, FollowButton, UserCard } from "components"
import { SessionModel, UserModel, FollowsModel } from "models"
import { PagePanelWithNavMenu } from "components/PagePanels"
import DetailsTab from "./tabs/details"
import PostsTab from "./tabs/posts"
import FollowersTab from "./tabs/followers"
import "./index.mobile.less"
const Tabs = [
{
key: "posts",
icon: "BookOpen",
label: <Translation>
{t => t("Posts")}
</Translation>,
component: PostsTab,
},
{
key: "followers",
icon: "Users",
label: <Translation>
{t => t("Followers")}
</Translation>,
component: FollowersTab,
},
{
key: "details",
icon: "Info",
label: <Translation>
{t => t("Details")}
</Translation>,
component: DetailsTab,
}
]
export default class Account extends React.Component {
state = {
requestedUser: null,
user: null,
followers: [],
isSelf: false,
isFollowed: false,
tabActiveKey: "posts",
isNotExistent: false,
}
componentDidMount = async () => {
const token = await SessionModel.getDecodedToken()
const location = window.app.history.location
const query = new URLSearchParams(location.search)
const requestedUser = this.props.username ?? location.state?.username ?? query.get("username") ?? token?.username
let isSelf = false
let user = null
let isFollowed = false
let followers = []
if (requestedUser != null) {
if (token.username === requestedUser) {
isSelf = true
}
user = await UserModel.data({
username: requestedUser
}).catch((error) => {
console.error(error)
return false
})
if (!user) {
this.setState({
isNotExistent: true,
})
return false
}
console.log(`Loaded User [${user.username}] >`, user)
if (!isSelf) {
const followedResult = await FollowsModel.imFollowing(user._id).catch(() => false)
if (followedResult) {
isFollowed = followedResult.isFollowed
}
}
const followersResult = await FollowsModel.getFollowers(user._id).catch(() => false)
if (followersResult) {
followers = followersResult
}
}
await this.setState({
isSelf,
user,
requestedUser,
isFollowed,
followers,
})
}
render() {
const { user } = this.state
if (this.state.isNotExistent) {
return <antd.Result
status="404"
title="This user does not exist, yet..."
>
</antd.Result>
}
if (!user) {
return <Skeleton />
}
return <div
className={classnames(
"_mobile_account-profile",
)}
>
<UserCard
user={user}
/>
{/* <PagePanelWithNavMenu
tabs={Tabs}
useSetQueryType
transition
tabProps={{
state: this.state,
}}
/> */}
</div>
}
}

View File

@ -0,0 +1,10 @@
._mobile_account-profile {
display: flex;
flex-direction: column;
padding: 0 10px;
width: 100%;
}

View File

@ -1,32 +1,13 @@
import React from "react" import React from "react"
import * as antd from "antd"
import { Translation } from "react-i18next"
import { PagePanelWithNavMenu } from "components/PagePanels" import { PagePanelWithNavMenu } from "components/PagePanels"
import { Icons } from "components/Icons"
import Tabs from "./home/tabs" import Tabs from "./home/tabs"
export default class Home extends React.Component { export default class Home extends React.Component {
render() { render() {
const navMenuHeader = <>
<h1>
<Icons.Home />
<Translation>{(t) => t("Timeline")}</Translation>
</h1>
<antd.Button
type="primary"
onClick={app.controls.openPostCreator}
>
<Icons.PlusCircle />
<Translation>{(t) => t("Create")}</Translation>
</antd.Button>
</>
return <PagePanelWithNavMenu return <PagePanelWithNavMenu
tabs={Tabs} tabs={Tabs}
navMenuHeader={navMenuHeader}
primaryPanelClassName="full" primaryPanelClassName="full"
useSetQueryType useSetQueryType
transition transition