Closed JamesPHoughton closed 3 months ago
Posted to upwork: https://www.upwork.com/ab/applicants/1623799833964765184/job-details
Hello, I have just seen your job post on Upwork. I can help you. horizonvert.pu@gmail.com
Hi James, I have just submited my proposal to your job post, Kindly response as soon as possible, I can surely deliver your expected slider within an hour.
Merged https://github.com/Watts-Lab/surveys/pull/112 (thanks @ amirrahman132132), which takes care of what I asked for above.
I dug deeper into the SurveyJS docs (https://surveyjs.io/form-library/documentation/api-reference/itemvalue#getPropertyValue) and it seems that it is the survey library rather than CSS which inserts the value as a default text string if you leave out the text.
We can tell if there is an actual true value specified by using label.locTextValue.isEmpty
, which seems to return true if there is no value specified. So, I moved creating an empty string for the label value to the javascript:
option.innerHTML = `
<div class="each_label">
<div class="tick"></div>
<div class="label_value">${
label.locTextValue.isEmpty ? " " : label.text
}</div>
</div>
`;
This seems to allow us to omit the text string in order to leave a label off the slider tick altogether:
"valueLabels": [
{ "value": 0, "text": "0" },
{ "value": 2 },
{ "value": 4 },
{ "value": 6, "text": " " },
{ "value": 8 },
{ "value": 10, "text": "10" },
{ "value": 12, "text": "12" }
]
Right now, the spacing of the ticks is set by just putting the first tick at the beginning, the last tick at the end, and then evenly spacing the remaining ticks. It would be nice to be able to set the spacing according to the actual value in the tick, rather than just its rank/order, so that you could have ticks placed arbitrarily on the bar. I've created an example survey to test this out:
{
"type": "text",
"inputType": "range",
"name": "favoriteIrrational",
"title": "What is your favorite irrational number?",
"min": 1,
"max": 4,
"step": "any",
"progressBar": true,
"valueLabels": [
{ "value": 1.4142, "text": "√2" },
{ "value": 1.618, "text": "φ" },
{ "value": 2.7182, "text": "e" },
{ "value": 3.1415, "text": "π" }
]
}
currently it looks like this:
But it should look more like this:
This seems to be what is happening in this example:
@gumillie222 can you just read over this issue and check if its complete?
We are using SurveyJS as a base for a react component library. (You shouldn't need to know anything about SurveyJS to do this task). We have modified SurveyJS's range slider component so that the user can add labels to the slider to indicate values. I need the CSS for these labels (and possibly the range slider component if necessary) to be updated. Right now what I have looks like this:
The relevant DOM elements are:
and
I want it to look like this:
The code that controls these elements is found in this repo in
src/customQuestionTypes/labeledRange.js
andsrc/customQuestionTypes/labeledRange.css
. I believe we should be able to make these changes just within the CSS file, but I'm ok with modifying the JS if necessary.The major differences are:
Note:
mousedown
event) so that we don't bias the respondent's answer. This is the desired behavior, and you shouldn't need to change it.Setup
Then start the test suite by running:
This will open cypress (it should load its needed dependencies) and then you can click "start component testing".
Run the spec called
labeledRangeTest
to view the component. Changes to the CSS and JS will get automatically applied to the page.Please submit code by PR to this repo, and questions on this issue thread. =)
Resources
Styling for consistency across browsers:
Examples of styling ticks:
GH issue for adding the slider (work we have done so far): https://github.com/Watts-Lab/surveys/issues/1