@arcanejs/toolkit-frontend 0.4.0 → 0.5.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.
@@ -1,5 +1,14 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/util/touch.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/util/index.ts
2
8
  var _react = require('react');
9
+
10
+ // src/util/touch.ts
11
+
3
12
  function switchToMouseMode(ev) {
4
13
  if (ev.movementX === 0 && ev.movementY === 0) return;
5
14
  document.body.classList.remove("touch-mode");
@@ -64,6 +73,25 @@ function trackTouch(touch, move, end) {
64
73
 
65
74
  // src/util/index.ts
66
75
  var calculateClass = (...args) => args.filter((a) => !!a).join(" ");
76
+ var usePreferredColorScheme = () => {
77
+ const [theme, setTheme] = _react.useState.call(void 0, "light");
78
+ _react.useEffect.call(void 0, () => {
79
+ if (typeof window !== "undefined") {
80
+ const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
81
+ setTheme(mediaQuery.matches ? "dark" : "light");
82
+ const handleChange = (event) => {
83
+ setTheme(event.matches ? "dark" : "light");
84
+ };
85
+ mediaQuery.addEventListener("change", handleChange);
86
+ return () => {
87
+ mediaQuery.removeEventListener("change", handleChange);
88
+ };
89
+ }
90
+ }, []);
91
+ return theme;
92
+ };
93
+
94
+
67
95
 
68
96
 
69
97
 
@@ -72,4 +100,4 @@ var calculateClass = (...args) => args.filter((a) => !!a).join(" ");
72
100
 
73
101
 
74
102
 
75
- exports.switchToMouseMode = switchToMouseMode; exports.switchToTouchMode = switchToTouchMode; exports.initialiseListeners = initialiseListeners; exports.usePressable = usePressable; exports.trackTouch = trackTouch; exports.calculateClass = calculateClass;
103
+ exports.__export = __export; exports.switchToMouseMode = switchToMouseMode; exports.switchToTouchMode = switchToTouchMode; exports.initialiseListeners = initialiseListeners; exports.usePressable = usePressable; exports.trackTouch = trackTouch; exports.calculateClass = calculateClass; exports.usePreferredColorScheme = usePreferredColorScheme;
@@ -1,5 +1,14 @@
1
- // src/styling.ts
2
- import { createGlobalStyle, css } from "styled-components";
1
+ import {
2
+ usePreferredColorScheme
3
+ } from "./chunk-E7JSREGM.mjs";
4
+
5
+ // src/styling.tsx
6
+ import {
7
+ createGlobalStyle,
8
+ css,
9
+ ThemeProvider
10
+ } from "styled-components";
11
+ import { jsx } from "react/jsx-runtime";
3
12
  var GlobalStyle = createGlobalStyle`
4
13
  body {
5
14
  &.touch-mode * {
@@ -7,7 +16,8 @@ body {
7
16
  }
8
17
  }
9
18
  `;
10
- var THEME = {
19
+ var DARK_THEME = {
20
+ pageBg: "#333",
11
21
  colorGreen: "#98c379",
12
22
  colorRed: "#e06c75",
13
23
  colorAmber: "#d19a66",
@@ -22,19 +32,64 @@ var THEME = {
22
32
  hintRGB: "66, 134, 244",
23
33
  hintDark1: "#2a77f3",
24
34
  textNormal: "#F3F3F5",
35
+ textActive: "#ffffff",
25
36
  textMuted: "#777777",
37
+ shadows: {
38
+ boxShadowInset: "inset 0px 0px 8px 0px rgba(0, 0, 0, 0.3)",
39
+ textShadow: "0 -1px rgba(0, 0, 0, 0.7)",
40
+ textShadowActive: "0 -1px rgba(0, 0, 0, 0.4)"
41
+ },
42
+ gradients: {
43
+ button: "linear-gradient(to bottom, #4f5053, #343436)",
44
+ buttonHover: "linear-gradient(to bottom, #5e6064, #393a3b)",
45
+ buttonActive: "linear-gradient(to bottom, #242525, #37383a)",
46
+ buttonPressedHover: "linear-gradient(to bottom, #282929, #414243)",
47
+ hintPressed: "linear-gradient(to bottom,#2a77f3,#4286f4)"
48
+ },
26
49
  sizingPx: {
27
50
  spacing: 15,
28
51
  unitHeight: 40
29
52
  }
30
53
  };
54
+ var LIGHT_THEME = {
55
+ pageBg: "#f8f9fa",
56
+ colorGreen: "#22863a",
57
+ colorRed: "#d73a49",
58
+ colorAmber: "#b08800",
59
+ bgDark1: "#e9ecef",
60
+ bg: "#ffffff",
61
+ bgLight1: "#f5f5f5",
62
+ borderDark: "#c7c7c7",
63
+ borderLight: "#d7d7d7",
64
+ borderLighter: "#eaecef",
65
+ borderLighterer: "#f6f8fa",
66
+ hint: "#4286f4",
67
+ hintRGB: "0, 92, 197",
68
+ hintDark1: "#2a77f3",
69
+ textNormal: "#24292e",
70
+ textActive: "#202020",
71
+ textMuted: "#6a737d",
72
+ shadows: {
73
+ boxShadowInset: "inset 0px 0px 8px 0px rgba(0, 0, 0, 0.05)",
74
+ textShadow: "0 1px rgba(255, 255, 255, 0.7)",
75
+ textShadowActive: "0 1px rgba(255, 255, 255, 0.4)"
76
+ },
77
+ gradients: {
78
+ button: "linear-gradient(to bottom, #e1e4e8, #d1d5da)",
79
+ buttonHover: "linear-gradient(to bottom, #d1d5da, #c1c6cc)",
80
+ buttonActive: "linear-gradient(to bottom, #b1b6bc, #d2d6da)",
81
+ buttonPressedHover: "linear-gradient(to bottom, #a1a6ac, #91969c)",
82
+ hintPressed: "linear-gradient(to bottom, #438bff, #85b3ff)"
83
+ },
84
+ sizingPx: DARK_THEME.sizingPx
85
+ };
31
86
  var BaseStyle = createGlobalStyle`
32
87
  * {
33
88
  box-sizing: border-box;
34
89
  }
35
90
 
36
91
  body {
37
- background: #333;
92
+ background: ${(p) => p.theme.pageBg};
38
93
  margin: 0;
39
94
  padding: 0;
40
95
  font-size: 14px;
@@ -43,8 +98,8 @@ body {
43
98
  `;
44
99
  var buttonStateNormal = css`
45
100
  color: ${(p) => p.theme.textNormal};
46
- background: linear-gradient(to bottom, #4f5053, #343436);
47
- text-shadow: 0 -1px rgba(0, 0, 0, 0.7);
101
+ background: ${(p) => p.theme.gradients.button};
102
+ text-shadow: ${(p) => p.theme.shadows.textShadow};
48
103
  box-shadow:
49
104
  inset 0 1px 0 rgba(255, 255, 255, 0.15),
50
105
  0 1px 0 0 rgba(0, 0, 0, 0.25);
@@ -52,14 +107,14 @@ var buttonStateNormal = css`
52
107
  var buttonStateNormalHover = css`
53
108
  color: ${(p) => p.theme.textNormal};
54
109
  outline-color: rgba(243, 243, 245, 0.3);
55
- background: linear-gradient(to bottom, #5e6064, #393a3b);
56
- text-shadow: 0 -1px rgba(0, 0, 0, 0.7);
110
+ background: ${(p) => p.theme.gradients.buttonHover};
111
+ text-shadow: ${(p) => p.theme.shadows.textShadow};
57
112
  `;
58
113
  var buttonStateNormalActive = css`
59
- color: #ffffff;
114
+ color: ${(p) => p.theme.textNormal};
60
115
  outline-color: rgba(255, 255, 255, 0.3);
61
- background: linear-gradient(to bottom, #242525, #37383a);
62
- text-shadow: 0 -1px rgba(0, 0, 0, 0.4);
116
+ background: ${(p) => p.theme.gradients.buttonActive};
117
+ text-shadow: ${(p) => p.theme.shadows.textShadowActive};
63
118
  box-shadow:
64
119
  inset 0 1px 2px rgba(0, 0, 0, 0.2),
65
120
  0 1px 0 0 rgba(255, 255, 255, 0.15);
@@ -72,7 +127,7 @@ var buttonStatePressed = css`
72
127
  var buttonStatePressedHover = css`
73
128
  ${buttonStateNormalActive}
74
129
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 0 0 rgba(255,255,255,0.15);
75
- background: linear-gradient(to bottom, #282929, #414243);
130
+ background: ${(p) => p.theme.gradients.buttonPressedHover};
76
131
  `;
77
132
  var buttonStatePressedActive = buttonStateNormalActive;
78
133
  var buttonStateDisabled = css`
@@ -139,10 +194,15 @@ var touchIndicatorTouching = css`
139
194
  background-color: rgba(${(p) => p.theme.hintRGB}, 0.2);
140
195
  transition: border-color 0s;
141
196
  `;
197
+ var PreferredThemeProvider = ({ dark, light, children }) => {
198
+ const theme = usePreferredColorScheme();
199
+ return /* @__PURE__ */ jsx(ThemeProvider, { theme: theme === "dark" ? dark : light, children });
200
+ };
142
201
 
143
202
  export {
144
203
  GlobalStyle,
145
- THEME,
204
+ DARK_THEME,
205
+ LIGHT_THEME,
146
206
  BaseStyle,
147
207
  buttonStateNormal,
148
208
  buttonStateNormalHover,
@@ -151,5 +211,6 @@ export {
151
211
  buttonDisabled,
152
212
  rectButton,
153
213
  touchIndicatorNormal,
154
- touchIndicatorTouching
214
+ touchIndicatorTouching,
215
+ PreferredThemeProvider
155
216
  };
@@ -1,3 +1,12 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/util/index.ts
8
+ import { useEffect, useState as useState2 } from "react";
9
+
1
10
  // src/util/touch.ts
2
11
  import { useState } from "react";
3
12
  function switchToMouseMode(ev) {
@@ -64,12 +73,31 @@ function trackTouch(touch, move, end) {
64
73
 
65
74
  // src/util/index.ts
66
75
  var calculateClass = (...args) => args.filter((a) => !!a).join(" ");
76
+ var usePreferredColorScheme = () => {
77
+ const [theme, setTheme] = useState2("light");
78
+ useEffect(() => {
79
+ if (typeof window !== "undefined") {
80
+ const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
81
+ setTheme(mediaQuery.matches ? "dark" : "light");
82
+ const handleChange = (event) => {
83
+ setTheme(event.matches ? "dark" : "light");
84
+ };
85
+ mediaQuery.addEventListener("change", handleChange);
86
+ return () => {
87
+ mediaQuery.removeEventListener("change", handleChange);
88
+ };
89
+ }
90
+ }, []);
91
+ return theme;
92
+ };
67
93
 
68
94
  export {
95
+ __export,
69
96
  switchToMouseMode,
70
97
  switchToTouchMode,
71
98
  initialiseListeners,
72
99
  usePressable,
73
100
  trackTouch,
74
- calculateClass
101
+ calculateClass,
102
+ usePreferredColorScheme
75
103
  };
@@ -1,9 +1,7 @@
1
1
  import {
2
+ __export,
2
3
  calculateClass
3
- } from "./chunk-35U577MM.mjs";
4
- import {
5
- __export
6
- } from "./chunk-7P6ASYW6.mjs";
4
+ } from "./chunk-E7JSREGM.mjs";
7
5
 
8
6
  // src/components/core/index.ts
9
7
  var core_exports = {};
@@ -1,13 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkXEIKOLS2js = require('./chunk-XEIKOLS2.js');
4
3
 
5
-
6
- var _chunkMLKGABMKjs = require('./chunk-MLKGABMK.js');
4
+ var _chunk7VTNOX5Ojs = require('./chunk-7VTNOX5O.js');
7
5
 
8
6
  // src/components/core/index.ts
9
7
  var core_exports = {};
10
- _chunkMLKGABMKjs.__export.call(void 0, core_exports, {
8
+ _chunk7VTNOX5Ojs.__export.call(void 0, core_exports, {
11
9
  Icon: () => Icon,
12
10
  TRANSPARENCY_SVG: () => TRANSPARENCY_SVG,
13
11
  TRANSPARENCY_SVG_URI: () => TRANSPARENCY_SVG_URI
@@ -33,7 +31,7 @@ var Span = _styledcomponents.styled.span`
33
31
  'wght' 300,
34
32
  'GRAD' -25;
35
33
  `;
36
- var Icon = ({ icon, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Span, { className: _chunkXEIKOLS2js.calculateClass.call(void 0, props.className, ICON_CLASS), ...props, children: icon });
34
+ var Icon = ({ icon, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Span, { className: _chunk7VTNOX5Ojs.calculateClass.call(void 0, props.className, ICON_CLASS), ...props, children: icon });
37
35
 
38
36
  // src/components/core/index.ts
39
37
  var TRANSPARENCY_SVG = `
@@ -1,5 +1,14 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/styling.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk7VTNOX5Ojs = require('./chunk-7VTNOX5O.js');
4
+
5
+ // src/styling.tsx
6
+
7
+
8
+
9
+
2
10
  var _styledcomponents = require('styled-components');
11
+ var _jsxruntime = require('react/jsx-runtime');
3
12
  var GlobalStyle = _styledcomponents.createGlobalStyle`
4
13
  body {
5
14
  &.touch-mode * {
@@ -7,7 +16,8 @@ body {
7
16
  }
8
17
  }
9
18
  `;
10
- var THEME = {
19
+ var DARK_THEME = {
20
+ pageBg: "#333",
11
21
  colorGreen: "#98c379",
12
22
  colorRed: "#e06c75",
13
23
  colorAmber: "#d19a66",
@@ -22,19 +32,64 @@ var THEME = {
22
32
  hintRGB: "66, 134, 244",
23
33
  hintDark1: "#2a77f3",
24
34
  textNormal: "#F3F3F5",
35
+ textActive: "#ffffff",
25
36
  textMuted: "#777777",
37
+ shadows: {
38
+ boxShadowInset: "inset 0px 0px 8px 0px rgba(0, 0, 0, 0.3)",
39
+ textShadow: "0 -1px rgba(0, 0, 0, 0.7)",
40
+ textShadowActive: "0 -1px rgba(0, 0, 0, 0.4)"
41
+ },
42
+ gradients: {
43
+ button: "linear-gradient(to bottom, #4f5053, #343436)",
44
+ buttonHover: "linear-gradient(to bottom, #5e6064, #393a3b)",
45
+ buttonActive: "linear-gradient(to bottom, #242525, #37383a)",
46
+ buttonPressedHover: "linear-gradient(to bottom, #282929, #414243)",
47
+ hintPressed: "linear-gradient(to bottom,#2a77f3,#4286f4)"
48
+ },
26
49
  sizingPx: {
27
50
  spacing: 15,
28
51
  unitHeight: 40
29
52
  }
30
53
  };
54
+ var LIGHT_THEME = {
55
+ pageBg: "#f8f9fa",
56
+ colorGreen: "#22863a",
57
+ colorRed: "#d73a49",
58
+ colorAmber: "#b08800",
59
+ bgDark1: "#e9ecef",
60
+ bg: "#ffffff",
61
+ bgLight1: "#f5f5f5",
62
+ borderDark: "#c7c7c7",
63
+ borderLight: "#d7d7d7",
64
+ borderLighter: "#eaecef",
65
+ borderLighterer: "#f6f8fa",
66
+ hint: "#4286f4",
67
+ hintRGB: "0, 92, 197",
68
+ hintDark1: "#2a77f3",
69
+ textNormal: "#24292e",
70
+ textActive: "#202020",
71
+ textMuted: "#6a737d",
72
+ shadows: {
73
+ boxShadowInset: "inset 0px 0px 8px 0px rgba(0, 0, 0, 0.05)",
74
+ textShadow: "0 1px rgba(255, 255, 255, 0.7)",
75
+ textShadowActive: "0 1px rgba(255, 255, 255, 0.4)"
76
+ },
77
+ gradients: {
78
+ button: "linear-gradient(to bottom, #e1e4e8, #d1d5da)",
79
+ buttonHover: "linear-gradient(to bottom, #d1d5da, #c1c6cc)",
80
+ buttonActive: "linear-gradient(to bottom, #b1b6bc, #d2d6da)",
81
+ buttonPressedHover: "linear-gradient(to bottom, #a1a6ac, #91969c)",
82
+ hintPressed: "linear-gradient(to bottom, #438bff, #85b3ff)"
83
+ },
84
+ sizingPx: DARK_THEME.sizingPx
85
+ };
31
86
  var BaseStyle = _styledcomponents.createGlobalStyle`
32
87
  * {
33
88
  box-sizing: border-box;
34
89
  }
35
90
 
36
91
  body {
37
- background: #333;
92
+ background: ${(p) => p.theme.pageBg};
38
93
  margin: 0;
39
94
  padding: 0;
40
95
  font-size: 14px;
@@ -43,8 +98,8 @@ body {
43
98
  `;
44
99
  var buttonStateNormal = _styledcomponents.css`
45
100
  color: ${(p) => p.theme.textNormal};
46
- background: linear-gradient(to bottom, #4f5053, #343436);
47
- text-shadow: 0 -1px rgba(0, 0, 0, 0.7);
101
+ background: ${(p) => p.theme.gradients.button};
102
+ text-shadow: ${(p) => p.theme.shadows.textShadow};
48
103
  box-shadow:
49
104
  inset 0 1px 0 rgba(255, 255, 255, 0.15),
50
105
  0 1px 0 0 rgba(0, 0, 0, 0.25);
@@ -52,14 +107,14 @@ var buttonStateNormal = _styledcomponents.css`
52
107
  var buttonStateNormalHover = _styledcomponents.css`
53
108
  color: ${(p) => p.theme.textNormal};
54
109
  outline-color: rgba(243, 243, 245, 0.3);
55
- background: linear-gradient(to bottom, #5e6064, #393a3b);
56
- text-shadow: 0 -1px rgba(0, 0, 0, 0.7);
110
+ background: ${(p) => p.theme.gradients.buttonHover};
111
+ text-shadow: ${(p) => p.theme.shadows.textShadow};
57
112
  `;
58
113
  var buttonStateNormalActive = _styledcomponents.css`
59
- color: #ffffff;
114
+ color: ${(p) => p.theme.textNormal};
60
115
  outline-color: rgba(255, 255, 255, 0.3);
61
- background: linear-gradient(to bottom, #242525, #37383a);
62
- text-shadow: 0 -1px rgba(0, 0, 0, 0.4);
116
+ background: ${(p) => p.theme.gradients.buttonActive};
117
+ text-shadow: ${(p) => p.theme.shadows.textShadowActive};
63
118
  box-shadow:
64
119
  inset 0 1px 2px rgba(0, 0, 0, 0.2),
65
120
  0 1px 0 0 rgba(255, 255, 255, 0.15);
@@ -72,7 +127,7 @@ var buttonStatePressed = _styledcomponents.css`
72
127
  var buttonStatePressedHover = _styledcomponents.css`
73
128
  ${buttonStateNormalActive}
74
129
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 0 0 rgba(255,255,255,0.15);
75
- background: linear-gradient(to bottom, #282929, #414243);
130
+ background: ${(p) => p.theme.gradients.buttonPressedHover};
76
131
  `;
77
132
  var buttonStatePressedActive = buttonStateNormalActive;
78
133
  var buttonStateDisabled = _styledcomponents.css`
@@ -139,6 +194,12 @@ var touchIndicatorTouching = _styledcomponents.css`
139
194
  background-color: rgba(${(p) => p.theme.hintRGB}, 0.2);
140
195
  transition: border-color 0s;
141
196
  `;
197
+ var PreferredThemeProvider = ({ dark, light, children }) => {
198
+ const theme = _chunk7VTNOX5Ojs.usePreferredColorScheme.call(void 0, );
199
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _styledcomponents.ThemeProvider, { theme: theme === "dark" ? dark : light, children });
200
+ };
201
+
202
+
142
203
 
143
204
 
144
205
 
@@ -152,4 +213,4 @@ var touchIndicatorTouching = _styledcomponents.css`
152
213
 
153
214
 
154
215
 
155
- exports.GlobalStyle = GlobalStyle; exports.THEME = THEME; exports.BaseStyle = BaseStyle; exports.buttonStateNormal = buttonStateNormal; exports.buttonStateNormalHover = buttonStateNormalHover; exports.buttonStateNormalActive = buttonStateNormalActive; exports.buttonPressed = buttonPressed; exports.buttonDisabled = buttonDisabled; exports.rectButton = rectButton; exports.touchIndicatorNormal = touchIndicatorNormal; exports.touchIndicatorTouching = touchIndicatorTouching;
216
+ exports.GlobalStyle = GlobalStyle; exports.DARK_THEME = DARK_THEME; exports.LIGHT_THEME = LIGHT_THEME; exports.BaseStyle = BaseStyle; exports.buttonStateNormal = buttonStateNormal; exports.buttonStateNormalHover = buttonStateNormalHover; exports.buttonStateNormalActive = buttonStateNormalActive; exports.buttonPressed = buttonPressed; exports.buttonDisabled = buttonDisabled; exports.rectButton = rectButton; exports.touchIndicatorNormal = touchIndicatorNormal; exports.touchIndicatorTouching = touchIndicatorTouching; exports.PreferredThemeProvider = PreferredThemeProvider;
@@ -2,11 +2,10 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkKNYDA6D6js = require('../../chunk-KNYDA6D6.js');
6
- require('../../chunk-XEIKOLS2.js');
7
- require('../../chunk-MLKGABMK.js');
5
+ var _chunkT3QSZARMjs = require('../../chunk-T3QSZARM.js');
6
+ require('../../chunk-7VTNOX5O.js');
8
7
 
9
8
 
10
9
 
11
10
 
12
- exports.Icon = _chunkKNYDA6D6js.Icon; exports.TRANSPARENCY_SVG = _chunkKNYDA6D6js.TRANSPARENCY_SVG; exports.TRANSPARENCY_SVG_URI = _chunkKNYDA6D6js.TRANSPARENCY_SVG_URI;
11
+ exports.Icon = _chunkT3QSZARMjs.Icon; exports.TRANSPARENCY_SVG = _chunkT3QSZARMjs.TRANSPARENCY_SVG; exports.TRANSPARENCY_SVG_URI = _chunkT3QSZARMjs.TRANSPARENCY_SVG_URI;
@@ -2,9 +2,8 @@ import {
2
2
  Icon,
3
3
  TRANSPARENCY_SVG,
4
4
  TRANSPARENCY_SVG_URI
5
- } from "../../chunk-UJVH3PQF.mjs";
6
- import "../../chunk-35U577MM.mjs";
7
- import "../../chunk-7P6ASYW6.mjs";
5
+ } from "../../chunk-MESQQRK3.mjs";
6
+ import "../../chunk-E7JSREGM.mjs";
8
7
  export {
9
8
  Icon,
10
9
  TRANSPARENCY_SVG,