@mideind/netskrafl-react 2.1.0 → 2.1.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 CHANGED
@@ -1,63 +1,138 @@
1
1
 
2
2
  # netskrafl-react
3
3
 
4
- ## A React front end for Netskrafl
4
+ A React front end for Netskrafl, packaged as a React component library.
5
5
 
6
- This is a web front end for the Netskrafl game server, packaged as a React component.
6
+ ## Components
7
7
 
8
- The component is written in TypeScript. It assumes that the containing application
9
- (a) performs user authentication and (b) determines whether users have full access to the
10
- Netskrafl functionality (typically by being paying subscribers) or limited/free access.
11
- Information about (a) and (b) is passed to the component via its props.
8
+ This library provides two main components:
12
9
 
13
- The code for the Netskrafl backend server can be found on GitHub
14
- at [https://github.com/mideind/Netskrafl](https://github.com/mideind/Netskrafl).
15
- The backend is written in Python, using the Flask web framework.
16
- The `netskrafl-react` component talks to the Netskrafl server via a
17
- JSON API over HTTPS, and uses Firebase for real-time updates.
10
+ - **Netskrafl** - The full multiplayer crossword game
11
+ - **GataDagsins** - A daily crossword riddle ("Riddle of the Day")
18
12
 
19
- The source code for `netskrafl-react` is a bit unusual in that it was originally
20
- written for the [Mithril](https://mithril.js.org) UI framework. The Mithril code
21
- has been wrapped in a React component. Modifying the component thus requires
22
- some familiarity with Mithril, as well as React. However, Mithril is fairly
23
- straightforward and arguably simpler than React, so this should not be a major
24
- obstacle.
13
+ Both components are responsive and mobile-friendly.
25
14
 
26
15
  ## Installation
27
16
 
28
- To install the Netskrafl React component via `npm`, run the following command:
17
+ ```bash
18
+ npm install @mideind/netskrafl-react
19
+ ```
29
20
 
21
+ Requires React 18+. This package is distributed as ESM only.
22
+
23
+ ## Usage
24
+
25
+ Import the component and its styles:
26
+
27
+ ```tsx
28
+ import { Netskrafl } from '@mideind/netskrafl-react';
29
+ import '@mideind/netskrafl-react/style.css';
30
+
31
+ function App() {
32
+ return (
33
+ <Netskrafl
34
+ state={{
35
+ userEmail: 'user@example.com',
36
+ userFullName: 'Example User',
37
+ userId: 'unique-user-id',
38
+ firebaseToken: 'firebase-auth-token',
39
+ subscriber: true,
40
+ locale: 'is',
41
+ urlPrefix: 'https://netskrafl.is',
42
+ }}
43
+ />
44
+ );
45
+ }
30
46
  ```
31
- npm install @mideind/netskrafl-react
47
+
48
+ For Gáta Dagsins:
49
+
50
+ ```tsx
51
+ import { GataDagsins } from '@mideind/netskrafl-react';
52
+ import '@mideind/netskrafl-react/style.css';
53
+
54
+ function App() {
55
+ return (
56
+ <GataDagsins
57
+ state={{
58
+ userEmail: 'user@example.com',
59
+ userFullName: 'Example User',
60
+ userId: 'unique-user-id',
61
+ firebaseToken: 'firebase-auth-token',
62
+ subscriber: true,
63
+ locale: 'is',
64
+ urlPrefix: 'https://netskrafl.is',
65
+ }}
66
+ />
67
+ );
68
+ }
32
69
  ```
33
70
 
34
- ## Development
71
+ ### Props
35
72
 
36
- During development, you can run the rollup bundler in watch mode by running:
73
+ | Prop | Type | Description |
74
+ |------|------|-------------|
75
+ | `userEmail` | string | User's email address |
76
+ | `userFullName` | string | User's display name |
77
+ | `userId` | string | Unique user identifier |
78
+ | `firebaseToken` | string | Firebase authentication token for real-time updates |
79
+ | `subscriber` | boolean | Whether user has full access (subscriber) or limited/free access |
80
+ | `locale` | string | UI language (`'is'` for Icelandic, `'en'` for English) |
81
+ | `urlPrefix` | string | Base URL of the Netskrafl backend server |
37
82
 
38
- ```bash
39
- npm run watch
40
- ```
83
+ ## Features
41
84
 
42
- You can also use Storybook as a testing container by running:
85
+ - Drag-and-drop tile placement
86
+ - Click-to-select tile placement
87
+ - Keyboard tile placement (type letters to place tiles)
88
+ - Real-time game updates via Firebase
89
+ - Mobile-responsive design with touch support
90
+ - Pinch-to-zoom on mobile devices
43
91
 
44
- ```bash
45
- npm run storybook
46
- ```
92
+ ## Architecture
93
+
94
+ The components are written in TypeScript. They assume that the containing
95
+ application handles user authentication and subscription status.
47
96
 
48
- To build the component for production, run:
97
+ The code uses a hybrid React-Mithril architecture: the components are React
98
+ wrappers around [Mithril](https://mithril.js.org) UI code. Modifying the
99
+ components requires familiarity with both frameworks, though Mithril is
100
+ straightforward and arguably simpler than React.
101
+
102
+ The components communicate with the Netskrafl backend server via a JSON API
103
+ over HTTPS, and use Firebase for real-time updates.
104
+
105
+ ## Backend
106
+
107
+ The Netskrafl backend server code is available at
108
+ [github.com/mideind/Netskrafl](https://github.com/mideind/Netskrafl).
109
+ The backend is written in Python using the Flask web framework.
110
+
111
+ ## Development
49
112
 
50
113
  ```bash
114
+ # Install dependencies
115
+ npm install
116
+
117
+ # Run rollup in watch mode
118
+ npm run watch
119
+
120
+ # Run Storybook for development/testing
121
+ npm run storybook
122
+
123
+ # Build for production
51
124
  npm run rollup
52
- ```
53
125
 
54
- See the `package.json` file for specifics.
126
+ # Type-check
127
+ npx tsc --noEmit
128
+
129
+ # Lint
130
+ npx @biomejs/biome check src/
131
+ ```
55
132
 
56
- ## License and copyright
133
+ ## License
57
134
 
58
- Copyright © 2025 Miðeind ehf. The original author of `netskrafl-react`
59
- is *Vilhjálmur Þorsteinsson*.
135
+ Copyright © 2025 Miðeind ehf. Original author: Vilhjálmur Þorsteinsson.
60
136
 
61
- This code is released under the
62
- [CC-BY-NC 4.0 license](https://creativecommons.org/licenses/by-nc/4.0/).
137
+ Released under the [CC-BY-NC 4.0 license](https://creativecommons.org/licenses/by-nc/4.0/).
63
138
  See the LICENSE file for details.