Merge pull request #78 from Discours/even-more-fixes

articles fix
This commit is contained in:
Igor Lobanov 2022-12-07 21:14:53 +01:00 committed by GitHub
commit 3aafd4f5d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 36 additions and 25 deletions

View File

@ -19,7 +19,6 @@ export default (props: {
canEdit?: boolean canEdit?: boolean
compact?: boolean compact?: boolean
}) => { }) => {
const [isSharePopupVisible, setIsSharePopupVisible] = createSignal(false)
const [isReplyVisible, setIsReplyVisible] = createSignal(false) const [isReplyVisible, setIsReplyVisible] = createSignal(false)
const comment = createMemo(() => props.comment) const comment = createMemo(() => props.comment)
@ -68,9 +67,9 @@ export default (props: {
[styles.commentRatingNegative]: comment().stat?.rating < 0 [styles.commentRatingNegative]: comment().stat?.rating < 0
}} }}
> >
<button class={clsx(styles.commentRatingControl, styles.commentRatingControlUp)}></button> <button class={clsx(styles.commentRatingControl, styles.commentRatingControlUp)} />
<div class={styles.commentRatingValue}>{comment().stat?.rating || 0}</div> <div class={styles.commentRatingValue}>{comment().stat?.rating || 0}</div>
<button class={clsx(styles.commentRatingControl, styles.commentRatingControlDown)}></button> <button class={clsx(styles.commentRatingControl, styles.commentRatingControlDown)} />
</div> </div>
</div> </div>
</Show> </Show>
@ -112,9 +111,6 @@ export default (props: {
</Show> </Show>
<SharePopup <SharePopup
onVisibilityChange={(isVisible) => {
setIsSharePopupVisible(isVisible)
}}
containerCssClass={stylesHeader.control} containerCssClass={stylesHeader.control}
trigger={ trigger={
<button class={clsx(styles.commentControl, styles.commentControlShare)}> <button class={clsx(styles.commentControl, styles.commentControlShare)}>
@ -134,7 +130,7 @@ export default (props: {
<Show when={isReplyVisible()}> <Show when={isReplyVisible()}>
<form class={styles.replyForm}> <form class={styles.replyForm}>
<textarea name="reply" id="reply" rows="5"></textarea> <textarea name="reply" id="reply" rows="5" />
<div class={styles.replyFormControls}> <div class={styles.replyFormControls}>
<button class="button button--light" onClick={() => setIsReplyVisible(false)}> <button class="button button--light" onClick={() => setIsReplyVisible(false)}>
{t('Cancel')} {t('Cancel')}

View File

@ -55,9 +55,18 @@ export const AuthorCard = (props: AuthorCardProps) => {
const canFollow = createMemo(() => !props.hideFollow && session()?.user?.slug !== props.author.slug) const canFollow = createMemo(() => !props.hideFollow && session()?.user?.slug !== props.author.slug)
const name = () => { const name = createMemo(() => {
return props.author.name === 'Дискурс' && locale() !== 'ru' ? 'Discours' : translit(props.author.name) if (locale() !== 'ru') {
} if (props.author.name === 'Дискурс') {
return 'Discours'
}
return translit(props.author.name)
}
return props.author.name
})
// TODO: reimplement AuthorCard // TODO: reimplement AuthorCard
return ( return (
<div <div

View File

@ -134,8 +134,11 @@ export const ArticleCard = (props: ArticleCardProps) => {
<div class={styles.shoutAuthor}> <div class={styles.shoutAuthor}>
<For each={authors}> <For each={authors}>
{(author, index) => { {(author, index) => {
const name = let name = author.name
author.name === 'Дискурс' && locale() !== 'ru' ? 'Discours' : translit(author.name)
if (locale() !== 'ru') {
name = name === 'Дискурс' ? 'Discours' : translit(name)
}
return ( return (
<> <>

View File

@ -8,7 +8,7 @@ import { loadAuthor } from '../../stores/zine/authors'
import { Loading } from '../Loading' import { Loading } from '../Loading'
export const AuthorPage = (props: PageProps) => { export const AuthorPage = (props: PageProps) => {
const [isLoaded, setIsLoaded] = createSignal(Boolean(props.shouts) && Boolean(props.author)) const [isLoaded, setIsLoaded] = createSignal(Boolean(props.authorShouts) && Boolean(props.author))
const slug = createMemo(() => { const slug = createMemo(() => {
const { page: getPage } = useRouter() const { page: getPage } = useRouter()
@ -38,7 +38,7 @@ export const AuthorPage = (props: PageProps) => {
return ( return (
<PageWrap> <PageWrap>
<Show when={isLoaded()} fallback={<Loading />}> <Show when={isLoaded()} fallback={<Loading />}>
<AuthorView author={props.author} shouts={props.shouts} authorSlug={slug()} /> <AuthorView author={props.author} shouts={props.authorShouts} authorSlug={slug()} />
</Show> </Show>
</PageWrap> </PageWrap>
) )

View File

@ -8,7 +8,7 @@ import { Loading } from '../Loading'
import styles from './HomePage.module.scss' import styles from './HomePage.module.scss'
export const HomePage = (props: PageProps) => { export const HomePage = (props: PageProps) => {
const [isLoaded, setIsLoaded] = createSignal(Boolean(props.shouts) && Boolean(props.randomTopics)) const [isLoaded, setIsLoaded] = createSignal(Boolean(props.homeShouts) && Boolean(props.randomTopics))
onMount(async () => { onMount(async () => {
if (isLoaded()) { if (isLoaded()) {
@ -26,7 +26,7 @@ export const HomePage = (props: PageProps) => {
return ( return (
<PageWrap class={styles.mainContent}> <PageWrap class={styles.mainContent}>
<Show when={isLoaded()} fallback={<Loading />}> <Show when={isLoaded()} fallback={<Loading />}>
<HomeView randomTopics={props.randomTopics} shouts={props.shouts || []} /> <HomeView randomTopics={props.randomTopics} shouts={props.homeShouts || []} />
</Show> </Show>
</PageWrap> </PageWrap>
) )

View File

@ -29,7 +29,7 @@ export const LayoutShoutsPage = (props: PageProps) => {
return page.params.layout as LayoutType return page.params.layout as LayoutType
}) })
const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false) const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false)
const { sortedLayoutShouts, loadLayoutShoutsBy } = useLayoutsStore(layout(), props.shouts) const { sortedLayoutShouts, loadLayoutShoutsBy } = useLayoutsStore(layout(), props.layoutShouts)
const sortedArticles = createMemo<Shout[]>(() => sortedLayoutShouts().get(layout()) || []) const sortedArticles = createMemo<Shout[]>(() => sortedLayoutShouts().get(layout()) || [])
const loadMoreLayout = async (kind: LayoutType) => { const loadMoreLayout = async (kind: LayoutType) => {
saveScrollPosition() saveScrollPosition()

View File

@ -8,7 +8,7 @@ import { loadTopic } from '../../stores/zine/topics'
import { Loading } from '../Loading' import { Loading } from '../Loading'
export const TopicPage = (props: PageProps) => { export const TopicPage = (props: PageProps) => {
const [isLoaded, setIsLoaded] = createSignal(Boolean(props.shouts) && Boolean(props.topic)) const [isLoaded, setIsLoaded] = createSignal(Boolean(props.topicShouts) && Boolean(props.topic))
const slug = createMemo(() => { const slug = createMemo(() => {
const { page: getPage } = useRouter() const { page: getPage } = useRouter()
@ -38,7 +38,7 @@ export const TopicPage = (props: PageProps) => {
return ( return (
<PageWrap> <PageWrap>
<Show when={isLoaded()} fallback={<Loading />}> <Show when={isLoaded()} fallback={<Loading />}>
<TopicView topic={props.topic} shouts={props.shouts} topicSlug={slug()} /> <TopicView topic={props.topic} shouts={props.topicShouts} topicSlug={slug()} />
</Show> </Show>
</PageWrap> </PageWrap>
) )

View File

@ -6,7 +6,10 @@ import type { LayoutType } from '../stores/zine/layouts'
export type PageProps = { export type PageProps = {
randomTopics?: Topic[] randomTopics?: Topic[]
article?: Shout article?: Shout
shouts?: Shout[] layoutShouts?: Shout[]
authorShouts?: Shout[]
topicShouts?: Shout[]
homeShouts?: Shout[]
author?: Author author?: Author
allAuthors?: Author[] allAuthors?: Author[]
topic?: Topic topic?: Topic

View File

@ -16,5 +16,5 @@ Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate'
--- ---
<Prerendered> <Prerendered>
<Root shouts={shouts} author={author} client:load /> <Root authorShouts={shouts} author={author} client:load />
</Prerendered> </Prerendered>

View File

@ -15,6 +15,6 @@ initRouter(pathname, search)
--- ---
<Prerendered> <Prerendered>
<Root shouts={shouts} layout={layout} client:load /> <Root layoutShouts={shouts} layout={layout} client:load />
</Prerendered> </Prerendered>

View File

@ -6,7 +6,7 @@ import { initRouter } from '../stores/router'
import { PRERENDERED_ARTICLES_COUNT, RANDOM_TOPICS_COUNT } from '../components/Views/Home' import { PRERENDERED_ARTICLES_COUNT, RANDOM_TOPICS_COUNT } from '../components/Views/Home'
const randomTopics = await apiClient.getRandomTopics({ amount: RANDOM_TOPICS_COUNT }) const randomTopics = await apiClient.getRandomTopics({ amount: RANDOM_TOPICS_COUNT })
const articles = await apiClient.getShouts( const shouts = await apiClient.getShouts(
{ filters: { visibility: "public" }, limit: PRERENDERED_ARTICLES_COUNT }) { filters: { visibility: "public" }, limit: PRERENDERED_ARTICLES_COUNT })
const { pathname, search } = Astro.url const { pathname, search } = Astro.url
@ -16,6 +16,6 @@ Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate'
--- ---
<Prerendered> <Prerendered>
<Root randomTopics={randomTopics} shouts={articles} client:load /> <Root randomTopics={randomTopics} homeShouts={shouts} client:load />
</Prerendered> </Prerendered>

View File

@ -17,5 +17,5 @@ Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate'
--- ---
<Prerendered> <Prerendered>
<Root shouts={shouts} topic={topic} client:load /> <Root topicShouts={shouts} topic={topic} client:load />
</Prerendered> </Prerendered>