@articles-media/articles-dev-box 1.0.0 → 1.0.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.
@@ -0,0 +1,188 @@
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,4 +1,4 @@
1
- import ArticlesButton from "./Button";
1
+ import ArticlesButton from "#root/src/components/UI/Button";
2
2
 
3
3
  export default function ReturnToLauncherButton() {
4
4
 
@@ -11,6 +11,8 @@ export default function ReturnToLauncherButton() {
11
11
 
12
12
  // const router = useRouter()
13
13
 
14
+ if (typeof window === "undefined") return
15
+
14
16
  if (!launcher_mode) {
15
17
  return (
16
18
  <ArticlesButton
@@ -0,0 +1,55 @@
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;
@@ -0,0 +1,54 @@
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;
@@ -0,0 +1,59 @@
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;
@@ -0,0 +1,223 @@
1
+ @use "../global.scss" as *;
2
+
3
+ .ad-wrap {
4
+ z-index: 1;
5
+ margin: 0 auto;
6
+ margin-bottom: 1rem;
7
+ max-width: 312px;
8
+ width: 100%;
9
+
10
+ .ad {
11
+ position: relative;
12
+ align-self: flex-start;
13
+ width: 100%;
14
+ z-index: 2;
15
+ font-family: brandon-grotesque, sans-serif;
16
+ @include shadow-articles;
17
+ font-size: 14px;
18
+
19
+ @include media-breakpoint-down(md) {
20
+ font-size: 16px;
21
+ width: 100%;
22
+ }
23
+
24
+ .main-panel {
25
+ background-color: var(--articles-ad-background-color, var(--card-background));
26
+ color: var(--articles-ad-font-color, var(--bs-body-color));
27
+ // background-color: #343746;
28
+ height: 400px;
29
+ display: flex;
30
+ flex-direction: column;
31
+
32
+ .ad-warning {
33
+ // background-color: $base-color;
34
+ // background-color: white;
35
+ // color: black;
36
+ padding: 0.1rem 0.75rem;
37
+ font-family: brandon-grotesque, sans-serif;
38
+ // font-style: normal;
39
+ font-weight: 900;
40
+ font-size: 1rem;
41
+ border-bottom: 1px solid var(--articles-ad-border-color, var(--card-background));
42
+ }
43
+
44
+ .content-wrap {
45
+ display: flex;
46
+ // flex-direction: row;
47
+ flex-direction: column;
48
+ align-items: center;
49
+
50
+ @include media-breakpoint-up(lg) {
51
+ flex-direction: column;
52
+ }
53
+ }
54
+
55
+ .photo-banner {
56
+ position: relative;
57
+ height: 100px;
58
+ width: 100px;
59
+ flex-shrink: 0;
60
+ display: flex;
61
+ // justify-content: center;
62
+ align-items: center;
63
+ padding-left: 1rem;
64
+ margin-left: 0.75rem;
65
+
66
+ // @include media-breakpoint-up(lg) {
67
+ margin-left: 0rem;
68
+ height: 125px;
69
+ width: 100%;
70
+ // }
71
+
72
+ .logo {
73
+ // padding: 1rem;
74
+ // $height: 125px;
75
+ // position: absolute;
76
+ // top: 1rem;
77
+ // left: 50%;
78
+ // transform: translateX(-50%);
79
+ // height: $height;
80
+ object-fit: cover;
81
+ z-index: 1;
82
+
83
+ img {
84
+ width: 75px;
85
+ height: 75px;
86
+ object-fit: contain;
87
+
88
+ // @include media-breakpoint-up(lg) {
89
+ // width: 100px;
90
+ // height: 100px;
91
+ // }
92
+ }
93
+ }
94
+
95
+ .icon {
96
+ display: none;
97
+ position: absolute;
98
+ bottom: calc(-125px / 2);
99
+ left: 20px;
100
+ height: 125px;
101
+ display: flex;
102
+ align-items: center;
103
+ justify-content: center;
104
+ color: white;
105
+ font-size: 3.5rem;
106
+ }
107
+
108
+ .photo {
109
+ position: absolute;
110
+ left: 0;
111
+ top: 0;
112
+ width: 100%;
113
+ height: 100%;
114
+ object-fit: cover;
115
+ }
116
+ }
117
+
118
+ .details-wrap {
119
+ width: 100%;
120
+ }
121
+
122
+ .details,
123
+ .detail-title {
124
+ padding: 0.75rem;
125
+ // color: white;
126
+ display: grid;
127
+ grid-gap: 5px 5px;
128
+ grid-template-columns: repeat(2, 1fr);
129
+ padding-bottom: 0rem;
130
+
131
+ @include media-breakpoint-down(md) {
132
+ // padding-top: 80px;
133
+ }
134
+
135
+ .detail {
136
+ // margin-left: 5%;
137
+ // width: 50%;
138
+
139
+ .icon {
140
+ display: inline-block;
141
+ width: 1.5rem;
142
+
143
+ i {
144
+ justify-content: flex-start;
145
+ display: flex;
146
+ }
147
+ }
148
+ }
149
+ }
150
+
151
+ .short-description {
152
+ padding: 0.75rem;
153
+ padding-top: 0.25rem;
154
+ padding-bottom: 0rem;
155
+ min-height: 50px;
156
+ overflow-y: auto;
157
+ max-height: 125px;
158
+ // @include articles-scrollbar;
159
+ @include alternate-scrollbar;
160
+ // color: white;
161
+ }
162
+
163
+ .detail-title {
164
+ display: flex;
165
+ justify-content: space-between;
166
+ align-items: center;
167
+
168
+ // .detail {
169
+ // // font-size: 2rem;
170
+ // width: 100%;
171
+ // font-family: brandon-grotesque, sans-serif;
172
+ // font-style: normal;
173
+ // font-weight: 900;
174
+ // font-size: 1.25rem;
175
+
176
+ // .icon {
177
+ // margin-right: 1rem;
178
+ // }
179
+ // }
180
+ }
181
+
182
+ .action-wrap {
183
+ // background-color: #343746;
184
+ // color: white;
185
+ border-top: 1px solid var(--articles-ad-border-color, var(--card-background));
186
+
187
+ .action {
188
+ // color: white;
189
+ // margin-top: 0.75rem;
190
+ padding: 0.25rem;
191
+ display: flex;
192
+ justify-content: center;
193
+ align-items: center;
194
+ border: 1px solid var(--articles-ad-border-color, var(--card-background));
195
+ color: var(--articles-ad-font-color, var(--bs-body-color));
196
+ border-radius: 10px;
197
+ margin-left: auto;
198
+ margin-right: auto;
199
+ cursor: pointer;
200
+ transition-duration: 200ms;
201
+
202
+ &:hover {
203
+ background-color: white;
204
+ color: black;
205
+ }
206
+
207
+ &:active {
208
+ background-color: gray;
209
+ }
210
+ }
211
+ }
212
+ }
213
+ }
214
+
215
+ .advertise-with-us {
216
+ background-color: var(--articles-ad-background-color, var(--card-background));
217
+ border-top: 2px solid var(--articles-ad-border-color, var(--card-background));
218
+
219
+ a {
220
+ color: var(--articles-ad-font-color, var(--bs-body-color))!important;
221
+ }
222
+ }
223
+ }
@@ -0,0 +1,37 @@
1
+ @use "../global.scss" as *;
2
+
3
+ .scoreboard {
4
+ margin-top: 1rem;
5
+ max-width: 300px;
6
+ width: 100%;
7
+ margin-bottom: 1rem;
8
+
9
+ @include media-breakpoint-up(lg) {
10
+ margin-top: 0rem;
11
+ margin-bottom: 0rem;
12
+ display: block;
13
+ position: absolute;
14
+ left: 1rem;
15
+ top: 50%;
16
+ transform: translateY(-50%);
17
+ }
18
+ }
19
+
20
+ .articles-game-scoreboard {
21
+ border: 1px solid rgb(206, 212, 218);
22
+ border-radius: 8px;
23
+ box-shadow: rgba(0, 0, 0, 0.07) 0px 2px 8px;
24
+ // background: rgb(255, 255, 255);
25
+ color: rgb(34, 34, 34);
26
+ width: 100%;
27
+ max-width: 350px;
28
+ margin: 0px 1rem;
29
+ overflow: hidden;
30
+ display: flex;
31
+ flex-direction: column;
32
+ z-index: 1;
33
+ position: fixed;
34
+ bottom: 50%;
35
+ transform: translateY(50%);
36
+ left: 8px;
37
+ }