@adriansteffan/reactive 0.1.25 → 0.1.27
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/.claude/settings.local.json +5 -1
- package/dist/{mod-pa8Hci6M.js → mod-DExpgO5y.js} +8836 -8693
- package/dist/mod.d.ts +111 -0
- package/dist/reactive.es.js +55 -51
- package/dist/reactive.umd.js +628 -628
- package/dist/style.css +1 -1
- package/dist/{web-CWLGQMq-.js → web-DiCVmMf2.js} +1 -1
- package/dist/{web-DvZ82oLB.js → web-ioVs_hcC.js} +1 -1
- package/package.json +1 -1
- package/src/components/checkdevice.tsx +6 -1
- package/src/components/enterfullscreen.tsx +4 -1
- package/src/components/experimentrunner.tsx +10 -4
- package/src/components/plaininput.tsx +7 -3
- package/src/components/quest.tsx +12 -6
- package/src/components/text.tsx +6 -4
- package/src/components/tutorial.tsx +13 -11
- package/src/components/upload.tsx +9 -11
- package/src/index.css +2 -1
- package/src/mod.tsx +2 -0
- package/src/utils/common.ts +1 -0
- package/src/utils/theme.ts +63 -0
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { BaseComponentProps } from '../mod';
|
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { registerSimulation } from '../utils/simulation';
|
|
4
4
|
import { registerFlattener } from '../utils/upload';
|
|
5
|
+
import { useTheme, t } from '../utils/theme';
|
|
5
6
|
|
|
6
7
|
registerFlattener('CheckDevice', 'session');
|
|
7
8
|
|
|
@@ -164,12 +165,16 @@ function CheckDevice({
|
|
|
164
165
|
gatherDeviceInfo();
|
|
165
166
|
}, [check, data, updateStore, next]);
|
|
166
167
|
|
|
168
|
+
const th = t(useTheme());
|
|
169
|
+
|
|
167
170
|
return showContent ? (
|
|
171
|
+
<div className={`min-h-screen ${th.containerBg}`}>
|
|
168
172
|
<div className='max-w-prose mx-auto mt-20 mb-20 px-4'>
|
|
169
|
-
<article className=
|
|
173
|
+
<article className={`prose prose-2xl ${th.prose} text-xl ${th.proseLink} prose-a:underline prose-h1:text-4xl prose-h1:mb-10 prose-h1:font-bold prose-p:mb-4 prose-strong:font-bold ${th.text} leading-relaxed`}>
|
|
170
174
|
{content}
|
|
171
175
|
</article>
|
|
172
176
|
</div>
|
|
177
|
+
</div>
|
|
173
178
|
) : null;
|
|
174
179
|
}
|
|
175
180
|
|
|
@@ -6,6 +6,7 @@ import Text from '../components/text';
|
|
|
6
6
|
import { StatusBar } from '@capacitor/status-bar';
|
|
7
7
|
import { ImmersiveMode } from '@adriansteffan/immersive-mode';
|
|
8
8
|
import { Capacitor } from '@capacitor/core';
|
|
9
|
+
import { useTheme, t } from '../utils/theme';
|
|
9
10
|
|
|
10
11
|
registerFlattener('EnterFullscreen', 'session');
|
|
11
12
|
registerSimulation('EnterFullscreen', noopSimulate, {});
|
|
@@ -129,8 +130,10 @@ export default function EnterFullscreen({
|
|
|
129
130
|
}, [removeListenersAndTimeout]);
|
|
130
131
|
|
|
131
132
|
|
|
133
|
+
const th = t(useTheme());
|
|
134
|
+
|
|
132
135
|
if (isWaiting) {
|
|
133
|
-
return <div className={`min-h-screen ${containerClass ??
|
|
136
|
+
return <div className={`min-h-screen ${containerClass ?? th.containerBg}`} />;
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
return (
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
resolveSimulation,
|
|
18
18
|
} from '../utils/simulation';
|
|
19
19
|
import { useHybridSimulationDisabled } from './experimentprovider';
|
|
20
|
+
import { ThemeContext, t } from '../utils/theme';
|
|
20
21
|
|
|
21
22
|
import Upload from './upload';
|
|
22
23
|
import Text from './text';
|
|
@@ -406,22 +407,26 @@ export default function ExperimentRunner({
|
|
|
406
407
|
componentToRender = <></>;
|
|
407
408
|
}
|
|
408
409
|
|
|
410
|
+
const themeValue = config.theme ?? 'light';
|
|
411
|
+
const th = t(themeValue);
|
|
412
|
+
|
|
409
413
|
return (
|
|
414
|
+
<ThemeContext.Provider value={themeValue}>
|
|
410
415
|
<div className='w-full h-full'>
|
|
411
416
|
<div
|
|
412
417
|
className={` ${
|
|
413
418
|
config.showProgressBar ? '' : 'hidden '
|
|
414
419
|
} px-4 mt-4 sm:mt-12 max-w-2xl mx-auto`}
|
|
415
420
|
>
|
|
416
|
-
<div className=
|
|
421
|
+
<div className={`flex-1 h-6 ${th.progressBg} rounded-full overflow-hidden`}>
|
|
417
422
|
<div
|
|
418
|
-
className={`h-full
|
|
419
|
-
progress > 0 ?
|
|
423
|
+
className={`h-full ${th.progressBg} rounded-full duration-300 ${
|
|
424
|
+
progress > 0 ? ` border-black border-2` : ''
|
|
420
425
|
}`}
|
|
421
426
|
style={{
|
|
422
427
|
width: `${progress * 100}%`,
|
|
423
428
|
backgroundImage: `repeating-linear-gradient(
|
|
424
|
-
-45deg,
|
|
429
|
+
-45deg, ${th.progressStripe1}, ${th.progressStripe1} 10px, ${th.progressStripe2} 10px, ${th.progressStripe2} 20px
|
|
425
430
|
)`,
|
|
426
431
|
transition: 'width 300ms ease-in-out',
|
|
427
432
|
}}
|
|
@@ -430,5 +435,6 @@ export default function ExperimentRunner({
|
|
|
430
435
|
</div>
|
|
431
436
|
{componentToRender}
|
|
432
437
|
</div>
|
|
438
|
+
</ThemeContext.Provider>
|
|
433
439
|
);
|
|
434
440
|
}
|
|
@@ -3,6 +3,7 @@ import { useState } from 'react';
|
|
|
3
3
|
import { registerSimulation } from '../utils/simulation';
|
|
4
4
|
import { registerFlattener } from '../utils/upload';
|
|
5
5
|
import { uniform } from '../utils/distributions';
|
|
6
|
+
import { useTheme, t } from '../utils/theme';
|
|
6
7
|
|
|
7
8
|
registerFlattener('PlainInput', 'session');
|
|
8
9
|
|
|
@@ -40,6 +41,7 @@ function PlainInput({
|
|
|
40
41
|
storeupdate?: (entry: string) => { [key: string]: any };
|
|
41
42
|
placeholder?: string;
|
|
42
43
|
}) {
|
|
44
|
+
const th = t(useTheme());
|
|
43
45
|
const [inputValue, setInputValue] = useState('');
|
|
44
46
|
|
|
45
47
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
@@ -54,9 +56,10 @@ function PlainInput({
|
|
|
54
56
|
};
|
|
55
57
|
|
|
56
58
|
return (
|
|
59
|
+
<div className={`min-h-screen ${th.containerBg}`}>
|
|
57
60
|
<div className={`max-w-prose mx-auto ${className} mt-20 mb-20 px-4 `}>
|
|
58
61
|
<article
|
|
59
|
-
className={`prose prose-2xl prose
|
|
62
|
+
className={`prose prose-2xl ${th.prose} text-xl ${th.proseLink} prose-a:underline prose-h1:text-4xl prose-h1:mb-10 prose-h1:font-bold prose-p:mb-4 prose-strong:font-bold ${th.text} leading-relaxed
|
|
60
63
|
${animate ? 'animate-slide-down opacity-0' : ''}`}
|
|
61
64
|
>
|
|
62
65
|
{content}
|
|
@@ -68,7 +71,7 @@ function PlainInput({
|
|
|
68
71
|
value={inputValue}
|
|
69
72
|
onChange={handleChange}
|
|
70
73
|
placeholder={placeholder}
|
|
71
|
-
className=
|
|
74
|
+
className={`w-full px-4 py-3 border-2 ${th.inputBorder} ${th.inputBg} ${th.inputText} rounded-xl text-lg focus:outline-none focus:ring-2 ${th.focusRing}`}
|
|
72
75
|
/>
|
|
73
76
|
</div>
|
|
74
77
|
|
|
@@ -79,13 +82,14 @@ function PlainInput({
|
|
|
79
82
|
>
|
|
80
83
|
<button
|
|
81
84
|
onClick={handleClick}
|
|
82
|
-
className=
|
|
85
|
+
className={`${th.buttonBg} cursor-pointer px-8 py-3 border-2 ${th.buttonBorder} font-bold ${th.buttonText} text-lg rounded-xl ${th.buttonShadow} hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-none`}
|
|
83
86
|
>
|
|
84
87
|
{buttonText}
|
|
85
88
|
</button>
|
|
86
89
|
</div>
|
|
87
90
|
)}
|
|
88
91
|
</div>
|
|
92
|
+
</div>
|
|
89
93
|
);
|
|
90
94
|
}
|
|
91
95
|
|
package/src/components/quest.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useCallback, createElement, ComponentType } from 'react';
|
|
2
2
|
import { defaultCss, Model, Question, Serializer } from 'survey-core';
|
|
3
3
|
import { ReactQuestionFactory, Survey, SurveyQuestionElementBase } from 'survey-react-ui';
|
|
4
|
-
import { ContrastLight } from 'survey-core/themes';
|
|
4
|
+
import { ContrastLight, ContrastDark } from 'survey-core/themes';
|
|
5
5
|
import 'survey-core/survey-core.min.css';
|
|
6
6
|
import { registerSimulation } from '../utils/simulation';
|
|
7
7
|
import { registerFlattener } from '../utils/upload';
|
|
8
8
|
import { uniform } from '../utils/distributions';
|
|
9
|
+
import { useTheme, t } from '../utils/theme';
|
|
9
10
|
|
|
10
11
|
registerFlattener('Quest', 'session');
|
|
11
12
|
|
|
@@ -126,15 +127,18 @@ function Quest({
|
|
|
126
127
|
theme?: any;
|
|
127
128
|
containerClass?: string;
|
|
128
129
|
}) {
|
|
130
|
+
const contextTheme = useTheme();
|
|
131
|
+
const th = t(contextTheme);
|
|
132
|
+
|
|
129
133
|
Object.keys(customQuestions).forEach((name) => {
|
|
130
134
|
registerCustomQuestion(name, customQuestions[name]);
|
|
131
135
|
});
|
|
132
136
|
|
|
133
137
|
const survey = new Model({
|
|
134
138
|
...surveyJson,
|
|
135
|
-
css: { ...defaultCss, root:
|
|
139
|
+
css: { ...defaultCss, root: 'sd-root-modern custom-root' },
|
|
136
140
|
});
|
|
137
|
-
survey.applyTheme(theme ?? ContrastLight);
|
|
141
|
+
survey.applyTheme(theme ?? (contextTheme === 'dark' ? ContrastDark : ContrastLight));
|
|
138
142
|
|
|
139
143
|
const saveResults = useCallback(
|
|
140
144
|
(sender: any) => {
|
|
@@ -145,10 +149,12 @@ function Quest({
|
|
|
145
149
|
|
|
146
150
|
survey.onComplete.add(saveResults);
|
|
147
151
|
|
|
152
|
+
const useCustomBg = !!containerClass || contextTheme === 'dark';
|
|
153
|
+
|
|
148
154
|
return (
|
|
149
|
-
<div className={`min-h-screen ${containerClass ??
|
|
150
|
-
{!
|
|
151
|
-
<div className=
|
|
155
|
+
<div className={`min-h-screen ${containerClass ?? th.containerBg}`}>
|
|
156
|
+
{!useCustomBg && <div className='absolute inset-0 -z-10 h-full w-full bg-white bg-[radial-gradient(#e5e7eb_1px,transparent_1px)] [background-size:16px_16px]' />}
|
|
157
|
+
<div className={`max-w-4xl mx-auto px-4${useCustomBg ? ' quest-custom-bg' : ''}`}>
|
|
152
158
|
<Survey model={survey} />
|
|
153
159
|
</div>
|
|
154
160
|
</div>
|
package/src/components/text.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { BaseComponentProps, now } from '../mod';
|
|
|
3
3
|
import { registerSimulation } from '../utils/simulation';
|
|
4
4
|
import { registerFlattener } from '../utils/upload';
|
|
5
5
|
import { uniform } from '../utils/distributions';
|
|
6
|
+
import { useTheme, t } from '../utils/theme';
|
|
6
7
|
|
|
7
8
|
registerFlattener('Text', 'text');
|
|
8
9
|
|
|
@@ -20,7 +21,7 @@ function Text({
|
|
|
20
21
|
content,
|
|
21
22
|
buttonText = 'Click me',
|
|
22
23
|
className = '',
|
|
23
|
-
containerClass
|
|
24
|
+
containerClass,
|
|
24
25
|
next,
|
|
25
26
|
animate = false,
|
|
26
27
|
allowedKeys = false,
|
|
@@ -33,6 +34,7 @@ function Text({
|
|
|
33
34
|
animate?: boolean;
|
|
34
35
|
allowedKeys?: string[] | boolean;
|
|
35
36
|
} & BaseComponentProps) {
|
|
37
|
+
const th = t(useTheme());
|
|
36
38
|
const startTimeRef = useRef<number>(0);
|
|
37
39
|
|
|
38
40
|
useEffect(() => {
|
|
@@ -84,10 +86,10 @@ function Text({
|
|
|
84
86
|
};
|
|
85
87
|
|
|
86
88
|
return (
|
|
87
|
-
<div className={`min-h-screen ${containerClass}`}>
|
|
89
|
+
<div className={`min-h-screen ${containerClass ?? th.containerBg}`}>
|
|
88
90
|
<div className={`max-w-prose mx-auto ${className} pt-20 pb-20 px-4 `}>
|
|
89
91
|
<article
|
|
90
|
-
className={`prose prose-2xl prose
|
|
92
|
+
className={`prose prose-2xl ${th.prose} text-xl ${th.proseLink} prose-a:underline prose-h1:text-4xl prose-h1:mb-10 prose-h1:font-bold prose-p:mb-4 prose-strong:font-bold ${th.text} leading-relaxed
|
|
91
93
|
${animate ? 'animate-slide-down opacity-0' : ''}`}
|
|
92
94
|
>
|
|
93
95
|
{content}
|
|
@@ -102,7 +104,7 @@ function Text({
|
|
|
102
104
|
onClick={handleClick}
|
|
103
105
|
tabIndex={-1}
|
|
104
106
|
onKeyDown={(e) => { if (e.key === ' ' || e.key === 'Enter') e.preventDefault(); }}
|
|
105
|
-
className=
|
|
107
|
+
className={`${th.buttonBg} cursor-pointer px-8 py-3 border-2 ${th.buttonBorder} font-bold ${th.buttonText} text-lg rounded-xl ${th.buttonShadow} hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-none`}
|
|
106
108
|
>
|
|
107
109
|
{buttonText}
|
|
108
110
|
</button>
|
|
@@ -3,6 +3,7 @@ import { motion, AnimatePresence, LayoutGroup } from 'motion/react';
|
|
|
3
3
|
import { BaseComponentProps } from '../mod';
|
|
4
4
|
import { registerSimulation } from '../utils/simulation';
|
|
5
5
|
import { registerFlattener } from '../utils/upload';
|
|
6
|
+
import { useTheme, t } from '../utils/theme';
|
|
6
7
|
|
|
7
8
|
registerFlattener('Tutorial', null);
|
|
8
9
|
|
|
@@ -75,12 +76,8 @@ export interface TutorialProps extends BaseComponentProps {
|
|
|
75
76
|
theme?: 'light' | 'dark';
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
const
|
|
79
|
-
'px-4 py-3 border-2
|
|
80
|
-
|
|
81
|
-
const NAV_BTN_ACTIVE = NAV_BTN + ' bg-white text-black cursor-pointer hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-none';
|
|
82
|
-
|
|
83
|
-
const NAV_BTN_DISABLED = NAV_BTN + ' bg-gray-200 text-gray-400 border-gray-400 shadow-[2px_2px_0px_rgba(156,163,175,1)] cursor-default';
|
|
79
|
+
const NAV_BTN_BASE =
|
|
80
|
+
'px-4 py-3 border-2 font-bold text-lg rounded-xl transition-all duration-100 outline-none focus:outline-none focus:ring-0';
|
|
84
81
|
|
|
85
82
|
export const Tutorial = ({
|
|
86
83
|
next,
|
|
@@ -91,8 +88,15 @@ export const Tutorial = ({
|
|
|
91
88
|
animate = false,
|
|
92
89
|
nextKey = 'ArrowRight',
|
|
93
90
|
backKey = 'ArrowLeft',
|
|
94
|
-
theme
|
|
91
|
+
theme,
|
|
95
92
|
}: TutorialProps) => {
|
|
93
|
+
const contextTheme = useTheme();
|
|
94
|
+
const resolvedTheme = theme ?? contextTheme;
|
|
95
|
+
const th = t(resolvedTheme);
|
|
96
|
+
|
|
97
|
+
const NAV_BTN_ACTIVE = `${NAV_BTN_BASE} ${th.buttonBg} ${th.buttonText} ${th.buttonBorder} ${th.buttonShadow} cursor-pointer hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-none`;
|
|
98
|
+
const NAV_BTN_DISABLED = `${NAV_BTN_BASE} ${th.buttonDisabledBg} ${th.buttonDisabledText} ${th.buttonDisabledBorder} ${th.buttonDisabledShadow} cursor-default`;
|
|
99
|
+
|
|
96
100
|
const [page, setPage] = useState(0);
|
|
97
101
|
const [progressMap, setProgressMap] = useState<Record<number, boolean>>({});
|
|
98
102
|
const autoAdvanceTimer = useRef<ReturnType<typeof setTimeout>>();
|
|
@@ -162,7 +166,7 @@ export const Tutorial = ({
|
|
|
162
166
|
return (
|
|
163
167
|
<LayoutGroup>
|
|
164
168
|
<div
|
|
165
|
-
className={`${containerClass ??
|
|
169
|
+
className={`${containerClass ?? th.containerBg} ${animate ? 'animate-slide-down opacity-0' : ''}`}
|
|
166
170
|
style={{
|
|
167
171
|
width: '100vw',
|
|
168
172
|
height: '100vh',
|
|
@@ -222,9 +226,7 @@ export const Tutorial = ({
|
|
|
222
226
|
width: 8,
|
|
223
227
|
height: 8,
|
|
224
228
|
borderRadius: '50%',
|
|
225
|
-
backgroundColor: i === page
|
|
226
|
-
? (theme === 'dark' ? '#fff' : '#000')
|
|
227
|
-
: (theme === 'dark' ? 'rgba(255,255,255,0.3)' : 'rgba(0,0,0,0.2)'),
|
|
229
|
+
backgroundColor: i === page ? th.dotActive : th.dotInactive,
|
|
228
230
|
transition: 'background-color 0.2s',
|
|
229
231
|
}}
|
|
230
232
|
/>
|
|
@@ -17,6 +17,7 @@ import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
|
|
|
17
17
|
import { buildUploadFiles, convertArrayOfObjectsToCSV } from '../utils/upload';
|
|
18
18
|
import { registerSimulation, getBackendUrl, getInitialParticipant } from '../utils/simulation';
|
|
19
19
|
import { uniform } from '../utils/distributions';
|
|
20
|
+
import { useTheme, t } from '../utils/theme';
|
|
20
21
|
|
|
21
22
|
registerSimulation('Upload', async (trialProps, experimentState, _simulators, participant) => {
|
|
22
23
|
const sessionID = trialProps.sessionID || `sim_${Date.now()}_${Math.floor(uniform(0, 36 ** 6)).toString(36)}`;
|
|
@@ -379,16 +380,16 @@ export default function Upload({
|
|
|
379
380
|
}
|
|
380
381
|
}, [uploadState]);
|
|
381
382
|
|
|
383
|
+
const th = t(useTheme());
|
|
384
|
+
const btnClass = `cursor-pointer ${th.buttonBg} px-8 py-3 border-2 ${th.buttonBorder} font-bold ${th.buttonText} text-lg rounded-xl ${th.buttonShadow} hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-none`;
|
|
385
|
+
|
|
382
386
|
return (
|
|
383
|
-
<div className={containerClass ??
|
|
384
|
-
<div className={`flex flex-col items-center justify-center gap-4 p-6 text-xl mt-16 px-10 h-full ${className ?? ''}`}>
|
|
387
|
+
<div className={containerClass ?? th.containerBg} style={{ position: 'fixed', inset: 0 }}>
|
|
388
|
+
<div className={`flex flex-col items-center justify-center gap-4 p-6 text-xl mt-16 px-10 h-full ${th.text} ${className ?? ''}`}>
|
|
385
389
|
{uploadState == 'initial' && !autoUpload && (
|
|
386
390
|
<>
|
|
387
391
|
{content ?? <p>Thank you for participating! Please click the button below to submit your data.</p>}
|
|
388
|
-
<button
|
|
389
|
-
onClick={handleUpload}
|
|
390
|
-
className='mt-8 cursor-pointer bg-white px-8 py-3 border-2 border-black font-bold text-black text-lg rounded-xl shadow-[2px_2px_0px_rgba(0,0,0,1)] hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-none'
|
|
391
|
-
>
|
|
392
|
+
<button onClick={handleUpload} className={`mt-8 ${btnClass}`}>
|
|
392
393
|
Submit Data
|
|
393
394
|
</button>
|
|
394
395
|
</>
|
|
@@ -405,14 +406,11 @@ export default function Upload({
|
|
|
405
406
|
|
|
406
407
|
{uploadState == 'error' && (
|
|
407
408
|
<>
|
|
408
|
-
{errorContent ?? <div className=
|
|
409
|
+
{errorContent ?? <div className={`${th.error} mb-4`}>
|
|
409
410
|
<p>Sorry, there was an error uploading your data.</p>
|
|
410
411
|
<p>Please try again or contact the researcher.</p>
|
|
411
412
|
</div>}
|
|
412
|
-
<button
|
|
413
|
-
onClick={handleUpload}
|
|
414
|
-
className='cursor-pointer bg-white px-8 py-3 border-2 border-black font-bold text-black text-lg rounded-xl shadow-[2px_2px_0px_rgba(0,0,0,1)] hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-none'
|
|
415
|
-
>
|
|
413
|
+
<button onClick={handleUpload} className={btnClass}>
|
|
416
414
|
Try Again
|
|
417
415
|
</button>
|
|
418
416
|
</>
|
package/src/index.css
CHANGED
|
@@ -94,9 +94,10 @@
|
|
|
94
94
|
font-family: 'Atkinson Hyperlegible', sans-serif; /* Added this line */
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
.sd-root-modern
|
|
97
|
+
.quest-custom-bg .sd-root-modern {
|
|
98
98
|
background-color: transparent !important;
|
|
99
99
|
background-image: none !important;
|
|
100
|
+
background-size: unset !important;
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
.sd-root-modern * {
|
package/src/mod.tsx
CHANGED
|
@@ -7,6 +7,8 @@ export * from './utils/common';
|
|
|
7
7
|
export * from './utils/simulation';
|
|
8
8
|
export { registerFlattener, arrayFlattener } from './utils/upload';
|
|
9
9
|
export { normal, poisson, uniform, seedDistributions, sobol, halton, sampleParticipants } from './utils/distributions';
|
|
10
|
+
export { useTheme, ThemeContext, THEME, t } from './utils/theme';
|
|
11
|
+
export type { Theme } from './utils/theme';
|
|
10
12
|
export type { DimensionSpec, UniformSpec, NormalSpec, PoissonSpec, SamplingMethod } from './utils/distributions';
|
|
11
13
|
export { simulateDDMTrial, mapDDMChoice } from './utils/ddm';
|
|
12
14
|
export type { DDMTrialParams, DDMTrialResult, ParameterDef, NormalDist, UniformDist, BoundaryDef, CollapseDef, PostStimStrategyDef, ContinueStrategy, CollapseStrategy, SnapshotStrategy } from './utils/ddm';
|
package/src/utils/common.ts
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
export type Theme = 'light' | 'dark';
|
|
4
|
+
|
|
5
|
+
export const ThemeContext = createContext<Theme>('light');
|
|
6
|
+
export const useTheme = () => useContext(ThemeContext);
|
|
7
|
+
|
|
8
|
+
export const THEME = {
|
|
9
|
+
light: {
|
|
10
|
+
containerBg: '',
|
|
11
|
+
text: 'text-black',
|
|
12
|
+
prose: 'prose-slate',
|
|
13
|
+
proseLink: 'prose-a:text-blue-600',
|
|
14
|
+
buttonBg: 'bg-white',
|
|
15
|
+
buttonText: 'text-black',
|
|
16
|
+
buttonBorder: 'border-black',
|
|
17
|
+
buttonShadow: 'shadow-[2px_2px_0px_rgba(0,0,0,1)]',
|
|
18
|
+
buttonDisabledBg: 'bg-gray-200',
|
|
19
|
+
buttonDisabledText: 'text-gray-400',
|
|
20
|
+
buttonDisabledBorder: 'border-gray-400',
|
|
21
|
+
buttonDisabledShadow: 'shadow-[2px_2px_0px_rgba(156,163,175,1)]',
|
|
22
|
+
error: 'text-red-500',
|
|
23
|
+
focusRing: 'focus:ring-blue-500',
|
|
24
|
+
inputBg: '',
|
|
25
|
+
inputBorder: 'border-black',
|
|
26
|
+
inputText: '',
|
|
27
|
+
progressBg: 'bg-gray-200',
|
|
28
|
+
progressStripe1: '#E5E7EB',
|
|
29
|
+
progressStripe2: '#D1D5DB',
|
|
30
|
+
dotActive: '#000',
|
|
31
|
+
dotInactive: 'rgba(0,0,0,0.2)',
|
|
32
|
+
toastTheme: 'light' as const,
|
|
33
|
+
},
|
|
34
|
+
dark: {
|
|
35
|
+
containerBg: 'bg-[#1a1a2e]',
|
|
36
|
+
text: 'text-[#f5f5f5]',
|
|
37
|
+
prose: 'prose-invert',
|
|
38
|
+
proseLink: 'prose-a:text-blue-400',
|
|
39
|
+
buttonBg: 'bg-white',
|
|
40
|
+
buttonText: 'text-black',
|
|
41
|
+
buttonBorder: 'border-black',
|
|
42
|
+
buttonShadow: 'shadow-[2px_2px_0px_rgba(0,0,0,1)]',
|
|
43
|
+
buttonDisabledBg: 'bg-gray-700',
|
|
44
|
+
buttonDisabledText: 'text-gray-500',
|
|
45
|
+
buttonDisabledBorder: 'border-gray-600',
|
|
46
|
+
buttonDisabledShadow: 'shadow-[2px_2px_0px_rgba(75,85,99,1)]',
|
|
47
|
+
error: 'text-red-400',
|
|
48
|
+
focusRing: 'focus:ring-blue-400',
|
|
49
|
+
inputBg: 'bg-gray-700',
|
|
50
|
+
inputBorder: 'border-gray-500',
|
|
51
|
+
inputText: 'text-[#f5f5f5]',
|
|
52
|
+
progressBg: 'bg-gray-700',
|
|
53
|
+
progressStripe1: '#374151',
|
|
54
|
+
progressStripe2: '#4B5563',
|
|
55
|
+
dotActive: '#fff',
|
|
56
|
+
dotInactive: 'rgba(255,255,255,0.3)',
|
|
57
|
+
toastTheme: 'dark' as const,
|
|
58
|
+
},
|
|
59
|
+
} as const;
|
|
60
|
+
|
|
61
|
+
export function t(theme: Theme) {
|
|
62
|
+
return THEME[theme];
|
|
63
|
+
}
|