Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

More UI for the show post page.

Matt Roberts06e805fd5197
diff --git a/app/services/sqlstore/postgres/comment.go b/app/services/sqlstore/postgres/comment.go
index eaaa17d73..ba195065f 100644
--- a/app/services/sqlstore/postgres/comment.go
+++ b/app/services/sqlstore/postgres/comment.go
@@ -245,7 +245,7 @@ func getCommentsByPost(ctx context.Context, q *query.GetCommentsByPost) error {
WHERE p.id = $1
AND p.tenant_id = $2
AND c.deleted_at IS NULL
- ORDER BY c.created_at ASC`, q.Post.ID, tenant.ID, userId)
+ ORDER BY c.created_at DESC`, q.Post.ID, tenant.ID, userId)
if err != nil {
return errors.Wrap(err, "failed get comments of post with id '%d'", q.Post.ID)
}
diff --git a/public/assets/images/heroicons-person.svg b/public/assets/images/heroicons-person.svg
new file mode 100644
index 000000000..883c7f4dd
--- /dev/null
+++ b/public/assets/images/heroicons-person.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z" />
+</svg>
diff --git a/public/components/Reactions.tsx b/public/components/Reactions.tsx
index 68b8c26ad..c50a285f1 100644
--- a/public/components/Reactions.tsx
+++ b/public/components/Reactions.tsx
@@ -75,7 +75,7 @@ export const Reactions: React.FC<ReactionsProps> = ({ emojiSelectorRef, toggleRe
"clickable hover:bg-gray-200": fider.session.isAuthenticated && !reaction.includesMe,
})}
>
- {reaction.emoji} <span className="ml-1 font-semibold">{reaction.count}</span>
+ {reaction.emoji} <span className="ml-1 text-semibold">{reaction.count}</span>
</span>
))}
</>
diff --git a/public/components/ShowPostResponse.tsx b/public/components/ShowPostResponse.tsx
index 8f0dd6477..feafdd1bf 100644
--- a/public/components/ShowPostResponse.tsx
+++ b/public/components/ShowPostResponse.tsx
@@ -27,11 +27,11 @@ export const ResponseDetails = (props: PostResponseProps): JSX.Element | null =>
return null
}
- const { bg, border } = getLozengeProps(status)
+ const { bg } = getLozengeProps(status)
return (
<HStack spacing={4} align="start" className="c-response-details">
- <div className={`c-response-details__card ${bg} border ${border}`}>
+ <div className={`c-response-details__card ${bg} `}>
<div className="c-response-details__header">
<HStack spacing={2} align="center">
<UserName user={props.response.user} />
diff --git a/public/components/common/UserName.scss b/public/components/common/UserName.scss
index c76381f9f..bd37021b5 100644
--- a/public/components/common/UserName.scss
+++ b/public/components/common/UserName.scss
@@ -20,7 +20,7 @@
div {
svg {
height: 14px;
- vertical-align: text-bottom;
+ vertical-align: middle;
margin-inline-start: 2px;
align-items: flex-end;
}
diff --git a/public/pages/ShowPost/ShowPost.page.scss b/public/pages/ShowPost/ShowPost.page.scss
index 174e156cb..9bdb219e6 100644
--- a/public/pages/ShowPost/ShowPost.page.scss
+++ b/public/pages/ShowPost/ShowPost.page.scss
@@ -96,7 +96,6 @@
flex-grow: 1;
border-radius: get("border.radius.xlarge");
padding: spacing(4);
- box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
border-width: 2px;
}
diff --git a/public/pages/ShowPost/ShowPost.page.tsx b/public/pages/ShowPost/ShowPost.page.tsx
index 785556af2..46afc53bb 100644
--- a/public/pages/ShowPost/ShowPost.page.tsx
+++ b/public/pages/ShowPost/ShowPost.page.tsx
@@ -257,7 +257,7 @@ export default function ShowPostPage(props: ShowPostPageProps) {
{/* Edit Mode Actions */}
{editMode && (
- <HStack>
+ <HStack className="mt-6">
<Button variant="primary" onClick={saveChanges} disabled={Fider.isReadOnly}>
<Icon sprite={IconThumbsUp} />{" "}
<span>
@@ -314,11 +314,16 @@ export default function ShowPostPage(props: ShowPostPageProps) {
{/* Discussion Section */}
<div className="p-show-post__discussion-section">
{/* Discussion Header */}
- <div className="p-show-post__discussion-header">
- <h2 className="text-xl font-semibold text-gray-900">
- <Trans id="label.discussion">Discussion</Trans> <span className="text-gray-500">{props.comments.length}</span>
+ <HStack className="p-show-post__discussion-header" align="center" spacing={4}>
+ <h2 className="text-xl text-bold text-gray-900">
+ <span className="text-bold">
+ <Trans id="label.discussion">Discussion</Trans>
+ </span>
</h2>
- </div>
+ <div style={{ width: "25px", height: "25px" }} className="text-blue-300 ml-4 rounded-full bg-blue-100 text-center ">
+ {props.comments.length}
+ </div>
+ </HStack>
{/* Comment Input at top */}
<CommentInput post={props.post} />
@@ -336,10 +341,8 @@ export default function ShowPostPage(props: ShowPostPageProps) {
{/* Right Sidebar */}
<div className="p-show-post__action-col">
- {/* Stay Updated Card */}
{!editMode && <StayUpdatedCard post={props.post} subscribed={props.subscribed} />}
- {/* Voters Panel */}
<VotesPanel post={props.post} votes={props.votes} />
<PoweredByFider slot="show-post" className="mt-3" />
diff --git a/public/pages/ShowPost/components/ShowComment.tsx b/public/pages/ShowPost/components/ShowComment.tsx
index 60b6af103..c4fa6f539 100644
--- a/public/pages/ShowPost/components/ShowComment.tsx
+++ b/public/pages/ShowPost/components/ShowComment.tsx
@@ -171,9 +171,9 @@ export const ShowComment = (props: ShowCommentProps) => {
<div className="mb-1">
<HStack justify="between">
<HStack>
- <UserName user={comment.user} />{" "}
+ <UserName user={comment.user} /> <span className="text-sm text-gray-400">•</span>
<div className="text-xs">
- · <Moment locale={fider.currentLocale} date={comment.createdAt} /> {editedMetadata}
+ <Moment locale={fider.currentLocale} date={comment.createdAt} /> {editedMetadata}
</div>
</HStack>
{!isEditing && (
diff --git a/public/pages/ShowPost/components/StayUpdatedCard.tsx b/public/pages/ShowPost/components/StayUpdatedCard.tsx
index 7614a2bfe..d0bc8e147 100644
--- a/public/pages/ShowPost/components/StayUpdatedCard.tsx
+++ b/public/pages/ShowPost/components/StayUpdatedCard.tsx
@@ -5,7 +5,7 @@ import { useFider } from "@fider/hooks"
import IconPlus from "@fider/assets/images/heroicons-plus.svg"
import IconCheck from "@fider/assets/images/heroicons-check.svg"
import { VStack } from "@fider/components/layout"
-import { Trans } from "@lingui/macro"
+import { Trans } from "@lingui/react/macro"
import { Post } from "@fider/models"
export interface StayUpdatedCardProps {
@@ -48,7 +48,7 @@ export const StayUpdatedCard = (props: StayUpdatedCardProps) => {
return (
<VStack spacing={2}>
- <h3 className="text-base font-semibold text-gray-900">
+ <h3 className="text-bold text-gray-900">
<Trans id="showpost.stayupdated.title">Stay Updated</Trans>
</h3>
<p className="text-sm text-gray-600">
diff --git a/public/pages/ShowPost/components/VotesModal.scss b/public/pages/ShowPost/components/VotesModal.scss
new file mode 100644
index 000000000..cb00088a8
--- /dev/null
+++ b/public/pages/ShowPost/components/VotesModal.scss
@@ -0,0 +1,21 @@
+@use "~@fider/assets/styles/variables.scss" as *;
+
+.c-votes-modal {
+ &__list {
+ margin-top: spacing(4);
+ }
+
+ &__item {
+ padding: spacing(4);
+ transition: background-color 0.15s ease;
+
+ &--alternate {
+ background-color: var(--colors-gray-50);
+ }
+ }
+
+ &__date {
+ padding-right: spacing(4);
+ flex-shrink: 0;
+ }
+}
diff --git a/public/pages/ShowPost/components/VotesModal.tsx b/public/pages/ShowPost/components/VotesModal.tsx
index 2ce92b7c7..f8526d3d6 100644
--- a/public/pages/ShowPost/components/VotesModal.tsx
+++ b/public/pages/ShowPost/components/VotesModal.tsx
@@ -1,7 +1,9 @@
+import "./VotesModal.scss"
+
import React, { useEffect, useState } from "react"
import { Post, Vote } from "@fider/models"
import { Modal, Button, Loader, Avatar, UserName, Moment, Input } from "@fider/components"
-import { actions } from "@fider/services"
+import { actions, classSet } from "@fider/services"
import { useFider } from "@fider/hooks"
import IconSearch from "@fider/assets/images/heroicons-search.svg"
import IconX from "@fider/assets/images/heroicons-x.svg"
@@ -65,17 +67,24 @@ export const VotesModal: React.FC<VotesModalProps> = (props) => {
value={query}
onChange={handleSearchFilterChanged}
/>
- <VStack spacing={2} className="h-max-5xl overflow-auto">
- {filteredVotes.map((x) => (
- <HStack key={x.user.id} justify="between">
- <HStack>
+ <VStack spacing={0} className="h-max-5xl overflow-auto c-votes-modal__list">
+ {filteredVotes.map((x, index) => (
+ <HStack
+ key={x.user.id}
+ justify="between"
+ className={classSet({
+ "c-votes-modal__item": true,
+ "c-votes-modal__item--alternate": index % 2 === 1
+ })}
+ >
+ <HStack spacing={4}>
<Avatar user={x.user} />
- <VStack spacing={0}>
+ <VStack spacing={1}>
<UserName user={x.user} />
- <span className="text-muted">{x.user.email}</span>
+ <span className="text-muted text-sm">{x.user.email}</span>
</VStack>
</HStack>
- <span className="text-muted">
+ <span className="text-muted text-sm c-votes-modal__date">
<Moment locale={fider.currentLocale} date={x.createdAt} />
</span>
</HStack>
diff --git a/public/pages/ShowPost/components/VotesPanel.scss b/public/pages/ShowPost/components/VotesPanel.scss
new file mode 100644
index 000000000..786bfbc51
--- /dev/null
+++ b/public/pages/ShowPost/components/VotesPanel.scss
@@ -0,0 +1,66 @@
+@use "~@fider/assets/styles/variables.scss" as *;
+
+.c-votes-panel {
+ &__header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ }
+
+ &__count-badge {
+ background-color: var(--colors-gray-100);
+ color: var(--colors-gray-700);
+ font-size: get("font.size.xs");
+ font-weight: get("font.weight.semibold");
+ padding: spacing(1) spacing(2);
+ border-radius: get("border.radius.full");
+ line-height: 1;
+ }
+
+ &__avatars {
+ display: flex;
+ flex-wrap: wrap;
+ gap: spacing(3);
+ align-items: center;
+
+ // Style avatars with border
+ .c-avatar {
+ border: 2px solid var(--colors-white);
+ box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
+ }
+ }
+
+ &__more-avatar {
+ width: 40px;
+ height: 40px;
+ border-radius: get("border.radius.full");
+ border: 2px dashed var(--colors-gray-300);
+ background-color: var(--colors-white);
+ color: var(--colors-gray-600);
+ font-size: get("font.size.sm");
+ font-weight: get("font.weight.semibold");
+ cursor: pointer;
+ transition: all 0.2s ease;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+
+ svg {
+ width: 20px;
+ height: 20px;
+ }
+
+ &:hover:not(:disabled) {
+ border-color: var(--colors-primary-base);
+ color: var(--colors-primary-base);
+ background-color: var(--colors-primary-50);
+ transform: scale(1.05);
+ }
+
+ &:disabled {
+ cursor: not-allowed;
+ opacity: 0.6;
+ }
+ }
+}
diff --git a/public/pages/ShowPost/components/VotesPanel.tsx b/public/pages/ShowPost/components/VotesPanel.tsx
index ff0a8d968..c47058867 100644
--- a/public/pages/ShowPost/components/VotesPanel.tsx
+++ b/public/pages/ShowPost/components/VotesPanel.tsx
@@ -1,11 +1,14 @@
+import "./VotesPanel.scss"
+
import React, { useState } from "react"
import { Post, Vote } from "@fider/models"
-import { AvatarStack, Button } from "@fider/components"
+import { Avatar, Icon } from "@fider/components"
import { Fider } from "@fider/services"
import { useFider } from "@fider/hooks"
import { VotesModal } from "./VotesModal"
-import { HStack, VStack } from "@fider/components/layout"
+import { VStack } from "@fider/components/layout"
import { Trans } from "@lingui/react/macro"
+import IconPerson from "@fider/assets/images/heroicons-person.svg"
interface VotesPanelProps {
post: Post
@@ -13,6 +16,8 @@ interface VotesPanelProps {
votes: Vote[]
}
+const MAX_AVATARS_SHOWN = 12
+
export const VotesPanel = (props: VotesPanelProps) => {
const fider = useFider()
const [isVotesModalOpen, setIsVotesModalOpen] = useState(false)
@@ -26,31 +31,40 @@ export const VotesPanel = (props: VotesPanelProps) => {
const closeModal = () => setIsVotesModalOpen(false)
- const extraVotesCount = props.post.votesCount - props.votes.length
+ const totalVotesCount = props.post.votesCount
+ const visibleVotes = props.votes.slice(0, MAX_AVATARS_SHOWN)
+ const remainingCount = totalVotesCount - MAX_AVATARS_SHOWN
return (
- <VStack spacing={4}>
+ <VStack spacing={4} className="c-votes-panel">
<VotesModal post={props.post} isOpen={isVotesModalOpen} onClose={closeModal} />
- {!props.hideTitle && (
- <span className="text-category">
- <Trans id="label.voters">Voters</Trans>
- </span>
- )}
+
+ <div className="c-votes-panel__header">
+ {!props.hideTitle && (
+ <span className="text-bold text-gray-900">
+ <Trans id="label.voters">Voters</Trans>
+ </span>
+ )}
+ <div className="c-votes-panel__count-badge">{totalVotesCount}</div>
+ </div>
+
{props.votes.length > 0 && (
- <HStack spacing={0} className="gap-2">
- <AvatarStack users={props.votes.map((x) => x.user)} overlap={false} />
- </HStack>
- )}
- {extraVotesCount > 0 && (
- <Button variant="tertiary" disabled={!canShowAll} size="small" onClick={openModal}>
- <Trans id="showpost.votespanel.more">+{extraVotesCount} more</Trans>
- </Button>
- )}
- {props.votes.length > 0 && extraVotesCount === 0 && canShowAll && (
- <Button variant="tertiary" size="small" disabled={!canShowAll} onClick={openModal}>
- <Trans id="showpost.votespanel.seedetails">see details</Trans>
- </Button>
+ <div className="c-votes-panel__avatars">
+ {visibleVotes.map((vote, i) => (
+ <Avatar key={i} user={vote.user} />
+ ))}
+ {remainingCount > 0 ? (
+ <button className="c-votes-panel__more-avatar" onClick={openModal} disabled={!canShowAll}>
+ +{remainingCount}
+ </button>
+ ) : (
+ <button className="c-votes-panel__more-avatar" onClick={openModal} disabled={!canShowAll}>
+ <Icon sprite={IconPerson} />
+ </button>
+ )}
+ </div>
)}
+
{props.votes.length === 0 && (
<span className="text-muted">
<Trans id="label.none">None</Trans>