@use "../../../styles/abstracts/functions" as fun;
@use "../../../styles/abstracts/placeholders";
.wrapper {
.list {
@extend %flex-list;
align-items: stretch;
justify-content: center;
position: relative;
row-gap: var(--spacing-xs);
column-gap: var(--spacing-sm);
&--pages {
column-gap: var(--spacing-2xs);
margin-bottom: var(--spacing-sm);
}
}
.link {
height: 100%;
min-width: 5ch;
min-height: 6ex;
position: relative;
&:not(&--disabled) {
&:hover,
&:focus {
z-index: 3;
}
}
&--number {
padding: 0;
}
&--disabled {
display: flex;
place-content: center;
align-items: center;
background: var(--color-bg);
border: fun.convert-px(3) solid var(--color-primary-darker);
border-radius: fun.convert-px(5);
color: var(--color-primary-darker);
font-size: var(--font-size-md);
font-weight: 600;
text-decoration: underline transparent 0;
transform: scale(var(--scale-down, 0.94));
}
}
}
option value='main'>main
blob: 1e7c3e7a598a030e888d22da83e7cb487b0608a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
import Comment from '@components/Comment/Comment';
import Spinner from '@components/Spinner/Spinner';
import { getCommentsByPostId } from '@services/graphql/queries';
import { Comment as CommentData } from '@ts/types/comments';
import { useIntl } from 'react-intl';
import useSWR from 'swr';
import styles from './CommentsList.module.scss';
const CommentsList = ({
articleId,
comments,
}: {
articleId: number;
comments: CommentData[];
}) => {
const intl = useIntl();
const { data, error } = useSWR<CommentData[]>(
'/api/comments',
() => getCommentsByPostId(articleId),
{ fallbackData: comments }
);
const getCommentsList = () => {
if (error) {
return intl.formatMessage({
defaultMessage: 'Failed to load.',
description: 'CommentsList: failed to load',
});
}
if (!data) return <Spinner />;
return data.map((comment) => {
return (
<Comment
key={comment.commentId}
articleId={articleId}
comment={comment}
/>
);
});
};
return (
<>
<h2 className={styles.title}>
{intl.formatMessage({
defaultMessage: 'Comments',
description: 'CommentsList: Comments section title',
})}
</h2>
{data && data.length > 0 ? (
<ol className={styles.list}>{getCommentsList()}</ol>
) : (
<p className={styles['no-comments']}>
{intl.formatMessage({
defaultMessage: 'No comments yet.',
description: 'CommentsList: No comment message',
})}
</p>
)}
</>
);
};
export default CommentsList;
|