diff --git a/README.md b/README.md index d762d85..63f2868 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,10 @@ guide the learner’s interaction with the component. **\_scaleStep** (number): Defines the amount the scale should be incremented by. +**scaleStepPrefix** (string): Prefix to add to each slider step. For example, a "$" can be used as a prefix to indicate currency in dollars (ex. $100). + +**scaleStepSuffix** (string): Suffix to add to each slider step. For example, a "V" can be used as a suffix to indicate voltage (ex. 4V). + **\_correctAnswer** (string): Used to set a single value on the slider scale as the correct answer. (Since the attribute expects a string, numeric values must appear in JSON within quotes.) **\_correctRange** (object): Used to set a range of values on the slider scale as the correct answer. The range is determined by **\_bottom** and **\_top**. diff --git a/example.json b/example.json index d3b6a17..2bb57e6 100644 --- a/example.json +++ b/example.json @@ -22,6 +22,8 @@ "_scaleStart": 1, "_scaleEnd": 10, "_scaleStep": 1, + "scaleStepPrefix": "", + "scaleStepSuffix": "", "_correctAnswer": "", "_correctRange": { "_bottom": 4, diff --git a/properties.schema b/properties.schema index 2cad1a7..8f1072d 100644 --- a/properties.schema +++ b/properties.schema @@ -193,6 +193,26 @@ "validators": ["number"], "help": "The amount the scale should increment by" }, + "scaleStepPrefix": { + "type": "string", + "required": false, + "default": "", + "title": "Prefix to add to each slider step", + "inputType": "Text", + "validators": [], + "help": "For instance, a '$' can be used as a prefix to indicate currency in dollars (ex. $100)", + "translatable": true + }, + "scaleStepSuffix": { + "type": "string", + "required": false, + "default": "", + "title": "Suffix to add to each slider step", + "inputType": "Text", + "validators": [], + "help": "For instance, a 'V' can be used as a suffix to indicate voltage (ex. 4V)", + "translatable": true + }, "_correctAnswer": { "type": "string", "default": "", diff --git a/schema/component.schema.json b/schema/component.schema.json index 8225020..3518457 100644 --- a/schema/component.schema.json +++ b/schema/component.schema.json @@ -114,6 +114,24 @@ "description": "The amount the scale should increment by", "default": 1 }, + "scaleStepPrefix": { + "type": "string", + "title": "Prefix to add to each slider step", + "description": "For instance, a '$' can be used as a prefix to indicate currency in dollars (ex. $100)", + "default": "", + "_adapt": { + "translatable": true + } + }, + "scaleStepSuffix": { + "type": "string", + "title": "Suffix to add to each slider step", + "description": "For instance, a 'V' can be used as a suffix to indicate voltage (ex. 4V)", + "default": "", + "_adapt": { + "translatable": true + } + }, "_correctAnswer": { "type": "string", "title": "Correct answer", diff --git a/templates/slider.jsx b/templates/slider.jsx index 13b4042..32c1dbe 100644 --- a/templates/slider.jsx +++ b/templates/slider.jsx @@ -32,7 +32,9 @@ export default function Slider (props) { _showScale, _showNumber, _showScaleNumbers, - _showScaleIndicator + _showScaleIndicator, + scaleStepPrefix, + scaleStepSuffix } = props; const sliderScaleRef = useRef(null); @@ -101,7 +103,7 @@ export default function Slider (props) { {labelStart &&