@media-quest/builder 0.0.12 → 0.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@media-quest/builder",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "Builder library for Media-quest schemas",
5
5
  "main": "dist/public-api.js",
6
6
  "module": "dist/public-api.mjs",
@@ -13,6 +13,6 @@
13
13
  "prepublishOnly": "npm run build"
14
14
  },
15
15
  "dependencies": {
16
- "@media-quest/engine": "0.0.12"
16
+ "@media-quest/engine": "0.0.13"
17
17
  }
18
18
  }
@@ -37,15 +37,21 @@ export interface IDefaultTheme {
37
37
  responseButtons: BuilderOptionTheme;
38
38
  nextButtonTheme: BuilderOptionTheme;
39
39
  // mainQuestionText: BuilderTextTheme;
40
- dontKnowButtonTheme?: BuilderOptionTheme;
40
+ // dontKnowButtonTheme: BuilderOptionTheme;
41
41
  buttonThemes?: Array<BuilderOptionTheme>;
42
42
  }
43
43
 
44
44
  export interface BuilderOptionTheme {
45
45
  name: string;
46
- div: CssTheme;
46
+ normal: ButtonTheme;
47
+ dontKnow: ButtonTheme;
48
+ }
49
+
50
+ interface ButtonTheme {
51
+ btn: CssTheme;
52
+ divider: PStyle;
47
53
  text1: PStyle;
48
- text2?: CssTheme;
54
+ text2: PStyle;
49
55
  }
50
56
 
51
57
  namespace BuilderOptionTheme {
@@ -65,38 +71,80 @@ namespace BuilderOptionTheme {
65
71
  const FONT_WEIGHT: DStyle["fontWeight"] = 600;
66
72
  const FONT_SIZE: DCss.Px["value"] = 35;
67
73
 
68
- export const blueButton = (): BuilderOptionTheme => ({
69
- name: "blue-button-theme",
70
- div: {
71
- css: {
72
- backgroundColor: BLUE,
73
- borderColor: BLUE,
74
- textColor: WHITE,
75
- fontSize: { _unit: "px", value: FONT_SIZE },
76
- borderWidth: { _unit: "px", value: BTN_BORDER_WIDTH },
77
- borderStyle: BTN_BORDER_STYLE,
78
- borderRadius: { value: BTN_BORDER_RADIUS, _unit: "px" },
79
- padding: { _unit: "px", value: 40 },
80
- h: BTN_HEIGHT,
81
- w: BTN_WIDTH,
82
- x: 10,
83
- y: 8,
84
- textAlign: "center",
74
+ export const blueButton = (): BuilderOptionTheme => {
75
+ const optionTheme: BuilderOptionTheme = {
76
+ name: "blue-button-theme",
77
+ normal: {
78
+ btn: {
79
+ css: {
80
+ backgroundColor: BLUE,
81
+ borderColor: BLUE,
82
+ textColor: WHITE,
83
+ fontSize: { _unit: "px", value: FONT_SIZE },
84
+ borderWidth: { _unit: "px", value: BTN_BORDER_WIDTH },
85
+ borderStyle: BTN_BORDER_STYLE,
86
+ borderRadius: { value: BTN_BORDER_RADIUS, _unit: "px" },
87
+ padding: { _unit: "px", value: 40 },
88
+ h: BTN_HEIGHT,
89
+ w: BTN_WIDTH,
90
+ x: 10,
91
+ y: 8,
92
+ textAlign: "center",
93
+ },
94
+ cssDisabled: { opacity: 0.3, cursor: "not-allowed" },
95
+ cssEnabled: { opacity: 1, cursor: "pointer" },
96
+ },
97
+ divider: {},
98
+ text1: {
99
+ y: 50,
100
+ transform: "translate(0%, 50%)",
101
+ textColor: WHITE,
102
+ fontSize: { _unit: "px", value: FONT_SIZE },
103
+ w: 84,
104
+ x: 8,
105
+ fontWeight: FONT_WEIGHT,
106
+ textAlign: "center",
107
+ },
108
+ text2: {},
85
109
  },
86
- cssDisabled: { opacity: 0.3, cursor: "not-allowed" },
87
- cssEnabled: { opacity: 1, cursor: "pointer" },
88
- },
89
- text1: {
90
- y: 50,
91
- transform: "translate(0%, 50%)",
92
- textColor: WHITE,
93
- fontSize: { _unit: "px", value: FONT_SIZE },
94
- w: 84,
95
- x: 8,
96
- fontWeight: FONT_WEIGHT,
97
- textAlign: "center",
98
- },
99
- });
110
+
111
+ dontKnow: {
112
+ btn: {
113
+ css: {
114
+ backgroundColor: WHITE,
115
+ borderColor: LIGHT_BLUE,
116
+ textColor: BLUE,
117
+ fontSize: { _unit: "px", value: FONT_SIZE },
118
+ borderWidth: { _unit: "px", value: BTN_BORDER_WIDTH },
119
+ borderStyle: BTN_BORDER_STYLE,
120
+ borderRadius: { value: BTN_BORDER_RADIUS, _unit: "px" },
121
+ padding: { _unit: "px", value: 40 },
122
+ h: BTN_HEIGHT,
123
+ w: BTN_SHORT_WIDTH,
124
+ x: 10,
125
+ y: 8,
126
+ textAlign: "center",
127
+ },
128
+ cssDisabled: { opacity: 0.3, cursor: "not-allowed" },
129
+ cssEnabled: { opacity: 1, cursor: "pointer" },
130
+ },
131
+ text1: {
132
+ y: 50,
133
+ transform: "translate(0%, 50%)",
134
+ textColor: BLUE,
135
+ fontSize: { _unit: "px", value: FONT_SIZE },
136
+ w: 84,
137
+ x: 8,
138
+ fontWeight: FONT_WEIGHT,
139
+ textAlign: "center",
140
+ },
141
+ text2: {},
142
+ divider: {},
143
+ },
144
+ };
145
+
146
+ return optionTheme;
147
+ };
100
148
  }
101
149
 
102
150
  export const DefaultTheme: IDefaultTheme = {
@@ -375,7 +375,7 @@ export class DefaultThemeCompiler extends AbstractThemeCompiler<IDefaultTheme> {
375
375
  const factsCollected: Fact[] = [];
376
376
  const { id, value, label } = buttonDto;
377
377
 
378
- const { div, text1 } = DefaultTheme.responseButtons;
378
+ // const { div, text1, dontKnow } = DefaultTheme.responseButtons;
379
379
  if (options.kind === "response-button") {
380
380
  const fact: Fact = {
381
381
  kind: "numeric-fact",
@@ -396,6 +396,8 @@ export class DefaultThemeCompiler extends AbstractThemeCompiler<IDefaultTheme> {
396
396
  factsCollected,
397
397
  },
398
398
  };
399
+ const btnStyles = value === 9 ? DefaultTheme.responseButtons.dontKnow : DefaultTheme.responseButtons.normal;
400
+ console.log(btnStyles);
399
401
  const btn: DDivDto = {
400
402
  id,
401
403
  _tag: "div",
@@ -404,17 +406,17 @@ export class DefaultThemeCompiler extends AbstractThemeCompiler<IDefaultTheme> {
404
406
  _tag: "p",
405
407
  id: U.randomString(30),
406
408
  text: label,
407
- style: text1,
409
+ style: btnStyles.text1,
408
410
  },
409
411
  ],
410
412
  onStateChange: [
411
413
  {
412
414
  queryName: DStateProps._Queries.disableUserInputQuery.name,
413
- whenFalse: [...ThemeUtils.enableClickCommands(id, div.cssEnabled)],
414
- whenTrue: [...ThemeUtils.disableClickCommands(id, div.cssDisabled)],
415
+ whenFalse: [...ThemeUtils.enableClickCommands(id, btnStyles.btn.cssEnabled)],
416
+ whenTrue: [...ThemeUtils.disableClickCommands(id, btnStyles.btn.cssDisabled)],
415
417
  },
416
418
  ],
417
- style: { ...div.css, ...div.cssEnabled },
419
+ style: { ...btnStyles.btn.css, ...btnStyles.btn.cssEnabled },
418
420
  onClick: [onClickHandler],
419
421
  };
420
422
  if (options.kind === "next-button") {
File without changes