mirror of
https://github.com/wassname/talk.git
synced 2026-07-29 11:28:24 +08:00
First round styling
This commit is contained in:
@@ -1,11 +1,41 @@
|
||||
.Reply {
|
||||
position: relative;
|
||||
.root {
|
||||
margin-top: 16px;
|
||||
margin-left: 20px;
|
||||
margin-bottom: 15px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.Comment {
|
||||
margin-bottom: 15px;
|
||||
position: relative;
|
||||
.rootLevel0 {
|
||||
margin-left: 0px;
|
||||
}
|
||||
|
||||
.comment {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.commentLevel0 {
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
.commentLevel1 {
|
||||
border-left: 3px #212121 solid;
|
||||
}
|
||||
|
||||
.commentLevel2 {
|
||||
border-left: 2px #6a6a6a solid;
|
||||
}
|
||||
|
||||
.commentLevel3 {
|
||||
border-left: 2px #9e9e9e solid;
|
||||
}
|
||||
|
||||
.commentLevel4 {
|
||||
border-left: 2px #c1c1c1 solid;
|
||||
}
|
||||
|
||||
.highlightedComment {
|
||||
padding-left: 20px;
|
||||
border-left: 3px solid rgb(35,118,216);
|
||||
}
|
||||
|
||||
.pendingComment {
|
||||
|
||||
@@ -10,6 +10,8 @@ import {TransitionGroup} from 'react-transition-group';
|
||||
import cn from 'classnames';
|
||||
import styles from './Comment.css';
|
||||
import {THREADING_LEVEL} from '../constants/stream';
|
||||
import merge from 'lodash/merge';
|
||||
import mapValues from 'lodash/mapValues';
|
||||
|
||||
import {
|
||||
BestButton,
|
||||
@@ -333,9 +335,12 @@ export default class Comment extends React.Component {
|
||||
|
||||
const view = this.getVisibileReplies();
|
||||
const {loadingState} = this.state;
|
||||
const isReply = !!parentId;
|
||||
const isPending = comment.id.indexOf('pending') >= 0;
|
||||
const isHighlighted = highlighted === comment.id;
|
||||
|
||||
const hasMoreComments = comment.replies && (comment.replies.hasNextPage || comment.replies.nodes.length > view.length);
|
||||
const replyCount = this.hasIgnoredReplies() ? '' : comment.replyCount;
|
||||
const moreRepliesCount = this.hasIgnoredReplies() ? -1 : comment.replyCount - view.length;
|
||||
const flagSummary = getActionSummary('FlagActionSummary', comment);
|
||||
const dontAgreeSummary = getActionSummary(
|
||||
'DontAgreeActionSummary',
|
||||
@@ -348,11 +353,6 @@ export default class Comment extends React.Component {
|
||||
myFlag = dontAgreeSummary.find((s) => s.current_user);
|
||||
}
|
||||
|
||||
let commentClass = parentId
|
||||
? `reply ${styles.Reply}`
|
||||
: `comment ${styles.Comment}`;
|
||||
commentClass += comment.id.indexOf('pending') >= 0 ? ` ${styles.pendingComment}` : '';
|
||||
|
||||
// call a function, and if it errors, call addNotification('error', ...) (e.g. to show user a snackbar)
|
||||
const notifyOnError = (fn, errorToMessage) =>
|
||||
async function(...args) {
|
||||
@@ -388,7 +388,7 @@ export default class Comment extends React.Component {
|
||||
);
|
||||
|
||||
/**
|
||||
* classNamesToAdd
|
||||
* conditionClassNames
|
||||
* adds classNames based on condition
|
||||
* classnames is an array of objects with key as classnames and value as conditions
|
||||
* i.e:
|
||||
@@ -398,34 +398,43 @@ export default class Comment extends React.Component {
|
||||
*
|
||||
* This will add myClassName to comments tagged with STAFF TAG.
|
||||
* **/
|
||||
|
||||
const classNamesToAdd = commentClassNames.reduce((acc, className) => {
|
||||
let res = [];
|
||||
|
||||
// Adding classNames based on tags
|
||||
Object.keys(className).forEach((cn) => {
|
||||
const condition = className[cn];
|
||||
condition.tags.forEach((tag) => {
|
||||
if (hasTag(comment.tags, tag)) {
|
||||
res = [...res, cn];
|
||||
}
|
||||
});
|
||||
const conditionalClassNames =
|
||||
mapValues(merge({}, ...commentClassNames), (condition) => {
|
||||
if (condition.tags) {
|
||||
return condition.tags.some((tag) => hasTag(comment.tags, tag));
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// TODO: Compare rest of the comment obj to the condition if needed
|
||||
|
||||
return [...acc, ...res];
|
||||
}, []);
|
||||
const rootClassNames = [
|
||||
'talk-stream-comment-wrapper',
|
||||
`talk-stream-comment-wrapper-level-${depth}`,
|
||||
styles.root,
|
||||
styles[`rootLevel${depth}`],
|
||||
{
|
||||
...conditionalClassNames,
|
||||
[styles.enter]: this.state.animateEnter,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(commentClass, 'talk-stream-comment-wrapper', classNamesToAdd, {[styles.enter]: this.state.animateEnter})}
|
||||
className={cn(...rootClassNames)}
|
||||
id={`c_${comment.id}`}
|
||||
style={{marginLeft: depth * 30}}
|
||||
>
|
||||
<hr aria-hidden={true} />
|
||||
{!isReply && <hr aria-hidden={true} />}
|
||||
<div
|
||||
className={highlighted === comment.id ? 'highlighted-comment' : ''}
|
||||
className={cn(
|
||||
'talk-stream-comment',
|
||||
`talk-stream-comment-level-${depth}`,
|
||||
styles.comment,
|
||||
styles[`commentLevel${depth}`],
|
||||
{
|
||||
[styles.pendingComment]: isPending,
|
||||
[styles.highlightedComment]: isHighlighted,
|
||||
'talk-stream-highlighted-comment': isHighlighted,
|
||||
}
|
||||
)}
|
||||
>
|
||||
<AuthorName author={comment.user} className={'talk-stream-comment-user-name'} />
|
||||
{isStaff(comment.tags) ? <TagLabel>Staff</TagLabel> : null}
|
||||
@@ -601,7 +610,7 @@ export default class Comment extends React.Component {
|
||||
<div className="talk-load-more-replies">
|
||||
<LoadMore
|
||||
topLevel={false}
|
||||
replyCount={replyCount}
|
||||
replyCount={moreRepliesCount}
|
||||
moreComments={hasMoreComments}
|
||||
loadMore={this.loadNewReplies}
|
||||
loadingState={loadingState}
|
||||
|
||||
@@ -5,27 +5,15 @@ import t from 'coral-framework/services/i18n';
|
||||
import cn from 'classnames';
|
||||
|
||||
class LoadMore extends React.Component {
|
||||
initialState = true;
|
||||
|
||||
replyCountFormat = (count) => {
|
||||
if (!count) {
|
||||
return t('framework.view_all_replies_unknown_number');
|
||||
return t('framework.show_all_replies');
|
||||
}
|
||||
if (count === 1) {
|
||||
return t('framework.view_reply');
|
||||
return t('framework.show_1_more_reply');
|
||||
}
|
||||
|
||||
if (this.initialState) {
|
||||
return t('framework.view_all_replies_initial', count);
|
||||
} else {
|
||||
return t('framework.view_all_replies', count);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (['success', 'error'].indexOf(nextProps.loadingState) >= 0) {
|
||||
this.initialState = false;
|
||||
}
|
||||
return t('framework.show_x_more_replies', count);
|
||||
}
|
||||
|
||||
render () {
|
||||
|
||||
@@ -3,7 +3,7 @@ import React, {PropTypes} from 'react';
|
||||
import t from 'coral-framework/services/i18n';
|
||||
|
||||
const NewCount = ({count, loadMore}) => {
|
||||
return <div className='coral-new-comments coral-load-more'>
|
||||
return <div className='talk-new-comments talk-load-more'>
|
||||
{
|
||||
count ?
|
||||
<button onClick={loadMore}>
|
||||
|
||||
@@ -26,7 +26,7 @@ body {
|
||||
}
|
||||
|
||||
button {
|
||||
margin: 5px 10px 5px 0px;
|
||||
margin: 5px 0px 5px 0px;
|
||||
background: none;
|
||||
padding: 0px;
|
||||
border: none;
|
||||
@@ -266,11 +266,6 @@ hr {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.highlighted-comment {
|
||||
padding-left: 10px;
|
||||
border-left: 3px solid rgb(35,118,216);
|
||||
}
|
||||
|
||||
/* Tag Labels */
|
||||
|
||||
.coral-plugin-tag-label {
|
||||
@@ -282,26 +277,16 @@ hr {
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Reply styles */
|
||||
|
||||
.comment .reply {
|
||||
margin: 0px 0px 10px 20px;
|
||||
}
|
||||
|
||||
/* Comment Action Styles */
|
||||
|
||||
.commentActionsRight, .replyActionsRight {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
width: 30%;
|
||||
}
|
||||
.commentActionsLeft, .replyActionsLeft {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
float: left;
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
.comment__action-container .material-icons {
|
||||
@@ -422,9 +407,11 @@ button.comment__action-button[disabled],
|
||||
}
|
||||
|
||||
.talk-load-more button {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
color: #FFF;
|
||||
background-color: #2376D8;
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
padding: 10px;
|
||||
border-radius: 2px;
|
||||
@@ -437,23 +424,42 @@ button.comment__action-button[disabled],
|
||||
background-color: #4399FF;
|
||||
}
|
||||
|
||||
.talk-load-more-replies, .coral-new-comments {
|
||||
.talk-new-comments {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.coral-new-comments {
|
||||
.talk-load-more-replies {
|
||||
width: 100%;
|
||||
padding-left: 20px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.talk-new-comments {
|
||||
position: relative;
|
||||
top: 1.8em;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.talk-load-more-replies button.talk-load-more, .coral-new-comments button.talk-load-more{
|
||||
.talk-load-more-replies .talk-load-more-button {
|
||||
background-color: transparent;
|
||||
color: #979797;
|
||||
border: #979797 solid 1px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.talk-load-more-replies .talk-load-more-button:hover {
|
||||
background-color: #979797;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.talk-new-comments button.talk-load-more{
|
||||
width: initial;
|
||||
}
|
||||
|
||||
|
||||
@media (min-device-width : 300px) and (max-device-width : 420px) {
|
||||
.commentActionsLeft.comment__action-container .coral-plugin-replies-reply-button {
|
||||
visibility: collapse;
|
||||
|
||||
@@ -5,6 +5,8 @@ import {can} from 'coral-framework/services/perms';
|
||||
|
||||
import {PopupMenu, Button} from 'coral-ui';
|
||||
import ClickOutside from 'coral-framework/components/ClickOutside';
|
||||
import cn from 'classnames';
|
||||
import styles from './styles.css';
|
||||
|
||||
const name = 'coral-plugin-flags';
|
||||
|
||||
@@ -146,14 +148,17 @@ export default class FlagButton extends Component {
|
||||
<button
|
||||
ref={(ref) => this.flagButton = ref}
|
||||
onClick={!this.props.banned && !flaggedByCurrentUser && !localPost ? this.onReportClick : null}
|
||||
className={`${name}-button`}>
|
||||
className={cn(`${name}-button`, styles.button)}>
|
||||
{
|
||||
flagged
|
||||
? <span className={`${name}-button-text`}>{t('reported')}</span>
|
||||
: <span className={`${name}-button-text`}>{t('report')}</span>
|
||||
}
|
||||
<i className={`${name}-icon material-icons ${flagged && 'flaggedIcon'}`}
|
||||
style={flagged ? styles.flaggedIcon : {}}
|
||||
<i className={
|
||||
cn(`${name}-icon`, 'material-icons', {
|
||||
flaggedIcon: flagged,
|
||||
[styles.flaggedIcon]: flagged,
|
||||
})}
|
||||
aria-hidden={true}>flag</i>
|
||||
</button>
|
||||
{
|
||||
@@ -214,12 +219,3 @@ export default class FlagButton extends Component {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = {
|
||||
flaggedIcon: {
|
||||
color: '#F00'
|
||||
},
|
||||
unflaggedIcon: {
|
||||
color: 'inherit'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
.button {
|
||||
margin: 5px 0px 5px 10px;
|
||||
}
|
||||
|
||||
.flaggedIcon {
|
||||
color: #f00
|
||||
}
|
||||
+3
-3
@@ -235,9 +235,9 @@ en:
|
||||
success_bio_update: "Your biography has been updated"
|
||||
success_name_update: "Your username has been updated"
|
||||
success_update_settings: "The changes you have made have been applied to the comment stream on this article"
|
||||
view_all_replies_unknown_number: "view all replies"
|
||||
view_all_replies: "view {0} replies"
|
||||
view_all_replies_initial: "view all {0} replies"
|
||||
show_all_replies: Show all replies
|
||||
show_1_more_reply: Show 1 more reply
|
||||
show_x_more_replies: Show {0} more replies
|
||||
view_more_comments: "view more comments"
|
||||
view_reply: "view reply"
|
||||
from_settings_page: "From the Profile Page you can see your comment history."
|
||||
|
||||
+3
-3
@@ -232,9 +232,9 @@ es:
|
||||
success_bio_update: "Tu biografia fue actualizada"
|
||||
success_name_update: "Tu nombre de usuario ha sido actualizado"
|
||||
success_update_settings: "La configuración de este articulo fue actualizada"
|
||||
view_all_replies_unknown_number: "ver todas las respuestas"
|
||||
view_all_replies: "ver {0} respuestas"
|
||||
view_all_replies_initial: "ver todas las {0} respuestas"
|
||||
show_all_replies: "Mostrar todas las respuestas"
|
||||
show_1_more_reply: "Mostrar 1 respuesta más"
|
||||
show_x_more_replies: "Mostrar {0} respuestas más"
|
||||
view_more_comments: "Ver más comentarios"
|
||||
view_reply: "ver respuesta"
|
||||
from_settings_page: "Desde la página de configuración puedes ver tu historia de comentarios."
|
||||
|
||||
@@ -66,11 +66,11 @@ export default class PermalinkButton extends React.Component {
|
||||
return (
|
||||
<ClickOutside onClickOutside={this.handleClickOutside}>
|
||||
<div className={cn(`${name}-container`, styles.container)}>
|
||||
|
||||
|
||||
<button
|
||||
ref={(ref) => this.linkButton = ref}
|
||||
onClick={this.toggle}
|
||||
className={`${name}-button`}>
|
||||
className={cn(`${name}-button`, styles.button)}>
|
||||
{t('permalink')}
|
||||
<Icon name="link" />
|
||||
</button>
|
||||
@@ -89,7 +89,7 @@ export default class PermalinkButton extends React.Component {
|
||||
<Button
|
||||
onClick={this.copyPermalink}
|
||||
className={cn([
|
||||
styles.button,
|
||||
styles.copyButton,
|
||||
`${name}-copy-button`, {
|
||||
[styles.success]:copySuccessful,
|
||||
[styles.failure]: copyFailure
|
||||
@@ -98,7 +98,7 @@ export default class PermalinkButton extends React.Component {
|
||||
{copySuccessful && 'Copied'}
|
||||
{copyFailure && 'Not supported'}
|
||||
</Button>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</ClickOutside>
|
||||
|
||||
@@ -42,7 +42,13 @@
|
||||
}
|
||||
|
||||
.button {
|
||||
margin: 5px 0px 5px 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.copyButton {
|
||||
display: inline-block;
|
||||
margin: 5px 10px 5px 0px;
|
||||
float: right;
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
@@ -52,18 +58,19 @@
|
||||
height: auto;
|
||||
padding: 2px;
|
||||
transition: background-color 0.4s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.button:hover{
|
||||
.copyButton:hover{
|
||||
color: black;
|
||||
}
|
||||
|
||||
.button.success {
|
||||
.copyButton.success {
|
||||
background-color: #00897B;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.button.failure {
|
||||
.copyButton.failure {
|
||||
background-color: #FF5252;
|
||||
color: white;
|
||||
}
|
||||
@@ -74,4 +81,4 @@
|
||||
|
||||
.active {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user