Skip to content

Commit 771cc8b

Browse files
authored
New: Allow custom icon per prompt (fixes #19)
1 parent 43c9527 commit 771cc8b

File tree

8 files changed

+88
-16
lines changed

8 files changed

+88
-16
lines changed

example.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Apply to course.json, contentObject.json, blocks.json or components.json
2-
2+
33
"_scrollPrompt": {
44
"_isEnabled": true,
5-
"instruction": "{{_globals._extensions._scrollPrompt.scrollDown}}"
5+
"instruction": "{{_globals._extensions._scrollPrompt.scrollDown}}",
6+
"_iconClass": "icon-controls-down"
67
}

less/scrollPrompt.less

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@
66
align-items: center;
77
}
88

9-
&__btn .icon {
10-
.icon-controls-down;
11-
}
12-
139
&__instruction {
14-
margin-left: 1rem;
15-
.dir-rtl & {
16-
margin-left: inherit;
17-
margin-right: 1rem;
18-
}
10+
margin-inline-start: 1rem;
1911
}
2012
}

properties.schema

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@
3535
"inputType": "Text",
3636
"validators": [],
3737
"translatable": true
38+
},
39+
"_iconClass": {
40+
"type": "string",
41+
"required": false,
42+
"default": "icon-controls-down",
43+
"title": "Button icon class",
44+
"inputType": "Text",
45+
"validators": [],
46+
"help": "CSS class name to be applied to the scroll prompt button icon."
3847
}
3948
}
4049
}
@@ -60,6 +69,15 @@
6069
"inputType": "Text",
6170
"validators": [],
6271
"translatable": true
72+
},
73+
"_iconClass": {
74+
"type": "string",
75+
"required": false,
76+
"default": "icon-controls-down",
77+
"title": "Button icon class",
78+
"inputType": "Text",
79+
"validators": [],
80+
"help": "CSS class name to be applied to the scroll prompt button icon."
6381
}
6482
}
6583
}
@@ -85,6 +103,15 @@
85103
"inputType": "Text",
86104
"validators": [],
87105
"translatable": true
106+
},
107+
"_iconClass": {
108+
"type": "string",
109+
"required": false,
110+
"default": "icon-controls-down",
111+
"title": "Button icon class",
112+
"inputType": "Text",
113+
"validators": [],
114+
"help": "CSS class name to be applied to the scroll prompt button icon."
88115
}
89116
}
90117
}
@@ -110,6 +137,15 @@
110137
"inputType": "Text",
111138
"validators": [],
112139
"translatable": true
140+
},
141+
"_iconClass": {
142+
"type": "string",
143+
"required": false,
144+
"default": "icon-controls-down",
145+
"title": "Button icon class",
146+
"inputType": "Text",
147+
"validators": [],
148+
"help": "CSS class name to be applied to the scroll prompt button icon."
113149
}
114150
}
115151
}

schema/block.schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
"type": "string",
2525
"title": "Instruction text",
2626
"default": "{{_globals._extensions._scrollPrompt.scrollDown}}"
27+
},
28+
"_iconClass": {
29+
"type": "string",
30+
"title": "Button icon class",
31+
"description": "CSS class name to be applied to the scroll prompt button icon.",
32+
"default": "icon-controls-down"
2733
}
2834
}
2935
}

schema/component.schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
"type": "string",
2525
"title": "Instruction text",
2626
"default": "{{_globals._extensions._scrollPrompt.scrollDown}}"
27+
},
28+
"_iconClass": {
29+
"type": "string",
30+
"title": "Button icon class",
31+
"description": "CSS class name to be applied to the scroll prompt button icon.",
32+
"default": "icon-controls-down"
2733
}
2834
}
2935
}

schema/contentobject.schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
"type": "string",
2525
"title": "Instruction text",
2626
"default": "{{_globals._extensions._scrollPrompt.scrollDown}}"
27+
},
28+
"_iconClass": {
29+
"type": "string",
30+
"title": "Button icon class",
31+
"description": "CSS class name to be applied to the scroll prompt button icon.",
32+
"default": "icon-controls-down"
2733
}
2834
}
2935
}

schema/course.schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151
"type": "string",
5252
"title": "Instruction text",
5353
"default": "{{_globals._extensions._scrollPrompt.scrollDown}}"
54+
},
55+
"_iconClass": {
56+
"type": "string",
57+
"title": "Button icon class",
58+
"description": "CSS class name to be applied to the scroll prompt button icon.",
59+
"default": "icon-controls-down"
5460
}
5561
}
5662
}

templates/scrollPrompt.jsx

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { compile } from 'core/js/reactHelpers';
2+
import { classes, compile } from 'core/js/reactHelpers';
33

44
export default function ScrollPrompt (props) {
55
const {
@@ -8,14 +8,33 @@ export default function ScrollPrompt (props) {
88
} = props;
99

1010
return (
11-
<div className="scrollPrompt__inner a11y-ignore" aria-hidden="true">
12-
<button className="btn-icon scrollPrompt__btn" onClick={onScrollPromptClick}>
13-
<span className="icon" />
11+
<div
12+
className='scrollPrompt__inner a11y-ignore'
13+
aria-hidden='true'
14+
>
15+
16+
<button
17+
className='btn-icon scrollPrompt__btn'
18+
onClick={onScrollPromptClick}
19+
>
20+
<span
21+
className={classes([
22+
'icon',
23+
_scrollPrompt._iconClass
24+
? _scrollPrompt._iconClass
25+
: 'icon-controls-down'
26+
])}
27+
aria-hidden='true'
28+
/>
1429
</button>
1530

1631
{_scrollPrompt.instruction &&
17-
<div className="scrollPrompt__instruction" dangerouslySetInnerHTML={{ __html: compile(_scrollPrompt.instruction, props) }} />
32+
<div
33+
className='scrollPrompt__instruction'
34+
dangerouslySetInnerHTML={{ __html: compile(_scrollPrompt.instruction, props) }}
35+
/>
1836
}
37+
1938
</div>
2039
);
2140
}

0 commit comments

Comments
 (0)