gatsby-core-theme 44.4.52 → 44.5.0-poc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/.ci.yml +26 -0
  2. package/CHANGELOG.md +30 -126
  3. package/gatsby-browser.js +100 -48
  4. package/gatsby-node.mjs +21 -25
  5. package/package.json +1 -1
  6. package/release.config.js +5 -0
  7. package/src/components/atoms/author/index.js +5 -6
  8. package/src/components/atoms/collapse/collapse.test.js +26 -113
  9. package/src/components/atoms/collapse/index.js +1 -23
  10. package/src/components/molecules/comment/comment.module.scss +57 -7
  11. package/src/components/molecules/comment/index.js +79 -5
  12. package/src/components/molecules/header/variants/operator/template-one-two/index.js +3 -4
  13. package/src/components/molecules/header/variants/operator/template-one-two/template-one-two.stories.js +3 -4
  14. package/src/components/molecules/header/variants/slot/template-one/index.js +3 -4
  15. package/src/components/molecules/header/variants/slot/template-one/template-one.stories.js +3 -4
  16. package/src/components/molecules/leave-comment-form/index.js +0 -1
  17. package/src/components/organisms/anchor/template-one/anchor.module.scss +11 -19
  18. package/src/components/organisms/archive/index.js +2 -5
  19. package/src/components/organisms/comments/comment-tree/index.js +7 -8
  20. package/src/components/organisms/comments/index.js +24 -13
  21. package/src/components/organisms/cookie-consent/index.js +34 -48
  22. package/src/components/organisms/form/fields/fields.module.scss +2 -5
  23. package/src/components/organisms/form/fields/index.js +4 -2
  24. package/src/components/organisms/form/form.module.scss +39 -76
  25. package/src/components/organisms/form/index.js +1 -0
  26. package/src/constants/forms.js +1 -1
  27. package/src/helpers/tracker.mjs +2 -2
  28. package/src/resolver/redirect.mjs +0 -23
  29. package/src/resolver/redirect.test.js +1 -65
  30. package/src/components/atoms/comment-votes/comment-votes.module.scss +0 -34
  31. package/src/components/atoms/comment-votes/index.js +0 -92
  32. package/src/components/organisms/comments/comment-tree/comment-tree.module.scss +0 -47
  33. package/src/context/VotesProvider.js +0 -49
@@ -1,92 +0,0 @@
1
- /* eslint-disable react-hooks/rules-of-hooks */
2
- /* eslint-disable no-console */
3
- /* eslint-disable react-hooks/exhaustive-deps */
4
- /* eslint-disable jsx-a11y/click-events-have-key-events */
5
- /* eslint-disable import/no-extraneous-dependencies */
6
- import React, { useContext } from 'react';
7
- import axios from 'axios';
8
- import PropTypes from 'prop-types';
9
- import LazyImage from '~hooks/lazy-image';
10
- import useTranslate from '~hooks/useTranslate/useTranslate';
11
- import { useVote, VotesContext } from '../../../context/VotesProvider';
12
- import styles from './comment-votes.module.scss';
13
-
14
- const CommentVotes = ({
15
- comment,
16
- voteUpAria = 'Like Button',
17
- voteDownAria = 'Dislike Button'
18
- }) => {
19
- const { updateVote } = useContext(VotesContext);
20
-
21
- const userVote = useVote(comment.comment_id);
22
-
23
- const handleVote = async (like = false, commentId) => {
24
- const data = like
25
- ? {
26
- "vote_up": "increase",
27
- "commentID": commentId
28
- }
29
- : {
30
- "vote_down": "increase",
31
- "commentID": commentId
32
- };
33
-
34
- const headers = {
35
- headers: {
36
- "Content-Type": "application/json",
37
- Accept: "application/json",
38
- },
39
- };
40
-
41
- return new Promise((resolve, reject) => {
42
- axios
43
- .put('/api/put-vote', data, headers)
44
- .then((response) => {
45
- response.ok = response.status === 200;
46
- resolve(response);
47
- })
48
- .catch((error) => reject(error?.response?.data?.errors?.join() || error.message));
49
- });
50
- }
51
-
52
- return <>
53
- <button
54
- onClick={async () => {
55
- updateVote(comment.comment_id, 'vote_up');
56
- await handleVote(true, comment.comment_id)
57
- }}
58
- aria-label={useTranslate('vote_up_aria_label', voteUpAria)}
59
- type='button'
60
- className={`${styles.buttonGroup} ${styles.left} ${userVote === 'vote_down' && styles.disabled || ''}`}
61
- disabled={Boolean(userVote)}
62
- >
63
- <LazyImage className={styles.buttonGroupIcon} src='/images/like.svg' />
64
- <span>{userVote === 'vote_up' ? comment.votes_up + 1 : comment.votes_up}</span>
65
- </button>
66
- <button
67
- onClick={async () => {
68
- updateVote(comment.comment_id, 'vote_down');
69
- await handleVote(false, comment.comment_id)
70
- }}
71
- aria-label={useTranslate('vote_down_aria_label', voteDownAria)}
72
- type='button'
73
- className={`${styles.buttonGroup} ${styles.right} ${userVote === 'vote_up' && styles.disabled || ''}`}
74
- disabled={Boolean(userVote)}
75
- >
76
- <LazyImage className={styles.buttonGroupIcon} src='/images/dislike.svg' />
77
- <span>{userVote === 'vote_down' ? comment.votes_down + 1 : comment.votes_down}</span>
78
- </button>
79
- </>
80
- };
81
-
82
- CommentVotes.propTypes = {
83
- voteUpAria: PropTypes.string,
84
- voteDownAria: PropTypes.string,
85
- comment: PropTypes.shape({
86
- comment_id: PropTypes.string,
87
- votes_up: PropTypes.number,
88
- votes_down: PropTypes.number
89
- })
90
- };
91
-
92
- export default CommentVotes;
@@ -1,47 +0,0 @@
1
- .comment_0{
2
- margin-left: 0;
3
-
4
- >div>div{
5
- z-index: 1;
6
- }
7
- }
8
-
9
- .comment_1{
10
- @include min(tablet){
11
- margin-left: 5.6rem;
12
- }
13
-
14
- margin-left: 2.4rem;
15
- }
16
-
17
- .comment_2{
18
- @include min(tablet){
19
- margin-left: 11.2rem;
20
- }
21
-
22
- margin-left: 4rem;
23
- }
24
-
25
- .isReply{
26
- position: relative;
27
-
28
- &::before{
29
- content: "";
30
- position: absolute;
31
- right: 100%;
32
- border-left: .1rem solid #CFC7C0;
33
- border-bottom: .1rem solid #CFC7C0;
34
- border-bottom-left-radius: 2rem;
35
- bottom: 50%;
36
- height: calc(50% + 8.5rem);
37
- width: 1.1rem;
38
-
39
- @include min(tablet){
40
- width: 3rem;
41
- }
42
- }
43
-
44
- + .isReply::before{
45
- height: calc(50% + 25.5rem);
46
- }
47
- }
@@ -1,49 +0,0 @@
1
- import React, {createContext, useContext, useEffect, useState} from "react";
2
-
3
- export const VotesContext = createContext({});
4
-
5
- // eslint-disable-next-line react/prop-types
6
- export const VotesProvider = ({ children }) => {
7
- const [votes, setVotes] = useState({});
8
-
9
- useEffect(() => {
10
- const storedVotes =
11
- document.cookie
12
- .split("; ")
13
- .find((row) => row.startsWith("comments="))
14
- ?.split("=")[1]
15
- ?.split(",")
16
- .filter(Boolean) || [];
17
- const votesMap = storedVotes.reduce((acc, entry) => {
18
- const [id, vote] = entry.split(":");
19
- if (id && vote) acc[id] = vote;
20
- return acc;
21
- }, {});
22
- setVotes(votesMap);
23
- }, []);
24
-
25
- const updateVote = (commentId, voteValue) => {
26
- setVotes((prevVotes) => {
27
- const newVotes = { ...prevVotes, [commentId]: voteValue };
28
-
29
- // Convert votes object to cookie string
30
- const cookieValue = Object.entries(newVotes)
31
- .map(([id, vote]) => `${id}:${vote}`)
32
- .join(",");
33
-
34
- // Set the cookie (expires in 1 year)
35
- document.cookie = `comments=${cookieValue}; path=/;`;
36
-
37
- return newVotes;
38
- });
39
- };
40
-
41
- return (
42
- <VotesContext.Provider value={{votes, updateVote}}>{children}</VotesContext.Provider>
43
- );
44
- };
45
-
46
- export const useVote = (commentId) => {
47
- const { votes } = useContext(VotesContext);
48
- return votes?.[commentId];
49
- };