Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CORL 1010] Collapse comment threads (#2976)
* toggle open and closed comment + replies * show username and date for collapsed comment * toggle comments and replies open and closed * keep collapsed state of comments in reply list * style collapsed comment toggle * add css class overrides * style answered comments when collapsed * adjust spacing on collapse button: * add hover styles * add aria labels and update snapshots
- Loading branch information
Showing
43 changed files
with
8,588 additions
and
6,500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/core/client/stream/tabs/Comments/Comment/AnsweredTag.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.answeredTag { | ||
color: #03ab61; | ||
background: #e6faf1; | ||
|
||
border-color: #03ab61; | ||
border-style: solid; | ||
border-radius: 2px; | ||
border-width: 1px; | ||
|
||
text-transform: uppercase; | ||
} | ||
|
||
.tagIcon { | ||
margin-right: var(--v2-spacing-1); | ||
color: var(--v2-colors-green-500); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/core/client/stream/tabs/Comments/Comment/AnsweredTag.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Localized } from "@fluent/react/compat"; | ||
import React, { FunctionComponent } from "react"; | ||
|
||
import { Flex, Icon, Tag } from "coral-ui/components/v2"; | ||
|
||
import styles from "./AnsweredTag.css"; | ||
|
||
interface Props { | ||
collapsed?: boolean; | ||
} | ||
|
||
const AnsweredTag: FunctionComponent<Props> = ({ collapsed }) => { | ||
return collapsed ? ( | ||
<Icon className={styles.tagIcon}>check</Icon> | ||
) : ( | ||
<Tag variant="regular" color="primary" className={styles.answeredTag}> | ||
<Flex alignItems="center"> | ||
<Icon size="xs" className={styles.tagIcon}> | ||
check | ||
</Icon> | ||
<Localized id="qa-answered-tag">answered</Localized> | ||
</Flex> | ||
</Tag> | ||
); | ||
}; | ||
|
||
export default AnsweredTag; |
20 changes: 20 additions & 0 deletions
20
src/core/client/stream/tabs/Comments/Comment/CollapsableComment.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { FunctionComponent, ReactElement, useCallback, useState } from "react"; | ||
|
||
interface InjectedCollapsableCommentProps { | ||
collapsed: boolean; | ||
toggleCollapsed: () => void; | ||
} | ||
|
||
interface Props { | ||
children(props: InjectedCollapsableCommentProps): ReactElement; | ||
} | ||
|
||
const CollapsableComment: FunctionComponent<Props> = ({ children }) => { | ||
const [collapsed, setCollapsed] = useState<boolean>(false); | ||
const toggleCollapsed = useCallback(() => { | ||
setCollapsed(!collapsed); | ||
}, [collapsed]); | ||
return children({ collapsed, toggleCollapsed }); | ||
}; | ||
|
||
export default CollapsableComment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
$commentTimestampColor: var(--v2-colors-grey-500); | ||
|
||
.root { | ||
flex: 1; | ||
} | ||
|
||
.highlight { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/core/client/stream/tabs/Comments/Comment/CommentToggle.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.root { | ||
padding: var(--v2-spacing-2); | ||
width: 100%; | ||
background: var(--v2-colors-grey-100); | ||
|
||
&.mouseHover, | ||
&:hover { | ||
background: var(--v2-colors-grey-200); | ||
} | ||
} | ||
|
||
.icon { | ||
color: var(--v2-colors-grey-500); | ||
} | ||
|
||
.timestamp { | ||
font-family: var(--v2-font-family-primary); | ||
font-style: normal; | ||
font-weight: var(--v2-font-weight-primary-semi-bold); | ||
font-size: var(--v2-font-size-2); | ||
line-height: var(--v2-line-height-3); | ||
color: var(--v2-colors-grey-500); | ||
} | ||
|
||
.inner { | ||
flex: 1; | ||
} |
67 changes: 67 additions & 0 deletions
67
src/core/client/stream/tabs/Comments/Comment/CommentToggle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import cn from "classnames"; | ||
import React, { FunctionComponent } from "react"; | ||
|
||
import CLASSES from "coral-stream/classes"; | ||
import { BaseButton, Flex, Icon, RelativeTime } from "coral-ui/components/v2"; | ||
|
||
import EditedMarker from "./EditedMarker"; | ||
import TopBarLeft from "./TopBarLeft"; | ||
|
||
import styles from "./CommentToggle.css"; | ||
|
||
export interface Props { | ||
className?: string; | ||
username: React.ReactNode; | ||
body: string | null; | ||
createdAt: string; | ||
topBarRight?: React.ReactNode; | ||
footer?: React.ReactNode; | ||
showEditedMarker?: boolean; | ||
highlight?: boolean; | ||
parentAuthorName?: string | null; | ||
userTags?: React.ReactNode; | ||
collapsed?: boolean; | ||
toggleCollapsed?: () => void; | ||
} | ||
|
||
const CommentToggle: FunctionComponent<Props> = (props) => { | ||
return ( | ||
<BaseButton | ||
onClick={props.toggleCollapsed} | ||
className={cn(styles.root, CLASSES.comment.collapseToggle.$root)} | ||
> | ||
<Flex alignItems="center" spacing={1}> | ||
<Icon className={cn(styles.icon, CLASSES.comment.collapseToggle.icon)}> | ||
add | ||
</Icon> | ||
<Flex | ||
direction="row" | ||
justifyContent="space-between" | ||
className={cn(styles.inner, CLASSES.comment.topBar.$root)} | ||
> | ||
<TopBarLeft> | ||
<Flex direction="row" alignItems="center" itemGutter="half"> | ||
{props.username && props.username} | ||
{props.userTags} | ||
</Flex> | ||
<Flex direction="row" alignItems="baseline" itemGutter> | ||
<RelativeTime | ||
className={cn( | ||
styles.timestamp, | ||
CLASSES.comment.topBar.timestamp | ||
)} | ||
date={props.createdAt} | ||
/> | ||
{props.showEditedMarker && ( | ||
<EditedMarker className={CLASSES.comment.topBar.edited} /> | ||
)} | ||
</Flex> | ||
</TopBarLeft> | ||
{props.topBarRight && <div>{props.topBarRight}</div>} | ||
</Flex> | ||
</Flex> | ||
</BaseButton> | ||
); | ||
}; | ||
|
||
export default CommentToggle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.root { | ||
color: var(--v2-colors-stream-blue-500); | ||
} |
Oops, something went wrong.