Add community/public switch view in feed (#351)
This commit is contained in:
parent
a2b449502a
commit
02ee22fc99
|
@ -295,6 +295,7 @@
|
||||||
"PublicationsWithCount": "{count, plural, =0 {no publications} one {{count} publication} other {{count} publications}}",
|
"PublicationsWithCount": "{count, plural, =0 {no publications} one {{count} publication} other {{count} publications}}",
|
||||||
"Publish Album": "Publish Album",
|
"Publish Album": "Publish Album",
|
||||||
"Publish Settings": "Publish Settings",
|
"Publish Settings": "Publish Settings",
|
||||||
|
"Published": "Published",
|
||||||
"Punchline": "Punchline",
|
"Punchline": "Punchline",
|
||||||
"Quit": "Quit",
|
"Quit": "Quit",
|
||||||
"Quote": "Quote",
|
"Quote": "Quote",
|
||||||
|
|
|
@ -311,6 +311,7 @@
|
||||||
"Publish": "Опубликовать",
|
"Publish": "Опубликовать",
|
||||||
"Publish Album": "Опубликовать альбом",
|
"Publish Album": "Опубликовать альбом",
|
||||||
"Publish Settings": "Настройки публикации",
|
"Publish Settings": "Настройки публикации",
|
||||||
|
"Published": "Опубликованные",
|
||||||
"Punchline": "Панчлайн",
|
"Punchline": "Панчлайн",
|
||||||
"Quit": "Выйти",
|
"Quit": "Выйти",
|
||||||
"Quote": "Цитата",
|
"Quote": "Цитата",
|
||||||
|
|
|
@ -63,7 +63,6 @@ export const Header = (props: Props) => {
|
||||||
const [isFeedVisible, setIsFeedVisible] = createSignal(false)
|
const [isFeedVisible, setIsFeedVisible] = createSignal(false)
|
||||||
const toggleFixed = () => {
|
const toggleFixed = () => {
|
||||||
setFixed(!fixed())
|
setFixed(!fixed())
|
||||||
console.log('!!! toggleFixed:')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const tag = (topic: Topic) =>
|
const tag = (topic: Topic) =>
|
||||||
|
@ -141,9 +140,6 @@ export const Header = (props: Props) => {
|
||||||
clearTimeout(timer)
|
clearTimeout(timer)
|
||||||
}
|
}
|
||||||
|
|
||||||
createEffect(() => {
|
|
||||||
console.log('!!! mo:', modal())
|
|
||||||
})
|
|
||||||
const hideSubnavigation = (event, time = 500) => {
|
const hideSubnavigation = (event, time = 500) => {
|
||||||
timer = setTimeout(() => {
|
timer = setTimeout(() => {
|
||||||
toggleSubnavigation(false)
|
toggleSubnavigation(false)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.feedFilter {
|
.feedFilter {
|
||||||
@include media-breakpoint-down(md) {
|
@include media-breakpoint-down(md) {
|
||||||
margin-right: 4rem !important;
|
margin-right: 1rem !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,15 +195,29 @@
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 4rem;
|
margin-bottom: 4rem;
|
||||||
|
@include media-breakpoint-down(sm) {
|
||||||
|
flex-direction: column-reverse;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
.feedFilter {
|
.feedFilter {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
|
min-width: 300px;
|
||||||
|
|
||||||
& > li {
|
& > li {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dropdowns {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
gap: 1rem;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.periodSwitcher {
|
.periodSwitcher {
|
||||||
|
|
|
@ -31,15 +31,22 @@ export const FEED_PAGE_SIZE = 20
|
||||||
const UNRATED_ARTICLES_COUNT = 5
|
const UNRATED_ARTICLES_COUNT = 5
|
||||||
|
|
||||||
type FeedPeriod = 'week' | 'month' | 'year'
|
type FeedPeriod = 'week' | 'month' | 'year'
|
||||||
|
type VisibilityMode = 'all' | 'community' | 'public'
|
||||||
|
|
||||||
type PeriodItem = {
|
type PeriodItem = {
|
||||||
value: FeedPeriod
|
value: FeedPeriod
|
||||||
title: string
|
title: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type VisibilityItem = {
|
||||||
|
value: VisibilityMode
|
||||||
|
title: string
|
||||||
|
}
|
||||||
|
|
||||||
type FeedSearchParams = {
|
type FeedSearchParams = {
|
||||||
by: 'publish_date' | 'rating' | 'last_comment'
|
by: 'publish_date' | 'rating' | 'last_comment'
|
||||||
period: FeedPeriod
|
period: FeedPeriod
|
||||||
|
visibility: VisibilityMode
|
||||||
}
|
}
|
||||||
|
|
||||||
const getOrderBy = (by: FeedSearchParams['by']) => {
|
const getOrderBy = (by: FeedSearchParams['by']) => {
|
||||||
|
@ -80,6 +87,7 @@ export const Feed = (props: Props) => {
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize()
|
||||||
|
|
||||||
const monthPeriod: PeriodItem = { value: 'month', title: t('This month') }
|
const monthPeriod: PeriodItem = { value: 'month', title: t('This month') }
|
||||||
|
const visibilityAll = { value: 'public', title: t('All') }
|
||||||
|
|
||||||
const periods: PeriodItem[] = [
|
const periods: PeriodItem[] = [
|
||||||
{ value: 'week', title: t('This week') },
|
{ value: 'week', title: t('This week') },
|
||||||
|
@ -87,6 +95,11 @@ export const Feed = (props: Props) => {
|
||||||
{ value: 'year', title: t('This year') },
|
{ value: 'year', title: t('This year') },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const visibilities: VisibilityItem[] = [
|
||||||
|
{ value: 'community', title: t('All') },
|
||||||
|
{ value: 'public', title: t('Published') },
|
||||||
|
]
|
||||||
|
|
||||||
const { page, searchParams, changeSearchParams } = useRouter<FeedSearchParams>()
|
const { page, searchParams, changeSearchParams } = useRouter<FeedSearchParams>()
|
||||||
const [isLoading, setIsLoading] = createSignal(false)
|
const [isLoading, setIsLoading] = createSignal(false)
|
||||||
const [isRightColumnLoaded, setIsRightColumnLoaded] = createSignal(false)
|
const [isRightColumnLoaded, setIsRightColumnLoaded] = createSignal(false)
|
||||||
|
@ -100,14 +113,20 @@ export const Feed = (props: Props) => {
|
||||||
|
|
||||||
const currentPeriod = createMemo(() => {
|
const currentPeriod = createMemo(() => {
|
||||||
const period = periods.find((p) => p.value === searchParams().period)
|
const period = periods.find((p) => p.value === searchParams().period)
|
||||||
|
|
||||||
if (!period) {
|
if (!period) {
|
||||||
return monthPeriod
|
return monthPeriod
|
||||||
}
|
}
|
||||||
|
|
||||||
return period
|
return period
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const currentVisibility = createMemo(() => {
|
||||||
|
const visibility = visibilities.find((v) => v.value === searchParams().visibility)
|
||||||
|
if (!visibility) {
|
||||||
|
return visibilityAll
|
||||||
|
}
|
||||||
|
return visibility
|
||||||
|
})
|
||||||
|
|
||||||
const {
|
const {
|
||||||
actions: { loadReactionsBy },
|
actions: { loadReactionsBy },
|
||||||
} = useReactions()
|
} = useReactions()
|
||||||
|
@ -130,7 +149,7 @@ export const Feed = (props: Props) => {
|
||||||
|
|
||||||
createEffect(
|
createEffect(
|
||||||
on(
|
on(
|
||||||
() => page().route + searchParams().by + searchParams().period,
|
() => page().route + searchParams().by + searchParams().period + searchParams().visibility,
|
||||||
() => {
|
() => {
|
||||||
resetSortedArticles()
|
resetSortedArticles()
|
||||||
loadMore()
|
loadMore()
|
||||||
|
@ -146,17 +165,20 @@ export const Feed = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const orderBy = getOrderBy(searchParams().by)
|
const orderBy = getOrderBy(searchParams().by)
|
||||||
|
|
||||||
if (orderBy) {
|
if (orderBy) {
|
||||||
options.order_by = orderBy
|
options.order_by = orderBy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const visibilityMode = searchParams().visibility
|
||||||
|
if (visibilityMode && visibilityMode !== 'all') {
|
||||||
|
options.filters = { ...options.filters, visibility: visibilityMode }
|
||||||
|
}
|
||||||
|
|
||||||
if (searchParams().by && searchParams().by !== 'publish_date') {
|
if (searchParams().by && searchParams().by !== 'publish_date') {
|
||||||
const period = searchParams().period || 'month'
|
const period = searchParams().period || 'month'
|
||||||
const fromDate = getFromDate(period)
|
const fromDate = getFromDate(period)
|
||||||
options.filters = { fromDate: getServerDate(fromDate) }
|
options.filters = { ...options.filters, fromDate: getServerDate(fromDate) }
|
||||||
}
|
}
|
||||||
|
|
||||||
return props.loadShouts(options)
|
return props.loadShouts(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,16 +253,24 @@ export const Feed = (props: Props) => {
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<Show when={searchParams().by && searchParams().by !== 'publish_date'}>
|
<div class={styles.dropdowns}>
|
||||||
<div>
|
<Show when={searchParams().by && searchParams().by !== 'publish_date'}>
|
||||||
<DropDown
|
<DropDown
|
||||||
options={periods}
|
options={periods}
|
||||||
currentOption={currentPeriod()}
|
currentOption={currentPeriod()}
|
||||||
triggerCssClass={styles.periodSwitcher}
|
triggerCssClass={styles.periodSwitcher}
|
||||||
onChange={(period) => changeSearchParams({ period: period.value })}
|
onChange={(period: PeriodItem) => changeSearchParams({ period: period.value })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</Show>
|
||||||
</Show>
|
<DropDown
|
||||||
|
options={visibilities}
|
||||||
|
currentOption={currentVisibility()}
|
||||||
|
triggerCssClass={styles.periodSwitcher}
|
||||||
|
onChange={(visibility: VisibilityItem) =>
|
||||||
|
changeSearchParams({ visibility: visibility.value })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Show when={!isLoading()} fallback={<Loading />}>
|
<Show when={!isLoading()} fallback={<Loading />}>
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
.trigger {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
.chevron {
|
.chevron {
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ export const DropDown = <TOption extends Option = Option>(props: Props<TOption>)
|
||||||
<Show when={props.currentOption} keyed={true}>
|
<Show when={props.currentOption} keyed={true}>
|
||||||
<Popup
|
<Popup
|
||||||
trigger={
|
trigger={
|
||||||
<div class={props.triggerCssClass}>
|
<div class={clsx(styles.trigger, props.triggerCssClass)}>
|
||||||
{props.currentOption.title}{' '}
|
{props.currentOption.title}{' '}
|
||||||
<Chevron
|
<Chevron
|
||||||
class={clsx(styles.chevron, {
|
class={clsx(styles.chevron, {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user