@articles-media/articles-dev-box 1.0.2 → 1.0.3

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.
@@ -1,76 +0,0 @@
1
- import React from 'react';
2
-
3
- // const ArticlesAd = () => {
4
- // return (
5
- // <div style={{ border: '1px solid #ccc', padding: '20px', margin: '10px', textAlign: 'center' }}>
6
- // <p>Advertisement</p>
7
- // </div>
8
- // );
9
- // };
10
-
11
- // export default ArticlesAd;
12
-
13
- // import Script from "next/script";
14
- import { useEffect } from "react";
15
- // import { useStore } from "@/hooks/useStore";
16
-
17
- // Non typescript version, if copying consider using the typescript version instead from a repo like amcot or battle-trap
18
-
19
- export default function ArticlesAd({
20
- darkMode
21
- }) {
22
-
23
- // const darkMode = useStore((state) => state.darkMode)
24
-
25
- useEffect(() => {
26
- // if (!process.env.NEXT_PUBLIC_ARTICLES_OAUTH_ID) {
27
- // console.log("NEXT_PUBLIC_ARTICLES_OAUTH_ID is not set, skipping Articles Media Sign In button initialization.");
28
- // }
29
- }, []);
30
-
31
- useEffect(() => {
32
- const script = document.createElement('script');
33
-
34
- script.src = "https://accounts.articles.media/js/ad.js";
35
- script.async = true;
36
-
37
- document.body.appendChild(script);
38
-
39
- return () => {
40
- document.body.removeChild(script);
41
- }
42
- }, []);
43
-
44
- return (
45
- <div className="">
46
-
47
- {/* <script
48
- src={process.env.NODE_ENV === "development" ?
49
- // `${process.env.NEXT_PUBLIC_LOCAL_ACCOUNTS_ADDRESS}/js/ad.js`
50
- `https://accounts.articles.media/js/ad.js?darkMode=${darkMode}`
51
- :
52
- `https://accounts.articles.media/js/ad.js?darkMode=${darkMode}`
53
- }
54
- strategy="afterInteractive"
55
-
56
- data-version="1"
57
- // data-articles-color-mode="Dark"
58
- // data-articles-button-style={style}
59
- // data-articles-client-id={process.env.NEXT_PUBLIC_ARTICLES_OAUTH_ID}
60
- // data-articles-redirect-uri="https://localhost:3002"
61
- // data-articles-redirect-uri={process.env.NEXT_PUBLIC_ARTICLES_REDIRECT_URI}
62
- // data-articles-authHost={
63
- // process.env.NODE_ENV == "development" ? // "http://localhost:3001"
64
- // process.env.NEXT_PUBLIC_LOCAL_ACCOUNTS_ADDRESS
65
- // :
66
- // "https://accounts.articles.media"
67
- // }
68
- /> */}
69
-
70
- <div className={"articles-media-ad"}>
71
-
72
- </div>
73
-
74
- </div>
75
- );
76
- }
@@ -1,188 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
-
3
- // import axios from 'axios'
4
-
5
- // import Modal from 'react-bootstrap/Modal';
6
-
7
- // import { useHotkeys } from 'react-hotkeys-hook';
8
-
9
- // import ViewUserModal from '@/components/user/ViewUserModal/ViewUserModal';
10
- // import ArticlesSwitch from '../Articles/ArticlesSwitch';
11
- import ArticlesButton from '#root/src/components/UI/Button';
12
-
13
- // import useGameScoreboard from '#root/src/hooks/Games/useGameScoreboard';
14
- import useGameScoreboard from '#root/src/hooks/Games/useGameScoreboard';
15
-
16
- import "#root/src/styles/components/GameScoreboard.scss";
17
-
18
- function GameScoreboard({ game, reloadScoreboard, setReloadScoreboard }) {
19
-
20
- const [showSettings, setShowSettings] = useState(false)
21
-
22
- // const [scoreboard, setScoreboard] = useState([])
23
-
24
- const [visible, setVisible] = useState(false)
25
-
26
- const {
27
- data: scoreboard,
28
- isLoading: scoreboardIsLoading,
29
- mutate: scoreboardMutate
30
- } = useGameScoreboard({
31
- game: game
32
- })
33
-
34
- // function loadScoreboard() {
35
-
36
- // axios.get('/api/community/games/scoreboard', {
37
- // params: {
38
- // game: game
39
- // }
40
- // })
41
- // .then(response => {
42
- // console.log(response.data)
43
- // setScoreboard(response.data)
44
- // })
45
- // .catch(response => {
46
- // console.log(response.data)
47
- // })
48
-
49
- // }
50
-
51
- useEffect(() => {
52
-
53
- // loadScoreboard()
54
-
55
- }, [])
56
-
57
- useEffect(() => {
58
-
59
- if (reloadScoreboard) {
60
- setReloadScoreboard(false)
61
- // loadScoreboard()
62
- scoreboardMutate()
63
- }
64
-
65
- }, [reloadScoreboard])
66
-
67
- return (
68
- <div className="scoreboard">
69
-
70
- {/* <Modal show={showSettings} size={'md'} className="articles-modal" centered onHide={() => setShowSettings(false)}>
71
-
72
- <Modal.Header>
73
- <Modal.Title>
74
- Scoreboard Settings
75
- </Modal.Title>
76
- </Modal.Header>
77
-
78
- <Modal.Body>
79
-
80
- <div
81
- className="d-flex justify-content-between align-items-center"
82
- onClick={() => setVisible(!visible)}
83
- >
84
-
85
- <div>
86
- <i className="fas fa-trophy-alt"></i>
87
- <span>Join Scoreboard?</span>
88
- </div>
89
-
90
- <ArticlesSwitch
91
- checked={visible}
92
- />
93
-
94
- </div>
95
-
96
- </Modal.Body>
97
-
98
- <Modal.Footer className="justify-content-between">
99
-
100
- <ArticlesButton
101
- variant="articles"
102
- onClick={() => {
103
- setShowSettings(false)
104
- }}
105
- >
106
- Close
107
- </ArticlesButton>
108
-
109
- </Modal.Footer>
110
-
111
- </Modal> */}
112
-
113
- <div className="card card-articles card-sm mb-3 mb-lg-0">
114
-
115
- <div className="card-header d-flex justify-content-between align-items-center">
116
-
117
- <span>{game} Scoreboard</span>
118
-
119
- <ArticlesButton
120
- onClick={() => {
121
- scoreboardMutate()
122
- }}
123
- small
124
- >
125
- <i className="fad fa-redo me-0"></i>
126
- </ArticlesButton>
127
-
128
- </div>
129
-
130
- <div className="card-body p-0">
131
-
132
- {(scoreboard?.length || 0) == 0 &&
133
- <div className="small p-2">No scores yet</div>
134
- }
135
-
136
- {scoreboard?.map((doc, i) =>
137
- <div key={doc._id} className="result d-flex flex-column justify-content-between border-bottom p-2">
138
-
139
- <div className='d-flex justify-content-between lh-sm'>
140
-
141
- <div className='d-flex'>
142
-
143
- <h5 className='mb-0 me-3'>{i + 1}</h5>
144
-
145
- <div className='lh-sm'>
146
-
147
- {/* <ViewUserModal
148
- populated_user={doc.populated_user}
149
- user_id={doc.user_id}
150
- /> */}
151
-
152
- </div>
153
-
154
- </div>
155
-
156
- <div><h5 className="mb-0">{doc.score || doc.total}</h5></div>
157
-
158
- </div>
159
-
160
- {(doc.last_play && doc.public_last_play) && <small className='mt-1' style={{ fontSize: '0.75rem' }}>Played: {format(new Date(doc.last_play), 'MM/d/yy hh:mmaa')}</small>}
161
-
162
- </div>
163
- )}
164
-
165
- </div>
166
-
167
- <div className="card-footer d-flex justify-content-between align-items-center">
168
-
169
- <div className='small'>Play to get on the board!</div>
170
-
171
- <ArticlesButton
172
- small
173
- onClick={() => {
174
- setShowSettings(true)
175
- }}
176
- >
177
- <i className="fad fa-cog me-0"></i>
178
- </ArticlesButton>
179
-
180
- </div>
181
-
182
- </div>
183
-
184
- </div>
185
- )
186
- }
187
-
188
- export default GameScoreboard;
@@ -1,55 +0,0 @@
1
- import ArticlesButton from "#root/src/components/UI/Button";
2
-
3
- export default function ReturnToLauncherButton() {
4
-
5
- const urlParams = new URLSearchParams(window.location.search);
6
- const paramsObject = Object.fromEntries(urlParams)
7
-
8
- let { launcher_mode } = paramsObject
9
-
10
- launcher_mode = launcher_mode === '1' ? true : false
11
-
12
- // const router = useRouter()
13
-
14
- if (typeof window === "undefined") return
15
-
16
- if (!launcher_mode) {
17
- return (
18
- <ArticlesButton
19
- // ref={el => elementsRef.current[6] = el}
20
- className={`w-100`}
21
- small
22
- style={{
23
- zIndex: 10,
24
- position: "relative",
25
- }}
26
- onClick={() => {
27
- // window.history.back()
28
- window.location.href = `https://games.articles.media`
29
- }}
30
- >
31
- <i className="fad fa-gamepad"></i>
32
- View our other games
33
- </ArticlesButton>
34
- )
35
- }
36
-
37
- return (
38
- <ArticlesButton
39
- // ref={el => elementsRef.current[6] = el}
40
- className={`w-100`}
41
- small
42
- style={{
43
- zIndex: 10,
44
- position: "relative",
45
- }}
46
- onClick={() => {
47
- // window.history.back()
48
- window.location.href = `https://games.articles.media`
49
- }}
50
- >
51
- <i className="fad fa-gamepad"></i>
52
- Return to Games
53
- </ArticlesButton>
54
- );
55
- }
@@ -1,61 +0,0 @@
1
- import { forwardRef } from 'react';
2
- import classNames from "classnames";
3
-
4
- const ArticlesButton = forwardRef((props, ref) => {
5
-
6
- const {
7
- size,
8
- variant,
9
- style,
10
- // Can just use small instead of size="sm"
11
- small,
12
- large,
13
- onClick,
14
- className,
15
- disabled,
16
- active,
17
- type,
18
- onMouseDown,
19
- onMouseUp,
20
- onMouseLeave,
21
- onTouchStart,
22
- onTouchEnd,
23
- ...rest
24
- } = props;
25
-
26
- return (
27
- <button
28
- ref={ref}
29
- // onClick={onClick}
30
- {
31
- ...(type && {type: 'submit'})
32
- }
33
- disabled={disabled}
34
- style={style}
35
- onMouseDown={onMouseDown}
36
- onMouseUp={onMouseUp}
37
- onMouseLeave={onMouseLeave}
38
- onTouchStart={onTouchStart}
39
- onTouchEnd={onTouchEnd}
40
- // data-react-component='true'
41
- className={
42
- classNames(
43
- `btn ${variant ? `btn-${variant}` : 'btn-articles'}`,
44
- {
45
- [className]: className,
46
- 'btn-lg': large,
47
- 'btn-sm': small,
48
- 'active': active,
49
- [`btn-${size}`]: size
50
- }
51
- )
52
- }
53
- onClick={onClick}
54
- >
55
- {props.children}
56
- </button>
57
- )
58
- })
59
- ArticlesButton.displayName = 'ArticlesButton';
60
-
61
- export default ArticlesButton;
@@ -1,55 +0,0 @@
1
- import useSWR from "swr";
2
-
3
- import axios from "axios";
4
-
5
- const fetcher = async (data) => {
6
- if (process.env.NODE_ENV === 'development') {
7
- try {
8
- const res = await axios.get(`http://localhost:3001/api/ads/${data.ad_id}`, {
9
- params: {
10
- ad_id: data.ad_id
11
- }
12
- });
13
- return res.data.result;
14
- } catch (err) {
15
- // Failed to fetch from localhost, fallback to default URL
16
- }
17
- }
18
-
19
- return axios.get(data.url, {
20
- params: {
21
- ad_id: data.ad_id
22
- }
23
- }).then((res) => res.data.result);
24
- };
25
-
26
- const minutes = 60;
27
- const options = {
28
- dedupingInterval: ((1000 * 60) * minutes),
29
- // keepPreviousData: true,
30
- // fallbackData: []
31
- }
32
-
33
- const useAd = (ad_id) => {
34
-
35
- const { data, error, isLoading, mutate } = useSWR(
36
- ad_id ?
37
- {
38
- url: `https://articles.media/api/ads/${ad_id}`,
39
- ad_id
40
- }
41
- :
42
- null,
43
- fetcher,
44
- options
45
- );
46
-
47
- return {
48
- data,
49
- error,
50
- isLoading,
51
- mutate,
52
- };
53
- };
54
-
55
- export default useAd;
@@ -1,54 +0,0 @@
1
- import useSWR from "swr";
2
-
3
- import axios from "axios";
4
- import { minutesToMilliseconds } from "date-fns";
5
-
6
- const fetcher = async (data) => {
7
- if (process.env.NODE_ENV === 'development') {
8
- try {
9
- const res = await axios.get("http://localhost:3001/api/ads", {
10
- params: {
11
- // ad_id: data.ad_id
12
- }
13
- });
14
- return res.data;
15
- } catch (err) {
16
- // Failed to fetch from localhost, fallback to default URL
17
- }
18
- }
19
-
20
- return axios.get(data.url, {
21
- params: {
22
- // ad_id: data.ad_id
23
- }
24
- }).then((res) => res.data);
25
- };
26
-
27
- const minutes = 60;
28
- const options = {
29
- dedupingInterval: minutesToMilliseconds(minutes),
30
- focusThrottleInterval: minutesToMilliseconds(minutes),
31
- // keepPreviousData: true,
32
- // fallbackData: []
33
- }
34
-
35
- const useAds = (params) => {
36
-
37
- const { data, error, isLoading, mutate } = useSWR(
38
- {
39
- url: `https://articles.media/api/ads`,
40
- // ad_id
41
- },
42
- fetcher,
43
- options
44
- );
45
-
46
- return {
47
- data,
48
- error,
49
- isLoading,
50
- mutate,
51
- };
52
- };
53
-
54
- export default useAds;
@@ -1,59 +0,0 @@
1
- import useSWR from "swr";
2
-
3
- import axios from "axios";
4
-
5
- const fetcher = async (obj) => {
6
- if (process.env.NODE_ENV === 'development') {
7
- try {
8
- const res = await axios.get("http://localhost:3001/api/community/games/scoreboard", {
9
- params: {
10
- game: obj.game,
11
- }
12
- });
13
- return res.data;
14
- } catch (err) {
15
- // Failed to fetch from localhost, fallback to default URL
16
- }
17
- }
18
-
19
- return axios.get(obj.url, {
20
- params: {
21
- game: obj.game,
22
- }
23
- }).then((res) => res.data);
24
- };
25
-
26
- const options = {
27
- dedupingInterval: ((1000 * 60) * 30),
28
- refreshInterval: 0,
29
- revalidateOnFocus: false,
30
- revalidateIfStale: false,
31
- shouldRetryOnError: false,
32
- // fallbackData: []
33
- }
34
-
35
- const useGameScoreboard = (params) => {
36
-
37
- const { data, error, isLoading, isValidating, mutate } = useSWR(
38
- params?.game ?
39
- {
40
- // url: "/api/community/games/scoreboard",
41
- url: "https://articles.media/api/community/games/scoreboard",
42
- game: params.game,
43
- }
44
- :
45
- null,
46
- fetcher,
47
- options
48
- );
49
-
50
- return {
51
- data,
52
- error,
53
- isLoading,
54
- isValidating,
55
- mutate,
56
- };
57
- };
58
-
59
- export default useGameScoreboard;