Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: Add _isRound option for images (fixes #174) #175

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ guide the learner’s interaction with the component.

**\_columns** (number): Defines the number of columns wide the **\_items** are displayed in. If the value of **\_columns** is `2`, each **\_items** will be 50% wide. Similarly, if the value of **\_columns** is `3`, each **\_items** will be 33.3% wide. In mobile view, the width of each **\_items** is 50%.

**\_isRound** (boolean): If set to `true`, the item images will inherit a 50% border radius. Ideal for use with images that are square that are required to be round. The default is `false`.

**\_items** (array): Each *item* represents one choice for the multiple choice question and contains values for **text**, **\_shouldBeSelected**, **feedback**, and **\_graphic**.

>**text** (string): Optional text that is displayed as part of the multiple choice option.
Expand Down
1 change: 1 addition & 0 deletions example.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"_canShowMarking": true,
"_recordInteraction": true,
"_columns": 3,
"_isRound": false,
"_items": [
{
"text": "This is option 1.",
Expand Down
7 changes: 7 additions & 0 deletions less/gmcq.less
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@
display: none;
}

// Round image option
&.is-round &__image-container {
display: block;
border-radius: 50%;
overflow: hidden;
}

// GMCQ item icons
// --------------------------------------------------
&__answer-icon.is-radio .icon {
Expand Down
9 changes: 9 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@
"validators": ["number"],
"help": "Set the number of columns. If value is '0', component uses the default layout."
},
"_isRound": {
"type": "boolean",
"required": false,
"default": false,
"title": "Use circular item images",
"inputType": "Checkbox",
"validators": [],
"help": "If enabled, a 50% border radius will be applied to the item images, making them round."
},
"_selectable": {
"type": "number",
"required": true,
Expand Down
6 changes: 6 additions & 0 deletions schema/component.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@
"description": "Set the number of columns. If value is '0', component uses the default layout",
"default": 0
},
"_isRound": {
"type": "boolean",
"title": "Use circular item images",
"description": "If enabled, a 50% border radius will be applied to the item images, making them round.",
"default": false
},
"_selectable": {
"type": "number",
"title": "Selectable items",
Expand Down
2 changes: 2 additions & 0 deletions templates/gmcq.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function Gmcq(props) {
_shouldShowMarking,
_isRadio,
_columns,
_isRound,
displayTitle,
body,
instruction,
Expand Down Expand Up @@ -52,6 +53,7 @@ export default function Gmcq(props) {
<div
className={classes([
`gmcq-item item-${index}`,
_isRound && 'is-round',
(_shouldShowMarking && _shouldBeSelected) ? 'is-correct' : null,
(_shouldShowMarking && !_shouldBeSelected) ? 'is-incorrect' : null
])}
Expand Down
Loading