Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

More changes for the show post page

Matt Robertsfa54b8e91eb5
diff --git a/locale/de/client.json b/locale/de/client.json
index df8ef8689..d45b670ef 100644
--- a/locale/de/client.json
+++ b/locale/de/client.json
@@ -54,6 +54,7 @@
"label.custom": "Benutzerdefiniert",
"label.description": "Beschreibung",
"label.discussion": "Diskussion",
+ "label.edittags": "",
"label.email": "E-Mail",
"label.follow": "",
"label.gravatar": "Gravatar",
diff --git a/locale/el/client.json b/locale/el/client.json
index 86e6dff4d..9d1c5edcb 100644
--- a/locale/el/client.json
+++ b/locale/el/client.json
@@ -54,6 +54,7 @@
"label.custom": "Προσαρμοσμένη",
"label.description": "Περιγραφή",
"label.discussion": "Συζήτηση",
+ "label.edittags": "",
"label.email": "Email",
"label.follow": "",
"label.gravatar": "Gravatar",
diff --git a/locale/en/client.json b/locale/en/client.json
index 14407e41e..5913f24c3 100644
--- a/locale/en/client.json
+++ b/locale/en/client.json
@@ -54,6 +54,7 @@
"label.custom": "Custom",
"label.description": "Description",
"label.discussion": "Discussion",
+ "label.edittags": "Edit tags",
"label.email": "Email",
"label.follow": "Follow",
"label.gravatar": "Gravatar",
diff --git a/locale/es-ES/client.json b/locale/es-ES/client.json
index 5c44f7980..b0dbbf0a6 100644
--- a/locale/es-ES/client.json
+++ b/locale/es-ES/client.json
@@ -54,6 +54,7 @@
"label.custom": "Personalizado",
"label.description": "Descripción",
"label.discussion": "Discusión",
+ "label.edittags": "",
"label.email": "Correo electrónico",
"label.follow": "",
"label.gravatar": "Gravatar",
diff --git a/locale/fr/client.json b/locale/fr/client.json
index 47865e649..fc88b7029 100644
--- a/locale/fr/client.json
+++ b/locale/fr/client.json
@@ -54,6 +54,7 @@
"label.custom": "Personnalisé",
"label.description": "Description",
"label.discussion": "Discussion",
+ "label.edittags": "",
"label.email": "E-mail",
"label.follow": "",
"label.gravatar": "Gravatar",
diff --git a/locale/it/client.json b/locale/it/client.json
index 3f1f87b31..3052baaf5 100644
--- a/locale/it/client.json
+++ b/locale/it/client.json
@@ -54,6 +54,7 @@
"label.custom": "Personalizzato",
"label.description": "Descrizione",
"label.discussion": "Discussione",
+ "label.edittags": "",
"label.email": "Email",
"label.follow": "",
"label.gravatar": "Gravatar",
diff --git a/locale/nl/client.json b/locale/nl/client.json
index 7bfeb774a..dfa1acf36 100644
--- a/locale/nl/client.json
+++ b/locale/nl/client.json
@@ -54,6 +54,7 @@
"label.custom": "Aangepast",
"label.description": "Omschrijving",
"label.discussion": "Discussie",
+ "label.edittags": "",
"label.email": "E-mailadres",
"label.follow": "",
"label.gravatar": "Gravatar",
diff --git a/locale/pl/client.json b/locale/pl/client.json
index 70ab186c2..150e1c3dc 100644
--- a/locale/pl/client.json
+++ b/locale/pl/client.json
@@ -54,6 +54,7 @@
"label.custom": "Niestandardowy",
"label.description": "Opis",
"label.discussion": "Dyskusja",
+ "label.edittags": "",
"label.email": "Email",
"label.follow": "",
"label.gravatar": "Gravatar",
diff --git a/locale/pt-BR/client.json b/locale/pt-BR/client.json
index fe94e2e91..c93beb5a0 100644
--- a/locale/pt-BR/client.json
+++ b/locale/pt-BR/client.json
@@ -54,6 +54,7 @@
"label.custom": "Personalizado",
"label.description": "Descrição",
"label.discussion": "Discussão",
+ "label.edittags": "",
"label.email": "E-mail",
"label.follow": "",
"label.gravatar": "Gravatar",
diff --git a/locale/ru/client.json b/locale/ru/client.json
index 8024d048a..a17e82a7d 100644
--- a/locale/ru/client.json
+++ b/locale/ru/client.json
@@ -54,6 +54,7 @@
"label.custom": "Пользовательский",
"label.description": "Описание",
"label.discussion": "Обсуждение",
+ "label.edittags": "",
"label.email": "Адрес электронной почты",
"label.follow": "",
"label.gravatar": "Gravatar",
diff --git a/locale/sk/client.json b/locale/sk/client.json
index 9ffdb21e2..80b40f14f 100644
--- a/locale/sk/client.json
+++ b/locale/sk/client.json
@@ -54,6 +54,7 @@
"label.custom": "Vlastné",
"label.description": "Popis",
"label.discussion": "Diskusia",
+ "label.edittags": "",
"label.email": "Email",
"label.follow": "",
"label.gravatar": "Gravatar",
diff --git a/locale/sv-SE/client.json b/locale/sv-SE/client.json
index 6b1cd39de..6b4fc5527 100644
--- a/locale/sv-SE/client.json
+++ b/locale/sv-SE/client.json
@@ -54,6 +54,7 @@
"label.custom": "Anpassad",
"label.description": "Beskrivning",
"label.discussion": "Diskussion",
+ "label.edittags": "",
"label.email": "E-post",
"label.follow": "",
"label.gravatar": "Gravatar",
diff --git a/locale/tr/client.json b/locale/tr/client.json
index 4894a3605..0a2d20763 100644
--- a/locale/tr/client.json
+++ b/locale/tr/client.json
@@ -54,6 +54,7 @@
"label.custom": "Özel",
"label.description": "Açıklama",
"label.discussion": "Tartışma",
+ "label.edittags": "",
"label.email": "E-Posta",
"label.follow": "",
"label.gravatar": "Gravatar",
diff --git a/locale/zh-CN/client.json b/locale/zh-CN/client.json
index b7bec69e8..a981ec7a6 100644
--- a/locale/zh-CN/client.json
+++ b/locale/zh-CN/client.json
@@ -54,6 +54,7 @@
"label.custom": "自定义",
"label.description": "说明",
"label.discussion": "讨论",
+ "label.edittags": "",
"label.email": "邮箱",
"label.follow": "",
"label.gravatar": "Gravatar",
diff --git a/public/components/ShowTag.scss b/public/components/ShowTag.scss
index 2cf3f0234..ef59e941c 100644
--- a/public/components/ShowTag.scss
+++ b/public/components/ShowTag.scss
@@ -4,12 +4,13 @@
display: inline-flex;
justify-content: center;
align-items: center;
- font-size: 11px;
+ font-size: 13px;
color: get("colors.gray.900");
- font-weight: 500;
- border-radius: 10px;
- line-height: 18px;
- padding: 0 8px;
+ background-color: get("colors.gray.200");
+ font-weight: 600;
+ border-radius: 5px;
+ // line-height: 18px;
+ padding: 6px 10px;
border: 0;
&[href] {
@@ -21,6 +22,14 @@
}
}
+ span {
+ margin-right: 7px;
+ width: 12px;
+ height: 12px;
+ border-radius: 50%;
+ display: inline-block;
+ }
+
svg {
height: 8px;
margin-right: 2px;
diff --git a/public/components/ShowTag.tsx b/public/components/ShowTag.tsx
index b3b87114c..427ca509d 100644
--- a/public/components/ShowTag.tsx
+++ b/public/components/ShowTag.tsx
@@ -22,11 +22,11 @@ const getRGB = (color: string) => {
}
}
-const textColor = (color: string) => {
- const components = getRGB(color)
- const bgDelta = components.R * 0.299 + components.G * 0.587 + components.B * 0.114
- return bgDelta > 140 ? "#333" : "#fff"
-}
+// const textColor = (color: string) => {
+// const components = getRGB(color)
+// const bgDelta = components.R * 0.299 + components.G * 0.587 + components.B * 0.114
+// return bgDelta > 140 ? "#333" : "#fff"
+// }
export const ShowTag = (props: TagProps) => {
const className = classSet({
@@ -49,12 +49,13 @@ export const ShowTag = (props: TagProps) => {
href={props.link && props.tag.slug ? `/?tags=${props.tag.slug}` : undefined}
title={`${props.tag.name}${props.tag.isPublic ? "" : " (Private)"}`}
className={className}
- style={{
- backgroundColor: `#${props.tag.color}`,
- border: `1px solid #${darkerColor}`,
- color: textColor(props.tag.color),
- }}
>
+ <span
+ style={{
+ backgroundColor: `#${props.tag.color}`,
+ border: `1px solid #${darkerColor}`,
+ }}
+ ></span>
{!props.tag.isPublic && !props.circular && (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path
diff --git a/public/pages/ShowPost/ShowPost.page.tsx b/public/pages/ShowPost/ShowPost.page.tsx
index 0814859bb..a345d7c12 100644
--- a/public/pages/ShowPost/ShowPost.page.tsx
+++ b/public/pages/ShowPost/ShowPost.page.tsx
@@ -36,10 +36,10 @@ import IconX from "@fider/assets/images/heroicons-x.svg"
import IconThumbsUp from "@fider/assets/images/heroicons-thumbsup.svg"
import { HStack, VStack } from "@fider/components/layout"
import { Trans } from "@lingui/macro"
-import { TagsPanel2 } from "./components/TagsPanel2"
-import { NotificationsPanel2 } from "./components/NotificationsPanel2"
+import { TagsPanel } from "./components/TagsPanel"
+import { FollowButton } from "./components/FollowButton"
import { VoteSection } from "./components/VoteSection"
-import { ModerationPanel } from "./components/ModerationPanel"
+import { DeletePostModal } from "./components/DeletePostModal"
import { ResponseModal } from "./components/ResponseModal"
import { MostWanted } from "./components/MostWanted"
@@ -229,13 +229,10 @@ export default class ShowPostPage extends React.Component<ShowPostPageProps, Sho
) : (
<>
<h1 className="text-large">{this.props.post.title}</h1>
- <div className="mt-2">
- <TagsPanel2 post={this.props.post} tags={this.props.tags} />
- </div>
</>
)}
</div>
- <ModerationPanel onModalClose={() => this.setShowDeleteModal(false)} showModal={this.state.showDeleteModal} post={this.props.post} />
+ <DeletePostModal onModalClose={() => this.setShowDeleteModal(false)} showModal={this.state.showDeleteModal} post={this.props.post} />
{Fider.session.user.isCollaborator && (
<ResponseModal onCloseModal={() => this.setShowResponseModal(false)} showModal={this.state.showResponseModal} post={this.props.post} />
)}
@@ -269,12 +266,15 @@ export default class ShowPostPage extends React.Component<ShowPostPageProps, Sho
</>
)}
</VStack>
+ <div className="mt-2">
+ <TagsPanel post={this.props.post} tags={this.props.tags} />
+ </div>
<VStack spacing={4}>
{!this.state.editMode ? (
<HStack justify="between" center={false}>
<VoteSection post={this.props.post} votes={this.props.votes} />
- <NotificationsPanel2 post={this.props.post} subscribed={this.props.subscribed} />
+ <FollowButton post={this.props.post} subscribed={this.props.subscribed} />
</HStack>
) : (
<HStack>
diff --git a/public/pages/ShowPost/components/ModerationPanel.tsx b/public/pages/ShowPost/components/DeletePostModal.tsx
similarity index 95%
rename from public/pages/ShowPost/components/ModerationPanel.tsx
rename to public/pages/ShowPost/components/DeletePostModal.tsx
index 019234c8d..0aaa9d746 100644
--- a/public/pages/ShowPost/components/ModerationPanel.tsx
+++ b/public/pages/ShowPost/components/DeletePostModal.tsx
@@ -5,13 +5,13 @@ import { Form, Modal, Button, TextArea } from "@fider/components"
import { useFider } from "@fider/hooks"
import { t, Trans } from "@lingui/macro"
-interface ModerationPanelProps {
+interface DeletePostModalProps {
post: Post
showModal: boolean
onModalClose: () => void
}
-export const ModerationPanel = (props: ModerationPanelProps) => {
+export const DeletePostModal = (props: DeletePostModalProps) => {
const fider = useFider()
const [text, setText] = useState("")
const [error, setError] = useState<Failure>()
diff --git a/public/pages/ShowPost/components/NotificationsPanel2.tsx b/public/pages/ShowPost/components/FollowButton.tsx
similarity index 88%
rename from public/pages/ShowPost/components/NotificationsPanel2.tsx
rename to public/pages/ShowPost/components/FollowButton.tsx
index 85776d06d..2cad5a67b 100644
--- a/public/pages/ShowPost/components/NotificationsPanel2.tsx
+++ b/public/pages/ShowPost/components/FollowButton.tsx
@@ -6,9 +6,14 @@ import IconVolumeOn from "@fider/assets/images/heroicons-volume-on.svg"
import IconVolumeOff from "@fider/assets/images/heroicons-volume-off.svg"
import { VStack } from "@fider/components/layout"
import { Trans } from "@lingui/macro"
-import { NotificationsPanelProps } from "./NotificationsPanel"
+import { Post } from "@fider/models"
-export const NotificationsPanel2 = (props: NotificationsPanelProps) => {
+export interface NotificationsPanelProps {
+ post: Post
+ subscribed: boolean
+}
+
+export const FollowButton = (props: NotificationsPanelProps) => {
const fider = useFider()
const [subscribed, setSubscribed] = useState(props.subscribed)
diff --git a/public/pages/ShowPost/components/NotificationsPanel.tsx b/public/pages/ShowPost/components/NotificationsPanel.tsx
deleted file mode 100644
index 0de322a1c..000000000
--- a/public/pages/ShowPost/components/NotificationsPanel.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import React, { useState } from "react"
-import { Post } from "@fider/models"
-import { Button, Icon } from "@fider/components"
-import { actions } from "@fider/services"
-import { useFider } from "@fider/hooks"
-import IconVolumeOn from "@fider/assets/images/heroicons-volume-on.svg"
-import IconVolumeOff from "@fider/assets/images/heroicons-volume-off.svg"
-import { VStack } from "@fider/components/layout"
-import { Trans } from "@lingui/macro"
-
-export interface NotificationsPanelProps {
- post: Post
- subscribed: boolean
-}
-
-export const NotificationsPanel = (props: NotificationsPanelProps) => {
- const fider = useFider()
- const [subscribed, setSubscribed] = useState(props.subscribed)
-
- const subscribeOrUnsubscribe = async () => {
- const action = subscribed ? actions.unsubscribe : actions.subscribe
-
- const response = await action(props.post.number)
- if (response.ok) {
- setSubscribed(!subscribed)
- }
- }
-
- if (!fider.session.isAuthenticated) {
- return null
- }
-
- const button = subscribed ? (
- <Button className="w-full" onClick={subscribeOrUnsubscribe} disabled={fider.isReadOnly}>
- <Icon sprite={IconVolumeOff} />{" "}
- <span>
- <Trans id="label.unsubscribe">Unsubscribe</Trans>
- </span>
- </Button>
- ) : (
- <Button className="w-full" onClick={subscribeOrUnsubscribe} disabled={fider.isReadOnly}>
- <Icon sprite={IconVolumeOn} />
- <span>
- <Trans id="label.subscribe">Subscribe</Trans>
- </span>
- </Button>
- )
-
- const text = subscribed ? (
- <span className="text-muted">
- <Trans id="showpost.notificationspanel.message.subscribed">You’re receiving notifications about activity on this post.</Trans>
- </span>
- ) : (
- <span className="text-muted">
- <Trans id="showpost.notificationspanel.message.unsubscribed">You&apos;ll not receive any notification about this post.</Trans>
- </span>
- )
-
- return (
- <VStack>
- <span className="text-category">
- <Trans id="label.notifications">Notifications</Trans>
- </span>
- {button}
- {text}
- </VStack>
- )
-}
diff --git a/public/pages/ShowPost/components/TagListItem.tsx b/public/pages/ShowPost/components/TagListItem.tsx
index c9b542184..b4accef09 100644
--- a/public/pages/ShowPost/components/TagListItem.tsx
+++ b/public/pages/ShowPost/components/TagListItem.tsx
@@ -18,8 +18,7 @@ export const TagListItem = (props: TagListItemProps) => {
return (
<HStack className="clickable hover:bg-gray-100 rounded py-1" onClick={onClick}>
<Icon sprite={IconCheck} className={`h-4 text-green-600 ${!props.assigned && "invisible"}`} />
- <ShowTag tag={props.tag} circular />
- <span>{props.tag.name}</span>
+ <ShowTag tag={props.tag} />
</HStack>
)
}
diff --git a/public/pages/ShowPost/components/TagsPanel.tsx b/public/pages/ShowPost/components/TagsPanel.tsx
index c58873541..cf6ef268e 100644
--- a/public/pages/ShowPost/components/TagsPanel.tsx
+++ b/public/pages/ShowPost/components/TagsPanel.tsx
@@ -1,12 +1,10 @@
import React, { useState } from "react"
-import { Tag, Post } from "@fider/models"
+import { Post, Tag } from "@fider/models"
import { actions } from "@fider/services"
-import { ShowTag, Icon } from "@fider/components"
+import { ShowTag, Button } from "@fider/components"
import { TagListItem } from "./TagListItem"
import { useFider } from "@fider/hooks"
-import IconPencilAlt from "@fider/assets/images/heroicons-pencil-alt.svg"
-import IconCheckCircle from "@fider/assets/images/heroicons-check-circle.svg"
import { HStack, VStack } from "@fider/components/layout"
import { Trans } from "@lingui/macro"
@@ -52,29 +50,28 @@ export const TagsPanel = (props: TagsPanelProps) => {
return null
}
- const tagsList =
- assignedTags.length > 0 ? (
- <VStack spacing={2} className="flex-items-baseline">
- {assignedTags.map((tag) => (
- <ShowTag key={tag.id} tag={tag} link />
- ))}
- </VStack>
- ) : (
- <span className="text-muted">
- <Trans id="label.none">None</Trans>
- </span>
- )
+ const tagsList = (
+ <HStack spacing={2} center={true}>
+ {assignedTags.length > 0 && assignedTags.map((tag) => <ShowTag key={tag.id} tag={tag} link />)}
+ <HStack spacing={1} center={true} className="clickable" onClick={onSubtitleClick}>
+ <span>
+ <Trans id="label.edittags">Edit tags</Trans>
+ </span>
+ </HStack>
+ </HStack>
+ )
const editTagsList = props.tags.length > 0 && (
- <VStack>
+ <VStack justify="between" className="flex-items-start">
{props.tags.map((tag) => (
<TagListItem key={tag.id} tag={tag} assigned={assignedTags.indexOf(tag) >= 0} onClick={assignOrUnassignTag} />
))}
+ <Button variant="secondary" size="small" onClick={onSubtitleClick}>
+ <Trans id="action.close">Close</Trans>
+ </Button>
</VStack>
)
- const icon = canEdit && (isEditing ? <Icon sprite={IconCheckCircle} className="h-4" /> : <Icon sprite={IconPencilAlt} className="h-4" />)
-
if (fider.isReadOnly) {
return (
<VStack>
@@ -88,15 +85,10 @@ export const TagsPanel = (props: TagsPanelProps) => {
return (
<VStack>
- <HStack spacing={2} className="text-category clickable" onClick={onSubtitleClick}>
- <span>
- <Trans id="label.tags">Tags</Trans>
- </span>
- {icon}
+ <HStack spacing={2} center={true} className="text-primary-base text-xs">
+ {!isEditing && tagsList}
+ {isEditing && editTagsList}
</HStack>
-
- {!isEditing && tagsList}
- {isEditing && editTagsList}
</VStack>
)
}
diff --git a/public/pages/ShowPost/components/TagsPanel2.tsx b/public/pages/ShowPost/components/TagsPanel2.tsx
deleted file mode 100644
index 89266cb56..000000000
--- a/public/pages/ShowPost/components/TagsPanel2.tsx
+++ /dev/null
@@ -1,95 +0,0 @@
-import React, { useState } from "react"
-import { Tag } from "@fider/models"
-import { actions } from "@fider/services"
-import { ShowTag, Icon, Button } from "@fider/components"
-import { TagListItem } from "./TagListItem"
-import { useFider } from "@fider/hooks"
-
-import IconPlusCircle from "@fider/assets/images/heroicons-pluscircle.svg"
-import { HStack, VStack } from "@fider/components/layout"
-import { Trans } from "@lingui/macro"
-import { TagsPanelProps } from "./TagsPanel"
-
-export const TagsPanel2 = (props: TagsPanelProps) => {
- const fider = useFider()
- const canEdit = fider.session.isAuthenticated && fider.session.user.isCollaborator && props.tags.length > 0
-
- const [isEditing, setIsEditing] = useState(false)
- const [assignedTags, setAssignedTags] = useState(props.tags.filter((t) => props.post.tags.indexOf(t.slug) >= 0))
-
- const assignOrUnassignTag = async (tag: Tag) => {
- const idx = assignedTags.indexOf(tag)
- let nextAssignedTags: Tag[] = []
-
- if (idx >= 0) {
- const response = await actions.unassignTag(tag.slug, props.post.number)
- if (response.ok) {
- nextAssignedTags = [...assignedTags]
- nextAssignedTags.splice(idx, 1)
- }
- } else {
- const response = await actions.assignTag(tag.slug, props.post.number)
- if (response.ok) {
- nextAssignedTags = [...assignedTags, tag]
- }
- }
-
- setAssignedTags(nextAssignedTags)
- }
-
- const onSubtitleClick = () => {
- if (canEdit) {
- setIsEditing(!isEditing)
- }
- }
-
- if (!canEdit && assignedTags.length === 0) {
- return null
- }
-
- const tagsList = (
- <HStack spacing={2} center={true}>
- {assignedTags.length > 0 && assignedTags.map((tag) => <ShowTag key={tag.id} tag={tag} link />)}
- <HStack spacing={1} center={true} className="clickable" onClick={onSubtitleClick}>
- <Icon sprite={IconPlusCircle} className="h-5 text-primary" />
-
- {assignedTags.length === 0 && (
- <span>
- <Trans id="label.tags">Tags</Trans>
- </span>
- )}
- </HStack>
- </HStack>
- )
-
- const editTagsList = props.tags.length > 0 && (
- <VStack justify="between" className="flex-items-start">
- {props.tags.map((tag) => (
- <TagListItem key={tag.id} tag={tag} assigned={assignedTags.indexOf(tag) >= 0} onClick={assignOrUnassignTag} />
- ))}
- <Button variant="secondary" size="small" onClick={onSubtitleClick}>
- <Trans id="action.close">Close</Trans>
- </Button>
- </VStack>
- )
-
- if (fider.isReadOnly) {
- return (
- <VStack>
- <HStack spacing={2} className="text-category">
- <Trans id="label.tags">Tags</Trans>
- </HStack>
- {tagsList}
- </VStack>
- )
- }
-
- return (
- <VStack>
- <HStack spacing={2} center={true} className="text-primary-base text-xs">
- {!isEditing && tagsList}
- {isEditing && editTagsList}
- </HStack>
- </VStack>
- )
-}