@mideind/netskrafl-react 3.4.5 → 3.4.7
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 +82 -38
- package/dist/esm/css/netskrafl.css +14 -13
- package/dist/esm/index.js +70 -70
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,74 +20,115 @@ npm install @mideind/netskrafl-react
|
|
|
20
20
|
|
|
21
21
|
Requires React 18+. This package is distributed as ESM only.
|
|
22
22
|
|
|
23
|
+
If using Next.js, add the package to `transpilePackages` in `next.config.ts`:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
transpilePackages: ['@mideind/netskrafl-react'],
|
|
27
|
+
```
|
|
28
|
+
|
|
23
29
|
## Usage
|
|
24
30
|
|
|
25
|
-
Import the component and
|
|
31
|
+
Import the component, its styles, and optionally the props type:
|
|
26
32
|
|
|
27
33
|
```tsx
|
|
28
34
|
import { Netskrafl } from '@mideind/netskrafl-react';
|
|
35
|
+
import type { INetskraflProps } from '@mideind/netskrafl-react';
|
|
29
36
|
import '@mideind/netskrafl-react/style.css';
|
|
30
37
|
|
|
31
38
|
function App() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
const props: INetskraflProps = {
|
|
40
|
+
state: {
|
|
41
|
+
serverUrl: 'https://your-netskrafl-server.is',
|
|
42
|
+
userEmail: 'user@example.com',
|
|
43
|
+
userNick: 'User',
|
|
44
|
+
userFullname: 'Example User',
|
|
45
|
+
token: 'jwt-auth-token',
|
|
46
|
+
plan: 'friend',
|
|
47
|
+
hasPaid: true,
|
|
48
|
+
// Firebase configuration
|
|
49
|
+
projectId: 'netskrafl',
|
|
50
|
+
firebaseApiKey: '...',
|
|
51
|
+
firebaseAppId: '...',
|
|
52
|
+
firebaseSenderId: '...',
|
|
53
|
+
databaseUrl: 'https://your-netskrafl.firebaseio.com',
|
|
54
|
+
measurementId: '...',
|
|
55
|
+
// Optional
|
|
56
|
+
loginMethod: 'myapp',
|
|
57
|
+
subscriptionUrl: '/subscribe',
|
|
58
|
+
},
|
|
59
|
+
tokenExpired: async () => {
|
|
60
|
+
// Called when the auth token expires.
|
|
61
|
+
// Fetch a new JWT and return it, or return undefined on failure.
|
|
62
|
+
const res = await fetch('/api/token', { method: 'POST' });
|
|
63
|
+
const data = await res.json();
|
|
64
|
+
return data.jwt;
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
return <Netskrafl {...props} />;
|
|
45
68
|
}
|
|
46
69
|
```
|
|
47
70
|
|
|
48
|
-
For Gáta Dagsins:
|
|
71
|
+
For Gáta Dagsins, the usage is identical except for the component name:
|
|
49
72
|
|
|
50
73
|
```tsx
|
|
51
74
|
import { GataDagsins } from '@mideind/netskrafl-react';
|
|
52
75
|
import '@mideind/netskrafl-react/style.css';
|
|
53
76
|
|
|
54
77
|
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
|
-
);
|
|
78
|
+
return <GataDagsins state={{ /* same shape */ }} tokenExpired={...} />;
|
|
68
79
|
}
|
|
69
80
|
```
|
|
70
81
|
|
|
71
82
|
### Props
|
|
72
83
|
|
|
84
|
+
Both components accept `INetskraflProps`:
|
|
85
|
+
|
|
73
86
|
| Prop | Type | Description |
|
|
74
87
|
|------|------|-------------|
|
|
88
|
+
| `state` | `Partial<GlobalState>` | Configuration and user state (see below) |
|
|
89
|
+
| `tokenExpired` | `() => Promise<string \| undefined>` | Optional callback invoked when the auth token expires; should return a fresh JWT |
|
|
90
|
+
|
|
91
|
+
### State fields
|
|
92
|
+
|
|
93
|
+
The `state` prop is a partial `GlobalState` object. Commonly used fields:
|
|
94
|
+
|
|
95
|
+
| Field | Type | Description |
|
|
96
|
+
|-------|------|-------------|
|
|
97
|
+
| `serverUrl` | string | Base URL of the Netskrafl backend server |
|
|
75
98
|
| `userEmail` | string | User's email address |
|
|
76
|
-
| `
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
99
|
+
| `userNick` | string | User's short display name |
|
|
100
|
+
| `userFullname` | string | User's full display name |
|
|
101
|
+
| `token` | string | JWT authentication token for API requests |
|
|
102
|
+
| `plan` | string | Subscription plan identifier (e.g. `'friend'`) |
|
|
103
|
+
| `hasPaid` | boolean | Whether the user has an active subscription |
|
|
104
|
+
| `loginMethod` | string | Identifies the host application (e.g. `'malstadur'`) |
|
|
105
|
+
| `subscriptionUrl` | string | URL to redirect users for subscription management |
|
|
106
|
+
| `projectId` | string | Firebase project ID |
|
|
107
|
+
| `firebaseApiKey` | string | Firebase API key |
|
|
108
|
+
| `firebaseAppId` | string | Firebase app ID |
|
|
109
|
+
| `firebaseSenderId` | string | Firebase messaging sender ID |
|
|
110
|
+
| `databaseUrl` | string | Firebase Realtime Database URL |
|
|
111
|
+
| `measurementId` | string | Firebase Analytics measurement ID |
|
|
112
|
+
| `movesUrl` | string | URL of the moves microservice |
|
|
113
|
+
| `movesAccessKey` | string | Access key for the moves microservice |
|
|
114
|
+
| `locale` | string | UI language (`'is'` for Icelandic, `'en_US'` for English) |
|
|
115
|
+
| `runningLocal` | boolean | Set to `true` in development environments |
|
|
116
|
+
| `userGroupId` | string? | Optional group identifier for Gáta Dagsins leaderboards |
|
|
117
|
+
|
|
118
|
+
All fields are optional (the state is `Partial<GlobalState>`), but the
|
|
119
|
+
components need at minimum `serverUrl`, `userEmail`, `token`, and the
|
|
120
|
+
Firebase configuration fields to function.
|
|
82
121
|
|
|
83
122
|
## Features
|
|
84
123
|
|
|
85
|
-
- Drag-and-drop tile placement
|
|
124
|
+
- Drag-and-drop tile placement with touch support
|
|
86
125
|
- Click-to-select tile placement
|
|
87
126
|
- Keyboard tile placement (type letters to place tiles)
|
|
88
127
|
- Real-time game updates via Firebase
|
|
89
|
-
- Mobile-responsive design
|
|
90
|
-
- Pinch-to-zoom on mobile
|
|
128
|
+
- Mobile-responsive design
|
|
129
|
+
- Pinch-to-zoom on mobile (pinch to zoom out, spread to zoom in)
|
|
130
|
+
- Double-tap to zoom out on mobile
|
|
131
|
+
- Auto-zoom when placing tiles on the board
|
|
91
132
|
|
|
92
133
|
## Architecture
|
|
93
134
|
|
|
@@ -123,6 +164,9 @@ npm run storybook
|
|
|
123
164
|
# Build for production
|
|
124
165
|
npm run rollup
|
|
125
166
|
|
|
167
|
+
# Build CSS only (faster, for CSS-only changes)
|
|
168
|
+
npm run css
|
|
169
|
+
|
|
126
170
|
# Type-check
|
|
127
171
|
npx tsc --noEmit
|
|
128
172
|
|
|
@@ -132,7 +176,7 @@ npx @biomejs/biome check src/
|
|
|
132
176
|
|
|
133
177
|
## License
|
|
134
178
|
|
|
135
|
-
Copyright ©
|
|
179
|
+
Copyright © 2026 Miðeind ehf. Original author: Vilhjálmur Þorsteinsson.
|
|
136
180
|
|
|
137
181
|
Released under the [CC-BY-NC 4.0 license](https://creativecommons.org/licenses/by-nc/4.0/).
|
|
138
182
|
See the LICENSE file for details.
|
|
@@ -328,9 +328,9 @@
|
|
|
328
328
|
|
|
329
329
|
Skrafl-explo.css
|
|
330
330
|
|
|
331
|
-
Styles for
|
|
331
|
+
Styles for Netskrafl using Málstaður colors
|
|
332
332
|
|
|
333
|
-
Copyright ©
|
|
333
|
+
Copyright © 2026 Miðeind ehf.
|
|
334
334
|
Author: Vilhjalmur Thorsteinsson
|
|
335
335
|
|
|
336
336
|
The Creative Commons Attribution-NonCommercial 4.0
|
|
@@ -6535,12 +6535,13 @@ div.netskrafl-container input[type="checkbox"] {
|
|
|
6535
6535
|
}
|
|
6536
6536
|
|
|
6537
6537
|
/* ==========================================================================
|
|
6538
|
-
RESPONSIVE: Mobile
|
|
6538
|
+
RESPONSIVE: Mobile default (overridden by the landscape query below)
|
|
6539
6539
|
========================================================================== */
|
|
6540
6540
|
|
|
6541
|
-
@media all and (max-width: 1023px)
|
|
6542
|
-
/*
|
|
6543
|
-
|
|
6541
|
+
@media all and (max-width: 1023px) {
|
|
6542
|
+
/* Default mobile styles: two-line header, score and tab layout.
|
|
6543
|
+
The landscape query further down overrides these for wide+short
|
|
6544
|
+
viewports with orientation: landscape. */
|
|
6544
6545
|
.netskrafl-container div.scoreleft {
|
|
6545
6546
|
display: inline-block;
|
|
6546
6547
|
position: relative;
|
|
@@ -6677,7 +6678,7 @@ div.netskrafl-container input[type="checkbox"] {
|
|
|
6677
6678
|
text-align: center;
|
|
6678
6679
|
}
|
|
6679
6680
|
.netskrafl-container div.logowrapper {
|
|
6680
|
-
|
|
6681
|
+
display: none;
|
|
6681
6682
|
}
|
|
6682
6683
|
.netskrafl-container div.playerwrapper {
|
|
6683
6684
|
width: 100%;
|
|
@@ -6785,12 +6786,9 @@ div.netskrafl-container input[type="checkbox"] {
|
|
|
6785
6786
|
.netskrafl-container div.player {
|
|
6786
6787
|
min-height: 36px;
|
|
6787
6788
|
}
|
|
6788
|
-
.netskrafl-container div.player-btn
|
|
6789
|
-
width: 84px;
|
|
6790
|
-
padding-top: 6px;
|
|
6791
|
-
}
|
|
6789
|
+
.netskrafl-container div.player-btn,
|
|
6792
6790
|
.netskrafl-container div.robot-btn {
|
|
6793
|
-
width:
|
|
6791
|
+
width: 120px;
|
|
6794
6792
|
padding-top: 6px;
|
|
6795
6793
|
}
|
|
6796
6794
|
.netskrafl-container div.scoreleft,
|
|
@@ -6808,7 +6806,7 @@ div.netskrafl-container input[type="checkbox"] {
|
|
|
6808
6806
|
}
|
|
6809
6807
|
.netskrafl-container div.movelist-container {
|
|
6810
6808
|
height: calc(100vh - 90px);
|
|
6811
|
-
height: calc(100dvh - var(--header-size, 40px) -
|
|
6809
|
+
height: calc(100dvh - var(--header-size, 40px) - 72px);
|
|
6812
6810
|
padding-top: 0px;
|
|
6813
6811
|
padding-bottom: 0px;
|
|
6814
6812
|
}
|
|
@@ -7112,6 +7110,9 @@ div.netskrafl-container input[type="checkbox"] {
|
|
|
7112
7110
|
.netskrafl-container div.game-container div.header-logo {
|
|
7113
7111
|
display: none;
|
|
7114
7112
|
}
|
|
7113
|
+
.netskrafl-container div.game-container div.logowrapper {
|
|
7114
|
+
display: none;
|
|
7115
|
+
}
|
|
7115
7116
|
.netskrafl-container div.board-help {
|
|
7116
7117
|
display: block;
|
|
7117
7118
|
z-index: 2;
|