@media-quest/builder 0.0.40 → 0.0.41
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/dist/public-api.d.ts +4 -5
- package/dist/public-api.js +35 -30
- package/dist/public-api.js.map +1 -1
- package/package.json +1 -1
- package/src/Builder-option.ts +1 -2
- package/src/Builder-question.spec.ts +1 -0
- package/src/Builder-question.ts +1 -2
- package/src/page/Builder-page-collection.spec.ts +5 -0
- package/src/theme/IDefault-theme.ts +1 -2
- package/src/theme/default-theme-compiler.ts +10 -5
- package/src/theme/theme2.ts +33 -22
package/package.json
CHANGED
package/src/Builder-option.ts
CHANGED
|
@@ -56,8 +56,7 @@ export class BuilderOption extends BuilderObject<"builder-question-option", Buil
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
public static fromJson(dto: BuilderOptionDto) {
|
|
59
|
-
|
|
60
|
-
return instance;
|
|
59
|
+
return new BuilderOption(dto);
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
toJson(): BuilderOptionDto {
|
package/src/Builder-question.ts
CHANGED
|
@@ -42,8 +42,7 @@ export class BuilderQuestion extends BuilderObject<"builder-question", BuilderQu
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
public static fromJson(dto: BuilderQuestionDto): BuilderQuestion {
|
|
45
|
-
|
|
46
|
-
return question;
|
|
45
|
+
return new BuilderQuestion(dto);
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
private constructor(dto: BuilderQuestionDto) {
|
|
@@ -44,6 +44,7 @@ const pages: BuilderPageDto[] = [
|
|
|
44
44
|
id: OptionID.create(),
|
|
45
45
|
label: "Neste",
|
|
46
46
|
value: -1,
|
|
47
|
+
cssOverride: {}
|
|
47
48
|
},
|
|
48
49
|
defaultQuestion: {
|
|
49
50
|
id: QuestionID.create(),
|
|
@@ -55,16 +56,19 @@ const pages: BuilderPageDto[] = [
|
|
|
55
56
|
id: "opt-nei" as OptionID,
|
|
56
57
|
value: 0,
|
|
57
58
|
label: "Nei",
|
|
59
|
+
cssOverride: {}
|
|
58
60
|
},
|
|
59
61
|
{
|
|
60
62
|
id: "opt-ja" as OptionID,
|
|
61
63
|
value: 1,
|
|
62
64
|
label: "Ja",
|
|
65
|
+
cssOverride: {}
|
|
63
66
|
},
|
|
64
67
|
{
|
|
65
68
|
id: "opt-vet-ikke" as OptionID,
|
|
66
69
|
value: 9,
|
|
67
70
|
label: "Vet ikke",
|
|
71
|
+
cssOverride: {}
|
|
68
72
|
},
|
|
69
73
|
],
|
|
70
74
|
},
|
|
@@ -92,6 +96,7 @@ const pages: BuilderPageDto[] = [
|
|
|
92
96
|
id: "next-button-id-page2" as OptionID,
|
|
93
97
|
label: "Neste",
|
|
94
98
|
value: -1,
|
|
99
|
+
cssOverride: {}
|
|
95
100
|
},
|
|
96
101
|
defaultQuestion: {
|
|
97
102
|
id: QuestionID.validateOrCreate("default-question-id"),
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
DDivDto,
|
|
12
12
|
DelayTask,
|
|
13
13
|
DElementDto,
|
|
14
|
-
DImgDto,
|
|
14
|
+
DImgDto, DStyle,
|
|
15
15
|
DTextDto,
|
|
16
16
|
PageDto,
|
|
17
17
|
PlayAudioTask,
|
|
@@ -633,20 +633,25 @@ export class DefaultThemeCompiler implements ThemeCompiler<IDefaultTheme> {
|
|
|
633
633
|
}
|
|
634
634
|
: { kind: "next-page" };
|
|
635
635
|
|
|
636
|
-
|
|
636
|
+
const _btnStyles =
|
|
637
637
|
value === 9 ? t.buttonBar.responseButtons.dontKnow : t.buttonBar.responseButtons.normal;
|
|
638
|
+
let css: PStyle = DStyle.clone(_btnStyles.btn.css)
|
|
639
|
+
const cssEnabled = DStyle.clone(_btnStyles.btn.cssEnabled)
|
|
640
|
+
|
|
638
641
|
if (t.buttonBar.vibrateMs) {
|
|
639
|
-
|
|
642
|
+
// TODO DO NOT WORK.
|
|
643
|
+
// onclickAction.vibrateMs = t.buttonBar.vibrateMs;
|
|
640
644
|
}
|
|
641
645
|
|
|
642
646
|
if(cssOverride) {
|
|
643
|
-
|
|
647
|
+
console.log(cssOverride);
|
|
648
|
+
css = {...css, ...cssOverride}
|
|
644
649
|
}
|
|
645
650
|
|
|
646
651
|
const btn: DButtonDto = {
|
|
647
652
|
_tag: "button",
|
|
648
653
|
innerText: label,
|
|
649
|
-
style: { ...
|
|
654
|
+
style: { ...css, ...cssEnabled },
|
|
650
655
|
onClick: onclickAction,
|
|
651
656
|
};
|
|
652
657
|
|
package/src/theme/theme2.ts
CHANGED
|
@@ -4,6 +4,10 @@ import { CssTheme } from "./css-theme";
|
|
|
4
4
|
import { PStyle } from "@media-quest/engine";
|
|
5
5
|
import { THEME_2_ICONS } from "./icons";
|
|
6
6
|
|
|
7
|
+
const deepClone = <T>(obj: T): T => {
|
|
8
|
+
return JSON.parse(JSON.stringify(obj));
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
const translate = (pos: { x?: number; y?: number }) => {
|
|
8
12
|
const x = pos.x || 0;
|
|
9
13
|
const y = pos.y || 0;
|
|
@@ -85,21 +89,26 @@ const BUTTON_BAR_WIDTH = Q_AREA_WIDTH - 2 * W_M3;
|
|
|
85
89
|
const MAIN_TEXT_WIDE = Q_AREA_WIDTH - 2 * W_M3;
|
|
86
90
|
const MAIN_TEXT_NARROW = MAIN_TEXT_WIDE - AUDIO_ICON_WIDTH - W_M3;
|
|
87
91
|
|
|
88
|
-
const btnTextBase: PStyle = {
|
|
89
|
-
|
|
90
|
-
bottom: VIDEO_CONTROLS_BOTTOM + 1.2,
|
|
91
|
-
zIndex: LAYER_5,
|
|
92
|
-
width: VIDEO_CONTROLS_WIDTH / 2,
|
|
93
|
-
textAlign: "center",
|
|
94
|
-
visibility: "hidden",
|
|
95
|
-
margin: { _unit: "px", value: 0 },
|
|
92
|
+
// const btnTextBase: PStyle = {
|
|
93
|
+
|
|
96
94
|
// backgroundColor: Colors.yellow,
|
|
97
|
-
};
|
|
95
|
+
// };
|
|
98
96
|
|
|
99
|
-
const
|
|
100
|
-
|
|
97
|
+
const btnTextBaseObj = (): PStyle => {
|
|
98
|
+
return {
|
|
99
|
+
fontSize: { _unit: "px", value: 25 },
|
|
100
|
+
bottom: VIDEO_CONTROLS_BOTTOM + 1.2,
|
|
101
|
+
zIndex: LAYER_5,
|
|
102
|
+
width: VIDEO_CONTROLS_WIDTH / 2,
|
|
103
|
+
textAlign: "center",
|
|
104
|
+
visibility: "hidden",
|
|
105
|
+
margin: { _unit: "px", value: 0 },
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const muteUnmuteText: PStyle = { ...btnTextBaseObj(), right: VIDEO_CONTROLS_RIGHT };
|
|
109
|
+
const playPauseText: PStyle = { ...btnTextBaseObj(), left: VIDEO_CONTROLS_LEFT };
|
|
101
110
|
const replayText: PStyle = {
|
|
102
|
-
...
|
|
111
|
+
...btnTextBaseObj(),
|
|
103
112
|
width: VIDEO_CONTROLS_WIDTH,
|
|
104
113
|
left: VIDEO_CONTROLS_LEFT,
|
|
105
114
|
// backgroundColor: Colors.yellow,
|
|
@@ -156,8 +165,9 @@ const responseButtonBaseCss = (): CssTheme => ({
|
|
|
156
165
|
fontSize: { _unit: "px", value: 28 },
|
|
157
166
|
lineHeight: 1.1,
|
|
158
167
|
|
|
159
|
-
// TODO
|
|
160
|
-
maxWidth: 25,
|
|
168
|
+
// TODO Skal knappene vokse, med mindre det settes en maksbredde?
|
|
169
|
+
// maxWidth: 25,
|
|
170
|
+
// maxWidth: { _unit: "percent", value: 10 },
|
|
161
171
|
minWidth: 12,
|
|
162
172
|
// width: 20,
|
|
163
173
|
// flex: "0 0 auto",
|
|
@@ -171,11 +181,11 @@ const responseButtonBaseCss = (): CssTheme => ({
|
|
|
171
181
|
position: "relative",
|
|
172
182
|
display: "block",
|
|
173
183
|
cursor: "pointer",
|
|
174
|
-
// maxWidth: { _unit: "percent", value: 10 },
|
|
175
184
|
},
|
|
176
185
|
cssDisabled: { opacity: 0.3, cursor: "not-allowed" },
|
|
177
186
|
cssEnabled: { opacity: 1, cursor: "pointer" },
|
|
178
187
|
});
|
|
188
|
+
|
|
179
189
|
export const primaryButton = (overridesCss: PStyle): BuilderOptionTheme => {
|
|
180
190
|
const base = responseButtonBaseCss();
|
|
181
191
|
const optionTheme: BuilderOptionTheme = {
|
|
@@ -183,8 +193,8 @@ export const primaryButton = (overridesCss: PStyle): BuilderOptionTheme => {
|
|
|
183
193
|
normal: {
|
|
184
194
|
btn: {
|
|
185
195
|
css: {
|
|
186
|
-
...base.css,
|
|
187
|
-
...overridesCss,
|
|
196
|
+
...deepClone(base.css),
|
|
197
|
+
...deepClone(overridesCss),
|
|
188
198
|
backgroundColor: Colors.primary,
|
|
189
199
|
borderColor: Colors.primary,
|
|
190
200
|
textColor: Colors.white,
|
|
@@ -200,8 +210,8 @@ export const primaryButton = (overridesCss: PStyle): BuilderOptionTheme => {
|
|
|
200
210
|
dontKnow: {
|
|
201
211
|
btn: {
|
|
202
212
|
css: {
|
|
203
|
-
...base.css,
|
|
204
|
-
...overridesCss,
|
|
213
|
+
...deepClone(base.css),
|
|
214
|
+
...deepClone(overridesCss),
|
|
205
215
|
backgroundColor: Colors.secondary,
|
|
206
216
|
borderColor: Colors.secondary,
|
|
207
217
|
textColor: Colors.primary,
|
|
@@ -375,14 +385,15 @@ export const Theme2: IDefaultTheme = {
|
|
|
375
385
|
bottom: Q_AREA_BOTTOM + H_M3,
|
|
376
386
|
left: Q_AREA_LEFT + W_M3,
|
|
377
387
|
// backgroundColor: "green",
|
|
378
|
-
gap: { _unit: "px", value:
|
|
388
|
+
gap: { _unit: "px", value: 32 },
|
|
379
389
|
alignItems: "stretch",
|
|
380
390
|
},
|
|
381
391
|
whenSingle: { justifyContent: "center" },
|
|
382
392
|
whenMany: { justifyContent: "flex-start" },
|
|
383
393
|
},
|
|
384
394
|
|
|
385
|
-
nextButtonTheme: primaryButton({}),
|
|
386
|
-
responseButtons: primaryButton({}),
|
|
395
|
+
nextButtonTheme: primaryButton({fontSize: { _unit: "px", value: 28 }, maxWidth: {_unit: "percent", value: 25}}),
|
|
396
|
+
responseButtons: primaryButton({fontSize: { _unit: "px", value: 28 }, maxWidth: {_unit: "percent", value: 25 }}),
|
|
387
397
|
},
|
|
388
398
|
};
|
|
399
|
+
console.log(Theme2);
|