@articles-media/articles-dev-box 1.0.0 → 1.0.1
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.
- package/README.md +18 -2
- package/index.js +3 -1
- package/package.json +7 -1
- package/src/GameScoreboard.jsx +234 -17
- package/src/components/Ad.jsx +629 -0
- package/src/hooks/Ads/useAd.js +55 -0
- package/src/hooks/Ads/useAds.js +54 -0
- package/src/hooks/useGameScoreboard.js +59 -0
- package/styles/components/Ad.scss +223 -0
- package/styles/components/GameScoreboard.scss +35 -1
- package/styles/global.scss +98 -0
- package/styles/variables.scss +3 -0
- /package/src/{ArticlesAd.jsx → components/ArticlesAd.jsx} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Articles Dev Box
|
|
2
2
|
|
|
3
|
-
Shared code, functions, and components
|
|
3
|
+
Shared code, functions, and components that are commonly used across Articles Media projects. None of this is meant to work outside the Articles Media frontend React ecosystem.
|
|
4
4
|
|
|
5
5
|
## Getting Started
|
|
6
6
|
|
|
@@ -16,6 +16,22 @@ Then go to the consuming project directory and run this command.
|
|
|
16
16
|
npm link articles-dev-box
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
For production use add the organization scooped package to your package.json.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm i @articles-media/articles-dev-box
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Package Exports
|
|
26
|
+
|
|
27
|
+
- ReturnToLauncherButton
|
|
28
|
+
- For bringing users back to their state in the games showcase/launcher
|
|
29
|
+
- GameScoreboard
|
|
30
|
+
- Scoreboard for registered games that links with a user's Articles Media account.
|
|
31
|
+
- Ad
|
|
32
|
+
- Articles Ad component that connects with user data.
|
|
33
|
+
|
|
19
34
|
# Roadmap
|
|
20
35
|
⏹️ Remove Bootstrap reliance
|
|
21
|
-
⏹️ Look into npm package yalc
|
|
36
|
+
⏹️ Look into npm package yalc
|
|
37
|
+
⏹️ Automatic GitHub Action for NPM
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ReturnToLauncherButton from './src/ReturnToLauncherButton.jsx';
|
|
2
|
-
import ArticlesAd from './src/ArticlesAd.jsx';
|
|
2
|
+
import ArticlesAd from './src/components/ArticlesAd.jsx';
|
|
3
|
+
import Ad from './src/components/Ad.jsx';
|
|
3
4
|
import GameScoreboard from './src/GameScoreboard.jsx';
|
|
4
5
|
|
|
5
6
|
function helloWorld() {
|
|
@@ -10,5 +11,6 @@ export {
|
|
|
10
11
|
helloWorld,
|
|
11
12
|
ReturnToLauncherButton,
|
|
12
13
|
ArticlesAd,
|
|
14
|
+
Ad,
|
|
13
15
|
GameScoreboard,
|
|
14
16
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@articles-media/articles-dev-box",
|
|
3
3
|
"description": "Shared code, functions, and components for different Articles Media projects.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -25,5 +25,11 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"classnames": "^2.5.1",
|
|
27
27
|
"sass": "^1.97.2"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"axios": "^1.13.2",
|
|
31
|
+
"date-fns": "^4.1.0",
|
|
32
|
+
"react-intersection-observer": "^10.0.0",
|
|
33
|
+
"swr": "^2.3.8"
|
|
28
34
|
}
|
|
29
35
|
}
|
package/src/GameScoreboard.jsx
CHANGED
|
@@ -1,17 +1,234 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import '../styles/components/GameScoreboard.scss';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
// import React from 'react';
|
|
2
|
+
// import '../styles/components/GameScoreboard.scss';
|
|
3
|
+
// import classNames from 'classnames';
|
|
4
|
+
|
|
5
|
+
// const GameScoreboard = ({
|
|
6
|
+
// game,
|
|
7
|
+
// darkMode
|
|
8
|
+
// }) => {
|
|
9
|
+
// return (
|
|
10
|
+
// <div
|
|
11
|
+
// className={
|
|
12
|
+
// classNames(
|
|
13
|
+
// `articles-game-scoreboard card`,
|
|
14
|
+
// { 'dark-mode': darkMode }
|
|
15
|
+
// )
|
|
16
|
+
// }
|
|
17
|
+
// >
|
|
18
|
+
|
|
19
|
+
// <div
|
|
20
|
+
// className='card-header'
|
|
21
|
+
// >
|
|
22
|
+
// <div className='fw-bold mb-0'>
|
|
23
|
+
// <i className='fad fa-gamepad'></i>
|
|
24
|
+
// {game} Scoreboard
|
|
25
|
+
// </div>
|
|
26
|
+
// </div>
|
|
27
|
+
|
|
28
|
+
// <div className='card-body p-2'>
|
|
29
|
+
// <p>This is a test scoreboard component.</p>
|
|
30
|
+
// <ul>
|
|
31
|
+
// <li>Player 1: 100</li>
|
|
32
|
+
// <li>Player 2: 200</li>
|
|
33
|
+
// </ul>
|
|
34
|
+
// </div>
|
|
35
|
+
|
|
36
|
+
// <div
|
|
37
|
+
// className='card-footer'
|
|
38
|
+
// >
|
|
39
|
+
|
|
40
|
+
// </div>
|
|
41
|
+
|
|
42
|
+
// </div>
|
|
43
|
+
// );
|
|
44
|
+
// };
|
|
45
|
+
|
|
46
|
+
// export default GameScoreboard;
|
|
47
|
+
|
|
48
|
+
import { useEffect, useState } from 'react'
|
|
49
|
+
|
|
50
|
+
// import axios from 'axios'
|
|
51
|
+
|
|
52
|
+
// import Modal from 'react-bootstrap/Modal';
|
|
53
|
+
|
|
54
|
+
// import { useHotkeys } from 'react-hotkeys-hook';
|
|
55
|
+
|
|
56
|
+
// import ViewUserModal from '@/components/user/ViewUserModal/ViewUserModal';
|
|
57
|
+
// import ArticlesSwitch from '../Articles/ArticlesSwitch';
|
|
58
|
+
import ArticlesButton from './Button';
|
|
59
|
+
|
|
60
|
+
import useGameScoreboard from './hooks/useGameScoreboard';
|
|
61
|
+
|
|
62
|
+
import "../styles/components/GameScoreboard.scss";
|
|
63
|
+
|
|
64
|
+
function GameScoreboard({ game, reloadScoreboard, setReloadScoreboard }) {
|
|
65
|
+
|
|
66
|
+
const [showSettings, setShowSettings] = useState(false)
|
|
67
|
+
|
|
68
|
+
// const [scoreboard, setScoreboard] = useState([])
|
|
69
|
+
|
|
70
|
+
const [visible, setVisible] = useState(false)
|
|
71
|
+
|
|
72
|
+
const {
|
|
73
|
+
data: scoreboard,
|
|
74
|
+
isLoading: scoreboardIsLoading,
|
|
75
|
+
mutate: scoreboardMutate
|
|
76
|
+
} = useGameScoreboard({
|
|
77
|
+
game: game
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
// function loadScoreboard() {
|
|
81
|
+
|
|
82
|
+
// axios.get('/api/community/games/scoreboard', {
|
|
83
|
+
// params: {
|
|
84
|
+
// game: game
|
|
85
|
+
// }
|
|
86
|
+
// })
|
|
87
|
+
// .then(response => {
|
|
88
|
+
// console.log(response.data)
|
|
89
|
+
// setScoreboard(response.data)
|
|
90
|
+
// })
|
|
91
|
+
// .catch(response => {
|
|
92
|
+
// console.log(response.data)
|
|
93
|
+
// })
|
|
94
|
+
|
|
95
|
+
// }
|
|
96
|
+
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
|
|
99
|
+
// loadScoreboard()
|
|
100
|
+
|
|
101
|
+
}, [])
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
|
|
105
|
+
if (reloadScoreboard) {
|
|
106
|
+
setReloadScoreboard(false)
|
|
107
|
+
// loadScoreboard()
|
|
108
|
+
scoreboardMutate()
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}, [reloadScoreboard])
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<div className="scoreboard">
|
|
115
|
+
|
|
116
|
+
{/* <Modal show={showSettings} size={'md'} className="articles-modal" centered onHide={() => setShowSettings(false)}>
|
|
117
|
+
|
|
118
|
+
<Modal.Header>
|
|
119
|
+
<Modal.Title>
|
|
120
|
+
Scoreboard Settings
|
|
121
|
+
</Modal.Title>
|
|
122
|
+
</Modal.Header>
|
|
123
|
+
|
|
124
|
+
<Modal.Body>
|
|
125
|
+
|
|
126
|
+
<div
|
|
127
|
+
className="d-flex justify-content-between align-items-center"
|
|
128
|
+
onClick={() => setVisible(!visible)}
|
|
129
|
+
>
|
|
130
|
+
|
|
131
|
+
<div>
|
|
132
|
+
<i className="fas fa-trophy-alt"></i>
|
|
133
|
+
<span>Join Scoreboard?</span>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<ArticlesSwitch
|
|
137
|
+
checked={visible}
|
|
138
|
+
/>
|
|
139
|
+
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
</Modal.Body>
|
|
143
|
+
|
|
144
|
+
<Modal.Footer className="justify-content-between">
|
|
145
|
+
|
|
146
|
+
<ArticlesButton
|
|
147
|
+
variant="articles"
|
|
148
|
+
onClick={() => {
|
|
149
|
+
setShowSettings(false)
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
Close
|
|
153
|
+
</ArticlesButton>
|
|
154
|
+
|
|
155
|
+
</Modal.Footer>
|
|
156
|
+
|
|
157
|
+
</Modal> */}
|
|
158
|
+
|
|
159
|
+
<div className="card card-articles card-sm mb-3 mb-lg-0">
|
|
160
|
+
|
|
161
|
+
<div className="card-header d-flex justify-content-between align-items-center">
|
|
162
|
+
|
|
163
|
+
<span>{game} Scoreboard</span>
|
|
164
|
+
|
|
165
|
+
<ArticlesButton
|
|
166
|
+
onClick={() => {
|
|
167
|
+
scoreboardMutate()
|
|
168
|
+
}}
|
|
169
|
+
small
|
|
170
|
+
>
|
|
171
|
+
<i className="fad fa-redo me-0"></i>
|
|
172
|
+
</ArticlesButton>
|
|
173
|
+
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
<div className="card-body p-0">
|
|
177
|
+
|
|
178
|
+
{(scoreboard?.length || 0) == 0 &&
|
|
179
|
+
<div className="small p-2">No scores yet</div>
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
{scoreboard?.map((doc, i) =>
|
|
183
|
+
<div key={doc._id} className="result d-flex flex-column justify-content-between border-bottom p-2">
|
|
184
|
+
|
|
185
|
+
<div className='d-flex justify-content-between lh-sm'>
|
|
186
|
+
|
|
187
|
+
<div className='d-flex'>
|
|
188
|
+
|
|
189
|
+
<h5 className='mb-0 me-3'>{i + 1}</h5>
|
|
190
|
+
|
|
191
|
+
<div className='lh-sm'>
|
|
192
|
+
|
|
193
|
+
{/* <ViewUserModal
|
|
194
|
+
populated_user={doc.populated_user}
|
|
195
|
+
user_id={doc.user_id}
|
|
196
|
+
/> */}
|
|
197
|
+
|
|
198
|
+
</div>
|
|
199
|
+
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
<div><h5 className="mb-0">{doc.score || doc.total}</h5></div>
|
|
203
|
+
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
{(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>}
|
|
207
|
+
|
|
208
|
+
</div>
|
|
209
|
+
)}
|
|
210
|
+
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
<div className="card-footer d-flex justify-content-between align-items-center">
|
|
214
|
+
|
|
215
|
+
<div className='small'>Play to get on the board!</div>
|
|
216
|
+
|
|
217
|
+
<ArticlesButton
|
|
218
|
+
small
|
|
219
|
+
onClick={() => {
|
|
220
|
+
setShowSettings(true)
|
|
221
|
+
}}
|
|
222
|
+
>
|
|
223
|
+
<i className="fad fa-cog me-0"></i>
|
|
224
|
+
</ArticlesButton>
|
|
225
|
+
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
</div>
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export default GameScoreboard;
|