mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
Improve style pt. 4 (post and comments)
This commit is contained in:
@@ -141,7 +141,7 @@ class NewPost extends React.Component<Props, State> {
|
|||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="newBoardContainer sidebarBox">
|
<div className="newBoardContainer sidebarCard">
|
||||||
<span className="boardTitle">{board.name}</span>
|
<span className="boardTitle">{board.name}</span>
|
||||||
<p><MutedText>{board.description}</MutedText></p>
|
<p><MutedText>{board.description}</MutedText></p>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const PostStatusFilter = ({
|
|||||||
handleFilterClick,
|
handleFilterClick,
|
||||||
currentFilter,
|
currentFilter,
|
||||||
}: Props) => (
|
}: Props) => (
|
||||||
<div className="postStatusFilterContainer sidebarBox">
|
<div className="postStatusFilterContainer sidebarCard">
|
||||||
<TitleText>Filter by post status:</TitleText>
|
<TitleText>Filter by post status:</TitleText>
|
||||||
{
|
{
|
||||||
postStatuses.map((postStatus, i) => (
|
postStatuses.map((postStatus, i) => (
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SearchFilter = ({ searchQuery, handleChange }: Props) => (
|
const SearchFilter = ({ searchQuery, handleChange }: Props) => (
|
||||||
<div className="sidebarBox">
|
<div className="sidebarCard">
|
||||||
<TitleText>Search:</TitleText>
|
<TitleText>Search:</TitleText>
|
||||||
<input
|
<input
|
||||||
type="search"
|
type="search"
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import { MutedText } from '../shared/CustomTexts';
|
|||||||
|
|
||||||
import { CommentRepliesState } from '../../reducers/commentRepliesReducer';
|
import { CommentRepliesState } from '../../reducers/commentRepliesReducer';
|
||||||
|
|
||||||
|
import friendlyDate from '../../helpers/friendlyDate';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
id: number;
|
id: number;
|
||||||
body: string;
|
body: string;
|
||||||
@@ -39,8 +41,11 @@ const Comment = ({
|
|||||||
</div>
|
</div>
|
||||||
<p className="commentBody">{body}</p>
|
<p className="commentBody">{body}</p>
|
||||||
<div className="commentFooter">
|
<div className="commentFooter">
|
||||||
<a className="commentReplyButton" onClick={handleToggleCommentReply}>Reply</a>
|
<a className="commentReplyButton" onClick={handleToggleCommentReply}>
|
||||||
<MutedText>{updatedAt}</MutedText>
|
{ reply.isOpen ? 'Cancel' : 'Reply' }
|
||||||
|
</a>
|
||||||
|
•
|
||||||
|
<MutedText>{friendlyDate(updatedAt)}</MutedText>
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
reply.isOpen ?
|
reply.isOpen ?
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { FormEvent } from 'react';
|
|||||||
import NewComment from './NewComment';
|
import NewComment from './NewComment';
|
||||||
import CommentList from './CommentList';
|
import CommentList from './CommentList';
|
||||||
import Spinner from '../shared/Spinner';
|
import Spinner from '../shared/Spinner';
|
||||||
import { DangerText } from '../shared/CustomTexts';
|
import { DangerText, UppercaseText } from '../shared/CustomTexts';
|
||||||
|
|
||||||
import IComment from '../../interfaces/IComment';
|
import IComment from '../../interfaces/IComment';
|
||||||
import { CommentRepliesState } from '../../reducers/commentRepliesReducer';
|
import { CommentRepliesState } from '../../reducers/commentRepliesReducer';
|
||||||
@@ -56,9 +56,7 @@ class CommentsP extends React.Component<Props> {
|
|||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="comments">
|
<div className="commentsContainer">
|
||||||
<h2>Comments</h2>
|
|
||||||
|
|
||||||
<NewComment
|
<NewComment
|
||||||
body={replies.find(reply => reply.commentId === -1) && replies.find(reply => reply.commentId === -1).body}
|
body={replies.find(reply => reply.commentId === -1) && replies.find(reply => reply.commentId === -1).body}
|
||||||
parentId={null}
|
parentId={null}
|
||||||
@@ -73,6 +71,10 @@ class CommentsP extends React.Component<Props> {
|
|||||||
{ areLoading ? <Spinner /> : null }
|
{ areLoading ? <Spinner /> : null }
|
||||||
{ error ? <DangerText>{error}</DangerText> : null }
|
{ error ? <DangerText>{error}</DangerText> : null }
|
||||||
|
|
||||||
|
<span className="commentsTitle">
|
||||||
|
activity • {comments.length} comments
|
||||||
|
</span>
|
||||||
|
|
||||||
<CommentList
|
<CommentList
|
||||||
comments={comments}
|
comments={comments}
|
||||||
replies={replies}
|
replies={replies}
|
||||||
|
|||||||
@@ -20,9 +20,14 @@ const NewComment = ({
|
|||||||
<textarea
|
<textarea
|
||||||
value={body}
|
value={body}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
placeholder="Leave a comment"
|
||||||
className="newCommentBody"
|
className="newCommentBody"
|
||||||
/>
|
/>
|
||||||
<Button onClick={() => handleSubmit(body, parentId)}>Submit</Button>
|
<Button
|
||||||
|
onClick={() => handleSubmit(body, parentId)}
|
||||||
|
className="submitCommentButton">
|
||||||
|
Submit
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import IPostStatus from '../../interfaces/IPostStatus';
|
|||||||
import PostStatusSelect from './PostStatusSelect';
|
import PostStatusSelect from './PostStatusSelect';
|
||||||
import PostStatusLabel from '../shared/PostStatusLabel';
|
import PostStatusLabel from '../shared/PostStatusLabel';
|
||||||
import Comments from '../../containers/Comments';
|
import Comments from '../../containers/Comments';
|
||||||
|
import { MutedText } from '../shared/CustomTexts';
|
||||||
|
|
||||||
|
import friendlyDate from '../../helpers/friendlyDate';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
postId: number;
|
postId: number;
|
||||||
@@ -40,7 +43,15 @@ class PostP extends React.Component<Props> {
|
|||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="pageContainer">
|
||||||
|
<div className="sidebar">
|
||||||
|
<div className="sidebarCard"></div>
|
||||||
|
<div className="sidebarCard"></div>
|
||||||
|
<div className="sidebarCard"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="postAndCommentsContainer">
|
||||||
|
<div className="postContainer">
|
||||||
<h2>{post.title}</h2>
|
<h2>{post.title}</h2>
|
||||||
{
|
{
|
||||||
isPowerUser && post ?
|
isPowerUser && post ?
|
||||||
@@ -56,14 +67,16 @@ class PostP extends React.Component<Props> {
|
|||||||
{...postStatuses.find(postStatus => postStatus.id === post.postStatusId)}
|
{...postStatuses.find(postStatus => postStatus.id === post.postStatusId)}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
<p className="postDescription">{post.description}</p>
|
||||||
<p>{post.description}</p>
|
<MutedText>{friendlyDate(post.createdAt)}</MutedText>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Comments
|
<Comments
|
||||||
postId={this.props.postId}
|
postId={this.props.postId}
|
||||||
authenticityToken={authenticityToken}
|
authenticityToken={authenticityToken}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import Post from '../../containers/Post';
|
|||||||
|
|
||||||
import IPostStatus from '../../interfaces/IPostStatus';
|
import IPostStatus from '../../interfaces/IPostStatus';
|
||||||
|
|
||||||
import '../../stylesheets/components/Post.scss';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
postId: number;
|
postId: number;
|
||||||
postStatuses: Array<IPostStatus>;
|
postStatuses: Array<IPostStatus>;
|
||||||
|
|||||||
33
app/javascript/helpers/friendlyDate.js
Normal file
33
app/javascript/helpers/friendlyDate.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
const friendlyDate = date => {
|
||||||
|
var now = new Date();
|
||||||
|
var timeStamp = fromRailsStringToJavascriptDate(date);
|
||||||
|
|
||||||
|
var secondsPast = (now.getTime() - timeStamp.getTime()) / 1000;
|
||||||
|
|
||||||
|
if (secondsPast < 60) {
|
||||||
|
secondsPast = parseInt(secondsPast);
|
||||||
|
return secondsPast + ' ' + (secondsPast === 1 ? 'second' : 'seconds') + ' ago';
|
||||||
|
} else if (secondsPast < 3600) {
|
||||||
|
let minutesPast = parseInt(secondsPast / 60);
|
||||||
|
return minutesPast + ' ' + (minutesPast === 1 ? 'minute' : 'minutes') + ' ago';
|
||||||
|
} else if (secondsPast <= 86400) {
|
||||||
|
let hoursPast = parseInt(secondsPast / 3600);
|
||||||
|
return hoursPast + ' ' + (hoursPast === 1 ? 'hour' : 'hours') + ' ago';
|
||||||
|
} else {
|
||||||
|
let daysPast = parseInt(secondsPast / 86400);
|
||||||
|
return daysPast + ' ' + (daysPast === 1 ? 'day' : 'days') + ' ago';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default friendlyDate;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Converts the default Rails datetime string
|
||||||
|
format to a JavaScript Date object.
|
||||||
|
*/
|
||||||
|
const fromRailsStringToJavascriptDate = date => {
|
||||||
|
let dateOnly = date.slice(0, 10);
|
||||||
|
let timeOnly = date.slice(11, 19);
|
||||||
|
|
||||||
|
return new Date(`${dateOnly}T${timeOnly}Z`);
|
||||||
|
}
|
||||||
@@ -6,27 +6,9 @@
|
|||||||
|
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|
||||||
.sidebar {
|
|
||||||
position: sticky;
|
|
||||||
top: 60px;
|
|
||||||
|
|
||||||
.sidebarBox {
|
|
||||||
width: 250px;
|
|
||||||
margin-right: 16px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@include media-breakpoint-down(sm) {
|
@include media-breakpoint-down(sm) {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
.sidebar {
|
|
||||||
position: relative;
|
|
||||||
width: 100%;
|
|
||||||
top: 0;
|
|
||||||
|
|
||||||
.sidebarBox { width: 100%; }
|
|
||||||
}
|
|
||||||
|
|
||||||
.postStatusFilterContainer {
|
.postStatusFilterContainer {
|
||||||
flex-direction: row !important;
|
flex-direction: row !important;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
@@ -45,19 +27,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebarBox {
|
|
||||||
@extend
|
|
||||||
.card,
|
|
||||||
.d-flex,
|
|
||||||
.flex-column,
|
|
||||||
.justify-content-start,
|
|
||||||
.align-items-center,
|
|
||||||
.flex-grow-0,
|
|
||||||
.flex-shrink-0,
|
|
||||||
.my-3,
|
|
||||||
.p-2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.postStatusListItemContainer {
|
.postStatusListItemContainer {
|
||||||
@extend
|
@extend
|
||||||
.d-flex,
|
.d-flex,
|
||||||
|
|||||||
@@ -1,21 +1,67 @@
|
|||||||
.comments {
|
.commentsContainer {
|
||||||
|
.newCommentForm {
|
||||||
|
@extend
|
||||||
|
.d-flex,
|
||||||
|
.my-3;
|
||||||
|
|
||||||
|
.newCommentBody {
|
||||||
|
@extend
|
||||||
|
.form-control,
|
||||||
|
.w-100,
|
||||||
|
.p-2,
|
||||||
|
.mr-2;
|
||||||
|
|
||||||
|
height: 80px;
|
||||||
|
|
||||||
|
border: thin solid grey;
|
||||||
|
border-radius: 4px;
|
||||||
|
|
||||||
|
resize: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submitCommentButton {
|
||||||
|
@extend
|
||||||
|
.align-self-end;
|
||||||
|
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.commentsTitle {
|
||||||
|
@extend
|
||||||
|
.text-secondary,
|
||||||
|
.text-uppercase,
|
||||||
|
.font-weight-lighter,
|
||||||
|
.my-2;
|
||||||
|
}
|
||||||
|
|
||||||
.commentList > .commentList {
|
.commentList > .commentList {
|
||||||
padding-left: 32px;
|
padding-left: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment {
|
.comment {
|
||||||
margin-bottom: 32px;
|
@extend
|
||||||
|
.my-3;
|
||||||
|
|
||||||
.commentHeader {
|
.commentHeader {
|
||||||
@extend
|
@extend .titleText;
|
||||||
.font-weight-bolder;
|
|
||||||
|
|
||||||
font-size: 17px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.commentBody {
|
.commentBody {
|
||||||
@extend
|
@extend .my-1;
|
||||||
.my-2;
|
}
|
||||||
|
|
||||||
|
.commentFooter {
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
.commentReplyButton {
|
||||||
|
color: #333;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
.pageContainer {
|
||||||
|
@extend
|
||||||
|
.d-flex,
|
||||||
|
.justify-content-between,
|
||||||
|
.align-items-start;
|
||||||
|
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
@include media-breakpoint-down(sm) {
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.postAndCommentsContainer { width: 100%; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.postAndCommentsContainer {
|
||||||
|
@extend
|
||||||
|
.card,
|
||||||
|
.flex-grow-1,
|
||||||
|
.p-3;
|
||||||
|
|
||||||
|
.postDescription {
|
||||||
|
@extend
|
||||||
|
.my-3;
|
||||||
|
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,37 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
position: sticky;
|
||||||
|
top: 60px;
|
||||||
|
|
||||||
|
.sidebarCard {
|
||||||
|
@extend
|
||||||
|
.card,
|
||||||
|
.d-flex,
|
||||||
|
.flex-column,
|
||||||
|
.justify-content-start,
|
||||||
|
.align-items-center,
|
||||||
|
.flex-grow-0,
|
||||||
|
.flex-shrink-0,
|
||||||
|
.my-3,
|
||||||
|
.p-2;
|
||||||
|
|
||||||
|
width: 250px;
|
||||||
|
margin-right: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@include media-breakpoint-down(sm) {
|
||||||
|
.sidebar {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
top: 0;
|
||||||
|
|
||||||
|
.sidebarCard { width: 100%; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.badge {
|
.badge {
|
||||||
@extend
|
@extend
|
||||||
.badge,
|
.badge,
|
||||||
|
|||||||
Reference in New Issue
Block a user