@mideind/netskrafl-react 3.4.6 → 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 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 its styles:
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
- 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
- );
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
- | `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 |
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 with touch support
90
- - Pinch-to-zoom on mobile devices
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 © 2025 Miðeind ehf. Original author: Vilhjálmur Þorsteinsson.
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 netskrafl.is using Málstaður colors
331
+ Styles for Netskrafl using Málstaður colors
332
332
 
333
- Copyright © 2025 Miðeind ehf.
333
+ Copyright © 2026 Miðeind ehf.
334
334
  Author: Vilhjalmur Thorsteinsson
335
335
 
336
336
  The Creative Commons Attribution-NonCommercial 4.0
@@ -6786,12 +6786,9 @@ div.netskrafl-container input[type="checkbox"] {
6786
6786
  .netskrafl-container div.player {
6787
6787
  min-height: 36px;
6788
6788
  }
6789
- .netskrafl-container div.player-btn {
6790
- width: 84px;
6791
- padding-top: 6px;
6792
- }
6789
+ .netskrafl-container div.player-btn,
6793
6790
  .netskrafl-container div.robot-btn {
6794
- width: 84px;
6791
+ width: 120px;
6795
6792
  padding-top: 6px;
6796
6793
  }
6797
6794
  .netskrafl-container div.scoreleft,
@@ -6809,7 +6806,7 @@ div.netskrafl-container input[type="checkbox"] {
6809
6806
  }
6810
6807
  .netskrafl-container div.movelist-container {
6811
6808
  height: calc(100vh - 90px);
6812
- height: calc(100dvh - var(--header-size, 40px) - 44px);
6809
+ height: calc(100dvh - var(--header-size, 40px) - 72px);
6813
6810
  padding-top: 0px;
6814
6811
  padding-bottom: 0px;
6815
6812
  }