@articles-media/articles-dev-box 1.0.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ # Articles Dev Box
2
+
3
+ Shared code, functions, and components for different Articles Media projects.
4
+
5
+ ## Getting Started
6
+
7
+ For local development, navigate to this project and run this command.
8
+
9
+ ```bash
10
+ npm link
11
+ ```
12
+
13
+ Then go to the consuming project directory and run this command.
14
+
15
+ ```bash
16
+ npm link articles-dev-box
17
+ ```
18
+
19
+ # Roadmap
20
+ ⏹️ Remove Bootstrap reliance
21
+ ⏹️ Look into npm package yalc
package/index.js ADDED
@@ -0,0 +1,14 @@
1
+ import ReturnToLauncherButton from './src/ReturnToLauncherButton.jsx';
2
+ import ArticlesAd from './src/ArticlesAd.jsx';
3
+ import GameScoreboard from './src/GameScoreboard.jsx';
4
+
5
+ function helloWorld() {
6
+ return "Hello, world!";
7
+ }
8
+
9
+ export {
10
+ helloWorld,
11
+ ReturnToLauncherButton,
12
+ ArticlesAd,
13
+ GameScoreboard,
14
+ };
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@articles-media/articles-dev-box",
3
+ "description": "Shared code, functions, and components for different Articles Media projects.",
4
+ "version": "1.0.0",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "files": [
8
+ "index.js",
9
+ "src",
10
+ "styles"
11
+ ],
12
+ "exports": {
13
+ ".": "./index.js"
14
+ },
15
+ "scripts": {
16
+ "test": "echo \"Error: no test specified\" && exit 1"
17
+ },
18
+ "keywords": [],
19
+ "author": "Articles Media",
20
+ "license": "ISC",
21
+ "peerDependencies": {
22
+ "react": ">=19.2.3",
23
+ "react-dom": ">=19.2.3"
24
+ },
25
+ "devDependencies": {
26
+ "classnames": "^2.5.1",
27
+ "sass": "^1.97.2"
28
+ }
29
+ }
@@ -0,0 +1,76 @@
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
+ }
package/src/Button.js ADDED
@@ -0,0 +1,61 @@
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;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import '../styles/components/GameScoreboard.scss';
3
+
4
+ const GameScoreboard = () => {
5
+ return (
6
+ <div className='articles-game-scoreboard'>
7
+ <h2>Game Scoreboard</h2>
8
+ <p>This is a test scoreboard component.</p>
9
+ <ul>
10
+ <li>Player 1: 100</li>
11
+ <li>Player 2: 200</li>
12
+ </ul>
13
+ </div>
14
+ );
15
+ };
16
+
17
+ export default GameScoreboard;
@@ -0,0 +1,53 @@
1
+ import ArticlesButton from "./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 (!launcher_mode) {
15
+ return (
16
+ <ArticlesButton
17
+ // ref={el => elementsRef.current[6] = el}
18
+ className={`w-100`}
19
+ small
20
+ style={{
21
+ zIndex: 10,
22
+ position: "relative",
23
+ }}
24
+ onClick={() => {
25
+ // window.history.back()
26
+ window.location.href = `https://games.articles.media`
27
+ }}
28
+ >
29
+ <i className="fad fa-gamepad"></i>
30
+ View our other games
31
+ </ArticlesButton>
32
+ )
33
+ }
34
+
35
+ return (
36
+ <ArticlesButton
37
+ // ref={el => elementsRef.current[6] = el}
38
+ className={`w-100`}
39
+ small
40
+ style={{
41
+ zIndex: 10,
42
+ position: "relative",
43
+ }}
44
+ onClick={() => {
45
+ // window.history.back()
46
+ window.location.href = `https://games.articles.media`
47
+ }}
48
+ >
49
+ <i className="fad fa-gamepad"></i>
50
+ Return to Games
51
+ </ArticlesButton>
52
+ );
53
+ }
@@ -0,0 +1,3 @@
1
+ .articles-game-scoreboard {
2
+ background-color: aquamarine;
3
+ }