mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-10-01 01:36:12 -04:00
Updates to PR as requested
This commit is contained in:
parent
1b351e08aa
commit
8fe8836bc2
21
ui/src/components/cake-day.tsx
vendored
21
ui/src/components/cake-day.tsx
vendored
@ -1,37 +1,26 @@
|
|||||||
import { Component } from 'inferno';
|
import { Component } from 'inferno';
|
||||||
import moment from 'moment';
|
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
||||||
interface CakeDayProps {
|
interface CakeDayProps {
|
||||||
creator_name: string;
|
creator_name: string;
|
||||||
creator_published: string;
|
is_post_creator?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CakeDay extends Component<CakeDayProps, any> {
|
export class CakeDay extends Component<CakeDayProps, any> {
|
||||||
render() {
|
render() {
|
||||||
const { creator_name, creator_published } = this.props;
|
const { creator_name, is_post_creator } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
this.isCakeDay(creator_published) && (
|
|
||||||
<div
|
<div
|
||||||
className="mr-lg-2 d-inline-block unselectable pointer mx-2"
|
className={`mr-lg-2 d-inline-block unselectable pointer${
|
||||||
|
is_post_creator ? ' mx-2' : ''
|
||||||
|
}`}
|
||||||
data-tippy-content={this.cakeDayTippy(creator_name)}
|
data-tippy-content={this.cakeDayTippy(creator_name)}
|
||||||
>
|
>
|
||||||
<svg class="icon icon-inline">
|
<svg class="icon icon-inline">
|
||||||
<use xlinkHref="#icon-cake"></use>
|
<use xlinkHref="#icon-cake"></use>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
isCakeDay(input: string): boolean {
|
|
||||||
const userCreationDate = moment.utc(input).local();
|
|
||||||
const currentDate = moment(new Date());
|
|
||||||
|
|
||||||
return (
|
|
||||||
userCreationDate.date() === currentDate.date() &&
|
|
||||||
userCreationDate.month() === currentDate.month()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
ui/src/components/comment-node.tsx
vendored
9
ui/src/components/comment-node.tsx
vendored
@ -26,6 +26,7 @@ import {
|
|||||||
isMod,
|
isMod,
|
||||||
setupTippy,
|
setupTippy,
|
||||||
colorList,
|
colorList,
|
||||||
|
isCakeDay,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { MomentTime } from './moment-time';
|
import { MomentTime } from './moment-time';
|
||||||
@ -126,7 +127,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
let node = this.props.node;
|
let node = this.props.node;
|
||||||
const { creator_name, creator_published } = node.comment;
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`comment ${
|
className={`comment ${
|
||||||
@ -164,10 +164,9 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<CakeDay
|
{isCakeDay(node.comment.creator_published) && (
|
||||||
creator_name={creator_name}
|
<CakeDay creator_name={node.comment.creator_name} />
|
||||||
creator_published={creator_published}
|
)}
|
||||||
/>
|
|
||||||
|
|
||||||
{this.isMod && (
|
{this.isMod && (
|
||||||
<div className="badge badge-light d-none d-sm-inline mr-2">
|
<div className="badge badge-light d-none d-sm-inline mr-2">
|
||||||
|
10
ui/src/components/post-listing.tsx
vendored
10
ui/src/components/post-listing.tsx
vendored
@ -33,6 +33,7 @@ import {
|
|||||||
setupTippy,
|
setupTippy,
|
||||||
hostname,
|
hostname,
|
||||||
previewLines,
|
previewLines,
|
||||||
|
isCakeDay,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
import { CakeDay } from './cake-day';
|
import { CakeDay } from './cake-day';
|
||||||
@ -258,8 +259,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
|||||||
|
|
||||||
listing() {
|
listing() {
|
||||||
let post = this.props.post;
|
let post = this.props.post;
|
||||||
const { creator_name, creator_published } = post;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div className={`vote-bar col-1 pr-0 small text-center`}>
|
<div className={`vote-bar col-1 pr-0 small text-center`}>
|
||||||
@ -440,10 +439,9 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<CakeDay
|
{isCakeDay(post.creator_published) && (
|
||||||
creator_name={creator_name}
|
<CakeDay creator_name={post.creator_name} is_post_creator />
|
||||||
creator_published={creator_published}
|
)}
|
||||||
/>
|
|
||||||
|
|
||||||
{this.isMod && (
|
{this.isMod && (
|
||||||
<span className="mx-1 badge badge-light">
|
<span className="mx-1 badge badge-light">
|
||||||
|
11
ui/src/utils.ts
vendored
11
ui/src/utils.ts
vendored
@ -53,6 +53,7 @@ import emojiShortName from 'emoji-short-name';
|
|||||||
import Toastify from 'toastify-js';
|
import Toastify from 'toastify-js';
|
||||||
import tippy from 'tippy.js';
|
import tippy from 'tippy.js';
|
||||||
import EmojiButton from '@joeattardi/emoji-button';
|
import EmojiButton from '@joeattardi/emoji-button';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
export const repoUrl = 'https://github.com/LemmyNet/lemmy';
|
export const repoUrl = 'https://github.com/LemmyNet/lemmy';
|
||||||
export const helpGuideUrl = '/docs/about_guide.html';
|
export const helpGuideUrl = '/docs/about_guide.html';
|
||||||
@ -489,6 +490,16 @@ export function showAvatars(): boolean {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isCakeDay(creator_published: string): boolean {
|
||||||
|
const userCreationDate = moment.utc(creator_published).local();
|
||||||
|
const currentDate = moment(new Date());
|
||||||
|
|
||||||
|
return (
|
||||||
|
userCreationDate.date() === currentDate.date() &&
|
||||||
|
userCreationDate.month() === currentDate.month()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Converts to image thumbnail
|
// Converts to image thumbnail
|
||||||
export function pictrsImage(hash: string, thumbnail: boolean = false): string {
|
export function pictrsImage(hash: string, thumbnail: boolean = false): string {
|
||||||
let root = `/pictrs/image`;
|
let root = `/pictrs/image`;
|
||||||
|
Loading…
Reference in New Issue
Block a user