@enigma-lake/mines-play-controller-sdk 2.1.3 → 2.1.5

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,14 +1,23 @@
1
1
  # MinesPlayController
2
2
 
3
3
  The `MinesPlayController` component is a key part of the gameplay
4
- interface, allowing users to initiate a play or cash out based on their
5
- current game state. It supports manual play, autoplay, dynamic currency
6
- handling, play amount adjustments, and classic-game--specific
7
- configuration.
4
+ interface.\
5
+ It allows users to initiate a play or cash out based on their current
6
+ game state.
7
+
8
+ It supports:
9
+
10
+ - Manual play
11
+ - Autoplay
12
+ - Dynamic currency handling
13
+ - Play amount adjustments
14
+ - Classic-game configuration
15
+ - External button styling configuration
16
+ - External switcher styling configuration
8
17
 
9
18
  ------------------------------------------------------------------------
10
19
 
11
- ## Component Overview
20
+ # Component Overview
12
21
 
13
22
  The `MinesPlayController` allows the user to:
14
23
 
@@ -19,18 +28,20 @@ The `MinesPlayController` allows the user to:
19
28
  - Toggle between manual play and autoplay
20
29
  - Configure mines count (when enabled)
21
30
  - Apply classic game layout and styling overrides
31
+ - Fully customize controller button styles
32
+ - Fully customize autoplay switch styles
22
33
 
23
34
  ------------------------------------------------------------------------
24
35
 
25
- ## Setup
36
+ # Setup
26
37
 
27
- ### 1. Install the package using npm
38
+ ## 1. Install the package
28
39
 
29
40
  ``` bash
30
41
  npm install @enigma-lake/mines-play-controller-sdk
31
42
  ```
32
43
 
33
- ### 2. Import the component and styles
44
+ ## 2. Import component and styles
34
45
 
35
46
  ``` tsx
36
47
  import {
@@ -44,208 +55,239 @@ import "@enigma-lake/mines-play-controller-sdk/dist/style.css";
44
55
 
45
56
  ------------------------------------------------------------------------
46
57
 
47
- ## Context & Provider
48
-
49
- ### `AutoManualPlayProvider`
58
+ # Context & Provider
50
59
 
51
- The `AutoManualPlayProvider` wraps the `MinesPlayController`, managing
52
- both manual play and autoplay. It uses React Context to provide game
53
- state and actions throughout the component tree.
60
+ ## AutoManualPlayProvider
54
61
 
55
- **Features:**
62
+ Wraps the controller and manages:
56
63
 
57
- - Manages game mode (MANUAL / AUTOPLAY)
58
- - Controls autoplay flow, rounds, and termination
59
- - Exposes state and callbacks to child components
64
+ - MANUAL / AUTOPLAY modes
65
+ - Autoplay lifecycle
66
+ - Internal state management
60
67
 
61
68
  ------------------------------------------------------------------------
62
69
 
63
- ## Props
70
+ # Props
64
71
 
65
- ### 1. StylingProps
72
+ ## StylingProps
66
73
 
67
- Controls visual appearance of the controller.
74
+ Controls controller layout and styling.
68
75
 
69
- - **`panel`**
70
- - `bgColorHex`: Hex color for the controller background
71
- - `bottom`: Bottom offset relative to the viewport
72
- - **`classicGame` (optional)**\
73
- Styling overrides applied when `isClassicGame` is enabled.
74
- - `dropdown.bgColorHex`: Background color for dropdown menus
75
- - `forceLeftStyle`: Forces left-aligned layout style
76
-
77
- ------------------------------------------------------------------------
76
+ ### panel
78
77
 
79
- ### 2. CurrencyProps
78
+ - `bgColorHex`: Background color
79
+ - `bottom`: Bottom offset
80
+ - `opacity`: Optional opacity
80
81
 
81
- Handles currency-related configuration.
82
+ ### classicGame (optional)
82
83
 
83
- - **`currencyOptions`**
84
- - `currentCurrency`: Currently selected currency
85
- - `currencies`: List of available currencies
86
- - `winText`: Display text for winnings
84
+ - `dropdown.bgColorHex`
85
+ - `forceLeftStyle`
87
86
 
88
87
  ------------------------------------------------------------------------
89
88
 
90
- ### 3. ActionsProps
89
+ ## CurrencyProps
91
90
 
92
- Defines callbacks for user actions.
93
-
94
- - **`onPlay`**: Triggered when a manual play starts
95
- - **`onAutoPlay`**: Triggered when autoplay starts\
96
- `(selection, next, stop, state) => void`
97
- - **`onAutoPlayStop` (optional)**: Triggered when autoplay is stopped
98
- manually
99
- - **`onCashout`**: Triggered when the user cashes out
91
+ ``` ts
92
+ currencyOptions: {
93
+ current: CurrencyMeta;
94
+ available: CurrencyMeta[];
95
+ }
96
+ ```
100
97
 
101
98
  ------------------------------------------------------------------------
102
99
 
103
- ### 4. PlaySettingsProps
100
+ ## ActionsProps
104
101
 
105
- Controls game state, limits, and UI behavior.
102
+ - `onPlay`
103
+ - `onAutoPlay(selection, next, stop, state)`
104
+ - `onAutoPlayStop`
105
+ - `onCashout`
106
106
 
107
- - **`isPlaying`**: Whether a round is currently in progress
107
+ ------------------------------------------------------------------------
108
108
 
109
- - **`canCashout`**: Whether the user can cash out
109
+ ## PlaySettingsProps
110
110
 
111
- - **`disabledController`**: Disables all controller interactions
111
+ - `isPlaying`
112
+ - `canCashout`
113
+ - `disabledController`
114
+ - `displayController`
115
+ - `classicGame`
116
+ - `showAutoPlayToast`
117
+ - `playHook`
118
+ - `autoPlayDelay`
119
+ - `totalBalance`
112
120
 
113
- - **`displayController`**: Toggles controller visibility
121
+ ------------------------------------------------------------------------
114
122
 
115
- - **`classicGame` (optional)**\
116
- Mines-related settings for classic or configurable modes.
123
+ # External Button Styling
124
+
125
+ You can fully control controller buttons externally.
126
+
127
+ ## playControllerButtons
128
+
129
+ ``` ts
130
+ playControllerButtons: {
131
+ textStyle: {
132
+ color: "#041926",
133
+ fontSize: "16px",
134
+ fontWeight: 800,
135
+ lineHeight: "125%",
136
+ letterSpacing: "0.8px",
137
+ textTransform: "none",
138
+ disableOpacity: 0.4
139
+ },
140
+
141
+ buttons: {
142
+ play: {
143
+ label: "Place Bet",
144
+ labelDisabled: "Pick a tile",
145
+ backgroundColor: "#EAFF00",
146
+ pressedBackgroundColor: "#C7D807",
147
+ disabledOpacity: 0.4,
148
+ },
117
149
 
118
- - `disabledMenu`: Disables the mines selector menu
119
- - `currentMines`: Currently selected number of mines
120
- - `onMinesChange(mines)`: Callback when mines count changes
150
+ startAutoplay: {
151
+ label: "Start Autoplay",
152
+ backgroundColor: "#EAFF00",
153
+ pressedBackgroundColor: "#C7D807",
154
+ disabledOpacity: 0.4,
155
+ },
121
156
 
122
- - **`showAutoPlayToast`**: Displays autoplay-related toast messages
157
+ stopAutoplay: {
158
+ label: "Stop Autoplay",
159
+ backgroundColor: "#F5A6C7",
160
+ pressedBackgroundColor: "#BA6E8E",
161
+ disabledOpacity: 0.4,
162
+ },
123
163
 
124
- - **`playHook`**
164
+ cashout: {
165
+ label: "Cashout",
166
+ backgroundColor: "#4ADEC6",
167
+ pressedBackgroundColor: "#269D89",
168
+ disabledOpacity: 0.4,
169
+ },
125
170
 
126
- - `playLimits`: Min/max limits for play amount
127
- - `playAmount`: Current bet amount
128
- - `setPlayAmount(value)`
171
+ selectPlayAmount: {
172
+ label: "Select Bet Amount",
173
+ backgroundColor: "#4ADEC6",
174
+ pressedBackgroundColor: "#269D89",
175
+ disabledOpacity: 0.4,
176
+ },
177
+ },
178
+ }
179
+ ```
129
180
 
130
- - **`autoPlayDelay` (optional)**: Delay (ms) before autoplay starts
181
+ ### Button Styling Behavior
131
182
 
132
- - **`totalBalance`**: Available balance for the selected currency
183
+ - `backgroundColor` overrides default gradient styles
184
+ - `pressedBackgroundColor` applies on mouse down / key press
185
+ - `disableOpacity` affects **text color only**
186
+ - `labelDisabled` applies only to `play` button when disabled AND
187
+ playing
188
+ - `textTransform` prevents automatic uppercase transformation
189
+ - Currency-based styles are ignored when custom config is provided
133
190
 
134
191
  ------------------------------------------------------------------------
135
192
 
136
- ### 5. Widgets
193
+ # External Switcher Styling
137
194
 
138
- Custom UI extensions.
195
+ You can configure the autoplay switch component.
139
196
 
140
- - **`leftWidgets`**: Widgets rendered on the left side
141
- - **`centerWidgets`**: Widgets rendered in the center
142
- - **`rightWidgets`**: Widgets rendered on the right side
197
+ ## playControllerSwitcher
143
198
 
144
- ------------------------------------------------------------------------
199
+ ``` ts
200
+ playControllerSwitcher: {
201
+ checked: {
202
+ thumb: "#fff",
203
+ slider: "#10be68",
204
+ },
205
+ unchecked: {
206
+ thumb: "#30424C",
207
+ slider: "#132A36",
208
+ }
209
+ }
210
+ ```
211
+
212
+ ### Switch Styling Behavior
145
213
 
146
- ### 6. Mode Flag
214
+ When `playControllerSwitcher` is provided:
147
215
 
148
- - **`isClassicGame` (optional)**\
149
- Enables classic game mode and activates related styling and play
150
- settings.
216
+ - Slider background uses `check.slider` when enabled
217
+ - Slider background uses `unchecked.slider` when disabled
218
+ - Thumb uses `check.thumb` when enabled
219
+ - Thumb uses `unchecked.thumb` when disabled
220
+ - Currency-based styling is ignored
221
+ - Default SCSS remains untouched if config is absent
151
222
 
152
223
  ------------------------------------------------------------------------
153
224
 
154
- ## Example Usage
225
+ # Full Example Configuration
155
226
 
156
227
  ``` tsx
157
- import "@enigma-lake/mines-play-controller-sdk/dist/style.css";
158
- import {
159
- AutoManualPlayProvider,
160
- AUTO_PLAY_STATE,
161
- } from "@enigma-lake/mines-play-controller-sdk";
162
- import { Currency } from "@enigma-lake/zoot-platform-sdk";
163
-
164
- const GameExample = () => {
165
- const config = {
166
- currencyOptions: {
167
- currentCurrency: Currency.SWEEPS,
168
- currencies: [Currency.SWEEPS, Currency.GOLD],
169
- winText: "0.00 SC",
170
- },
171
-
172
- onPlay: () => console.log("Play clicked"),
173
-
174
- onAutoPlay: (selection, next, stop, state) => {
175
- console.log("Autoplay state:", state);
176
- next();
177
- },
228
+ const config = {
229
+ currencyOptions: { ... },
178
230
 
179
- onAutoPlayStop: () => console.log("Autoplay stopped"),
231
+ onPlay: () => {},
232
+ onAutoPlay: () => {},
233
+ onCashout: () => {},
180
234
 
181
- onCashout: () => console.log("Cashout"),
235
+ playOptions: { ... },
182
236
 
183
- playOptions: {
184
- displayController: true,
185
- isPlaying: false,
186
- canCashout: false,
187
- disabledController: false,
237
+ panel: {
238
+ bottom: "15px",
239
+ bgColorHex: "#081E64",
240
+ },
188
241
 
189
- classicGame: {
190
- disabledMenu: false,
191
- currentMines: 3,
192
- onMinesChange: (mines) => console.log("Mines:", mines),
242
+ playControllerButtons: {
243
+ textStyle: {
244
+ color: "#041926",
245
+ textTransform: "none",
246
+ disableOpacity: 0.4,
247
+ },
248
+ buttons: {
249
+ play: {
250
+ label: "Place Bet",
251
+ labelDisabled: "Pick a tile",
252
+ backgroundColor: "#EAFF00",
253
+ pressedBackgroundColor: "#C7D807",
193
254
  },
194
-
195
- totalBalance: 1000,
196
-
197
- showAutoPlayToast: ({ type, message }) =>
198
- console.log(`${type}: ${message}`),
199
-
200
- playHook: () => ({
201
- playLimits: { min: 1, max: 100 },
202
- playAmount: 10,
203
- setPlayAmount: (value) => console.log("Amount:", value),
204
- }),
205
255
  },
256
+ },
206
257
 
207
- panel: {
208
- bottom: "15px",
209
- bgColorHex: "#081E64",
258
+ playControllerSwitcher: {
259
+ checked: {
260
+ thumb: "#fff",
261
+ slider: "#10be68",
210
262
  },
211
-
212
- classicGame: {
213
- dropdown: {
214
- bgColorHex: "#0B2A8F",
215
- },
216
- forceLeftStyle: true,
263
+ unchecked: {
264
+ thumb: "#30424C",
265
+ slider: "#132A36",
217
266
  },
218
-
219
- leftWidgets: [],
220
- centerWidgets: [],
221
- rightWidgets: [],
222
-
223
- isClassicGame: true,
224
- };
225
-
226
- return (
227
- <AutoManualPlayProvider config={config}>
228
- {() => null}
229
- </AutoManualPlayProvider>
230
- );
267
+ },
231
268
  };
232
269
  ```
233
270
 
234
271
  ------------------------------------------------------------------------
235
272
 
236
- ## Key Features
273
+ # Key Features
237
274
 
238
- 1. Dynamic currency support
239
- 2. Manual and autoplay modes
240
- 3. Play amount validation and limits
241
- 4. Classic-game styling and behavior overrides
242
- 5. Extensible widget system
275
+ 1. Manual & Autoplay modes\
276
+ 2. External button styling support\
277
+ 3. External switcher styling support\
278
+ 4. Currency fallback behavior\
279
+ 5. Text transformation control\
280
+ 6. Text-only disable opacity\
281
+ 7. Label override when disabled\
282
+ 8. Fully backward compatible styling system
243
283
 
244
284
  ------------------------------------------------------------------------
245
285
 
246
- ## Development Notes
286
+ # Development Notes
247
287
 
248
- - Play amounts are validated against limits and balance
249
- - Autoplay lifecycle is fully controlled via callbacks
250
- - Classic game configuration is opt-in via `isClassicGame`
251
- - Component is fully responsive and layout-aware
288
+ - Styling system is fully optional
289
+ - Existing integrations will not break
290
+ - Default currency behavior applies unless overridden
291
+ - Text opacity is calculated dynamically using RGBA conversion
292
+ - Pressed states are handled via inline override
293
+ - Switcher styling activates only when configuration is provided
@@ -0,0 +1,28 @@
1
+ import type React from "react";
2
+ import { PlayControllerButtonsConfig, PlayControllerButtonId } from "../../types/playController";
3
+ type CSSVarsStyle = React.CSSProperties & {
4
+ [key: `--${string}`]: string | number;
5
+ };
6
+ type ResolveLabelOpts = {
7
+ disabled?: boolean;
8
+ isPlaying?: boolean;
9
+ };
10
+ type ResolveStyleOpts = {
11
+ pressed: boolean;
12
+ disabled: boolean;
13
+ };
14
+ export declare function usePlayControllerButtons(params: {
15
+ theme?: PlayControllerButtonsConfig;
16
+ }): {
17
+ pressedId: PlayControllerButtonId | null;
18
+ setPressedId: React.Dispatch<React.SetStateAction<PlayControllerButtonId | null>>;
19
+ setPressed: (id: PlayControllerButtonId, value: boolean) => void;
20
+ getPressHandlers: (id: PlayControllerButtonId) => {
21
+ onMouseDown: () => void;
22
+ onMouseUp: () => void;
23
+ onMouseLeave: () => void;
24
+ };
25
+ resolveLabel: (id: PlayControllerButtonId, fallback: string, opts?: ResolveLabelOpts) => string;
26
+ resolveStyle: (id: PlayControllerButtonId, opts: ResolveStyleOpts) => CSSVarsStyle | undefined;
27
+ };
28
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReactNode, ReactElement } from 'react';
1
+ import React$1, { ReactNode, ReactElement } from 'react';
2
2
  import { CurrencyProps, PlayLimitsV2 } from '@enigma-lake/zoot-platform-sdk';
3
3
 
4
4
  declare enum GAME_MODE {
@@ -29,6 +29,7 @@ type StylingProps = {
29
29
  panel: {
30
30
  bottom?: string;
31
31
  bgColorHex: string;
32
+ opacity?: number;
32
33
  };
33
34
  classicGame?: {
34
35
  dropdown: {
@@ -65,6 +66,48 @@ type PlaySettingsProps = {
65
66
  autoPlayDelay?: number;
66
67
  totalBalance: number;
67
68
  };
69
+ type TextTransformOption = "none" | "uppercase" | "lowercase" | "capitalize";
70
+ type PlayControllerTextStyle = Omit<React$1.CSSProperties, "textTransform"> & {
71
+ textTransform?: React$1.CSSProperties["textTransform"];
72
+ disableOpacity?: number;
73
+ };
74
+ type PlayControllerButtonId = "play" | "startAutoplay" | "stopAutoplay" | "cashout" | "selectPlayAmount";
75
+ type PlayControllerButtonVariant = {
76
+ backgroundColor: string;
77
+ pressedBackgroundColor?: string;
78
+ textTransform?: TextTransformOption;
79
+ style?: React$1.CSSProperties;
80
+ pressedStyle?: React$1.CSSProperties;
81
+ disabledStyle?: React$1.CSSProperties;
82
+ };
83
+ type PlayControllerButtonConfig<VariantKey extends string> = {
84
+ label: string;
85
+ /**
86
+ * Only intended for `play` button:
87
+ * shown when button is disabled AND game is playing.
88
+ */
89
+ labelDisabled?: string;
90
+ variant?: VariantKey;
91
+ backgroundColor?: string;
92
+ pressedBackgroundColor?: string;
93
+ textTransform?: TextTransformOption;
94
+ style?: React$1.CSSProperties;
95
+ pressedStyle?: React$1.CSSProperties;
96
+ disabledStyle?: React$1.CSSProperties;
97
+ };
98
+ type PlayControllerSwitcherState = {
99
+ thumb?: string;
100
+ slider?: string;
101
+ };
102
+ type PlayControllerSwitcherConfig = {
103
+ checked?: PlayControllerSwitcherState;
104
+ unchecked?: PlayControllerSwitcherState;
105
+ };
106
+ type PlayControllerButtonsConfig<VariantKey extends string = "primary" | "danger" | "success"> = {
107
+ textStyle?: PlayControllerTextStyle;
108
+ variants?: Record<VariantKey, PlayControllerButtonVariant>;
109
+ buttons: Partial<Record<PlayControllerButtonId, PlayControllerButtonConfig<VariantKey>>>;
110
+ };
68
111
  type PlayControllerProps = StylingProps & ActionsProps & {
69
112
  currencyOptions: CurrencyProps;
70
113
  playOptions: PlaySettingsProps;
@@ -72,6 +115,8 @@ type PlayControllerProps = StylingProps & ActionsProps & {
72
115
  rightWidgets: Widget[];
73
116
  centerWidgets: Widget[];
74
117
  isClassicGame?: boolean;
118
+ playControllerButtons?: PlayControllerButtonsConfig;
119
+ playControllerSwitcher?: PlayControllerSwitcherConfig;
75
120
  };
76
121
 
77
122
  interface AutoManualPlayStateContextType {