Skip to content

Commit

Permalink
redirect(drawer): redesign UI & Share widgets (#151)
Browse files Browse the repository at this point in the history
* chore: wip

* chore: wip

* chore: style adjust

* chore: wip

* chore: wip

* chore: article navi

* chore: style adjust

* chore: wip

* chore: wip

* chore: wip

* chore: rm Share container

* chore: wip

* chore: WithMargin wip

* chore: WithMargin wip

* chore: WithMargin wip

* chore: WithMargin wip

* chore: dynamic load modal
  • Loading branch information
mydearxym authored Oct 20, 2023
1 parent ddc0fa6 commit ab7282c
Show file tree
Hide file tree
Showing 103 changed files with 859 additions and 952 deletions.
2 changes: 1 addition & 1 deletion config/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"//--- general configs ---//": "",
"DEFAULT_THEME": "day",
"DEFAULT_THEME": "night",
"SENIOR_AMOUNT_THRESHOLD": 51.2,
"SPONSOR_AMOUNT_THRESHOLD": 3999,
"PAGE_SIZE": {
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"sanitize-html": "^2.5.2",
"scroll-into-view-if-needed": "1.5.0",
"sentry-testkit": "^2.1.0",
"sonner": "^0.6.2",
"sonner": "^1.0.0",
"store": "^2.0.12",
"stringz": "^2.0.0",
"styled-components": "^6.1.0",
Expand Down
14 changes: 5 additions & 9 deletions src/containers/content/ArticleContent/DesktopView/SideInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,18 @@ const SideInfo: FC<TProps> = ({ article }) => {

<Br bottom={25} />

<Label>类别</Label>
<ArticleCatState cat={ARTICLE_CAT.FEATURE} state={ARTICLE_STATE.WIP} smaller={false} />

<Br bottom={25} />

<Label>标签</Label>
<Value>
<TagsList items={articleTags} size="small" />
</Value>

<Br bottom={25} />

<Label>类别</Label>
<ArticleCatState cat={ARTICLE_CAT.FEATURE} state={ARTICLE_STATE.WIP} smaller={false} />

<Br bottom={25} />

<Label>状态</Label>
<Value>进行中</Value>

<Br bottom={20} />
<Label>发布时间</Label>
<Value>
<ReadableDate date={insertedAt} fmt="absolute" withTime={false} />
Expand Down
16 changes: 8 additions & 8 deletions src/containers/digest/ArticleDigest/DesktopView/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ type TProps = {
}

const Header: FC<TProps> = ({ metric }) => {
const community = useViewingCommunity()
const { slug, title, logo } = useViewingCommunity()

return (
<Wrapper id={ANCHOR.GLOBAL_HEADER_ID}>
<InnerWrapper>
<Community>
<CommunityLogo src={assetSrc(community.logo)} />
<CommunityTitle>{community.title}</CommunityTitle>
<CommunityLogo src={assetSrc(logo)} />
<CommunityTitle>{title}</CommunityTitle>
</Community>

<Main metric={metric}>
<LinkItem href={`/${community.slug}/${ROUTE.POST}`}>讨论区</LinkItem>
<LinkItem href={`/${community.slug}/${ROUTE.KANBAN}`}>看板</LinkItem>
<LinkItem href={`/${community.slug}/${ROUTE.CHANGELOG}`}>更新日志</LinkItem>
<LinkItem href={`/${community.slug}/${ROUTE.HELP}`}>帮助台</LinkItem>
<LinkItem href={`/${community.slug}/${ROUTE.ABOUT}`}>关于</LinkItem>
<LinkItem href={`/${slug}/${ROUTE.POST}`}>讨论区</LinkItem>
<LinkItem href={`/${slug}/${ROUTE.KANBAN}`}>看板</LinkItem>
<LinkItem href={`/${slug}/${ROUTE.CHANGELOG}`}>更新日志</LinkItem>
<LinkItem href={`/${slug}/${ROUTE.HELP}`}>帮助台</LinkItem>
<LinkItem href={`/${slug}/${ROUTE.ABOUT}`}>关于</LinkItem>
</Main>

<MobileNaviWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import styled from 'styled-components'
import type { TActive, TSpace } from '@/spec'
import css, { theme } from '@/css'

import { WithMargin } from '@/widgets/Common'

export const Wrapper = styled.div`
${css.column('align-center')};
color: ${theme('article.digest')};
Expand Down Expand Up @@ -58,7 +60,7 @@ export const Footer = styled.div`
`

type TNote = TActive & TSpace
export const Note = styled.div<TNote>`
export const Note = styled(WithMargin)<TNote>`
font-size: 12px;
color: ${({ $active }) => ($active ? theme('article.title') : theme('lightText'))};
font-weight: ${({ $active }) => ($active ? 500 : 400)};
Expand All @@ -70,8 +72,6 @@ export const Note = styled.div<TNote>`
}
transition: color 0.2s;
${(props) => css.spaceMargins(props)};
`
export const ShineNote = styled.div`
font-size: 12px;
Expand Down
8 changes: 8 additions & 0 deletions src/containers/layout/ThemePalette/GlobalStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,13 @@ const GlobalStyle = createGlobalStyle<TPrimaryColor>`
background: ${theme('toast.bg')} !important;
border-color: ${theme('toast.border')} !important;
}
[data-sonner-toast] [data-close-button] {
background: ${theme('hoverBg')} !important;
color: ${theme('hint')} !important;
border-color: ${theme('hint')} !important;
}
[data-sonner-toast][data-mounted=true] {
margin-top: -8px !important;
}
`
export default GlobalStyle
2 changes: 1 addition & 1 deletion src/containers/layout/ThemePalette/ScrollBarStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ const ScrollBarStyle = createGlobalStyle`
}
.os-theme-dark.os-scrollbar > .os-scrollbar-track > .os-scrollbar-handle {
background: rgba(0, 0, 0, 0.4);
background: rgb(148 148 148 / 55%);
}
.os-theme-light.os-scrollbar > .os-scrollbar-track > .os-scrollbar-handle {
Expand Down
6 changes: 2 additions & 4 deletions src/containers/thread/AboutThread/styles/label_list.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import styled from 'styled-components'

import type { TSpace } from '@/spec'

import css, { theme } from '@/css'
import { WithMargin } from '@/widgets/Common'

export const Wrapper = styled.div<TSpace>`
export const Wrapper = styled(WithMargin)`
${css.rowWrap('align-center')};
gap: 0 8px;
${(props) => css.spaceMargins(props)};
`
export const Label = styled.div`
border: 1px solid;
Expand Down
3 changes: 2 additions & 1 deletion src/containers/thread/ArticlesThread/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ import { T, markStates, getParent, Instance, toJS } from '@/mobx'
import { nilOrEmpty } from '@/validator'
import { plural } from '@/fmt'

import { PagedPosts, ArticlesFilter, emptyPagi } from '@/model'
import { PagedPosts, PagedChangelogs, ArticlesFilter, emptyPagi } from '@/model'

const ArticlesThread = T.model('ArticlesThread', {
mode: T.opt(T.enum(['default', 'modeline']), 'default'),
pagedPosts: T.opt(PagedPosts, emptyPagi),
pagedChangelogs: T.opt(PagedChangelogs, emptyPagi),
filters: T.opt(ArticlesFilter, {}),
resState: T.opt(T.enum('resState', values(TYPE.RES_STATE)), TYPE.RES_STATE.LOADING),
})
Expand Down
4 changes: 3 additions & 1 deletion src/containers/thread/ChangelogThread/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ const ChangelogThread = T.model('ChangelogThread', {
return mockChangelogTimeTags(15)
},
get pagedChangelogsData(): TPagedArticles {
return toJS(self.pagedChangelogs)
const root = getParent(self) as TRootStore

return toJS(root.articlesThread.pagedChangelogs)
},
}))
.actions((self) => ({
Expand Down
5 changes: 2 additions & 3 deletions src/containers/thread/DashboardThread/styles/saving_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import type { TSpace } from '@/spec'
import css, { theme } from '@/css'

import InfoSVG from '@/icons/Save'
import { WithMargin } from '@/widgets/Common'

type TWrapper = { direction: 'left' | 'right'; width: string } & TSpace
export const NormalWrapper = styled.div<TWrapper>`
export const NormalWrapper = styled(WithMargin)<TWrapper>`
${css.row('align-center')};
width: ${({ direction, width }) => (direction === 'right' ? `calc(${width} + 10px)` : width)};
background: ${(props) => {
Expand All @@ -19,8 +20,6 @@ export const NormalWrapper = styled.div<TWrapper>`
height: 42px;
padding: 0 10px;
border-radius: 10px;
${(props) => css.spaceMargins(props)};
`
export const MinimalWrapper = styled(NormalWrapper)`
height: 34px;
Expand Down
4 changes: 2 additions & 2 deletions src/containers/tool/ArticleSticker/LeftSticker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FC } from 'react'

import type { TArticle } from '@/spec'

import Share from '@/containers/tool/Share'
import Share from '@/widgets/Share'
import Upvote from '@/widgets/Upvote'

import { Wrapper, InnerWrapper, Divider } from '../styles/left_sticker'
Expand Down Expand Up @@ -33,7 +33,7 @@ const LeftSticker: FC<TProps> = ({ show, article, testid = 'article-sticker-left
onAction={handleUpvote}
/>
<Divider />
<Share size={17} right={3} />
<Share right={3} />
</InnerWrapper>
</Wrapper>
)
Expand Down
11 changes: 0 additions & 11 deletions src/containers/tool/Drawer/AddOn/CloseButton.tsx

This file was deleted.

46 changes: 0 additions & 46 deletions src/containers/tool/Drawer/AddOn/index.tsx

This file was deleted.

30 changes: 15 additions & 15 deletions ...tainers/tool/Drawer/AddOn/ArticleNavi.tsx → ...ainers/tool/Drawer/Viewer/ArticleNavi.tsx
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import type { TArticleNavi } from '../spec'

import {
Wrapper,
LeftSwitchBlock,
LeftArrow,
RightSwitchBlock,
RightArrow,
UpSwitchBlock,
UpArrow,
DownSwitchBlock,
DownArrow,
IndexWrapper,
LeftIndexWrapper,
RightIndexWrapper,
} from '../styles/add_on/article_navi'
UpIndexWrapper,
DownIndexWrapper,
} from '../styles/article_navi'

import { naviToArticle } from '../logic'

Expand All @@ -29,20 +29,20 @@ const ArticleNavi: FC<TProps> = ({ articleNavi }) => {
return (
<Wrapper>
{articleNavi?.previous && (
<LeftSwitchBlock onClick={() => naviToArticle(articleNavi.previous)}>
<LeftArrow />
<UpSwitchBlock onClick={() => naviToArticle(articleNavi.previous)}>
<UpArrow />
<IndexWrapper>
<LeftIndexWrapper>上一篇</LeftIndexWrapper>
<UpIndexWrapper>上一篇</UpIndexWrapper>
</IndexWrapper>
</LeftSwitchBlock>
</UpSwitchBlock>
)}
{articleNavi?.next && (
<RightSwitchBlock onClick={() => naviToArticle(articleNavi.next)}>
<RightArrow />
<DownSwitchBlock onClick={() => naviToArticle(articleNavi.next)}>
<DownArrow />
<IndexWrapper>
<RightIndexWrapper>下一篇</RightIndexWrapper>
<DownIndexWrapper>下一篇</DownIndexWrapper>
</IndexWrapper>
</RightSwitchBlock>
</DownSwitchBlock>
)}
</Wrapper>
)
Expand Down
22 changes: 16 additions & 6 deletions src/containers/tool/Drawer/Viewer/DesktopView.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Fragment, FC, ReactNode, memo } from 'react'
import { includes } from 'ramda'

import { ANCHOR } from '@/constant/dom'

import type { TSwipeOption, TArticleNavi } from '../spec'
import AddOn from '../AddOn'
import type { TArticleNavi, TSwipeOption } from '../spec'
import { ARTICLE_VIEWER_TYPES } from '../constant'

import { DrawerOverlay, DrawerWrapper, DrawerContent } from '../styles'
import ArticleNavi from './ArticleNavi'
import { DrawerOverlay, DrawerWrapper, DrawerContent, NaviArea } from '../styles'
import { closeDrawer } from '../logic'

type TProps = {
Expand All @@ -15,8 +17,8 @@ type TProps = {
rightOffset: string
fromContentEdge: boolean
type: string
articleNavi?: TArticleNavi
children: ReactNode
articleNavi: TArticleNavi
}

const DesktopView: FC<TProps> = ({
Expand All @@ -29,6 +31,8 @@ const DesktopView: FC<TProps> = ({
articleNavi,
children,
}) => {
const isArticleViewer = includes(type, ARTICLE_VIEWER_TYPES)

return (
<Fragment>
<DrawerOverlay
Expand All @@ -45,8 +49,14 @@ const DesktopView: FC<TProps> = ({
mobile={false}
options={options}
>
<AddOn type={type} articleNavi={articleNavi} />
<DrawerContent type={type}>{children}</DrawerContent>
<DrawerContent type={type}>
{isArticleViewer && (
<NaviArea>
<ArticleNavi articleNavi={articleNavi} />
</NaviArea>
)}
{children}
</DrawerContent>
</DrawerWrapper>
</Fragment>
)
Expand Down
Loading

0 comments on commit ab7282c

Please sign in to comment.