Closed Ayush-Vashisht closed 3 weeks ago
Hey Ayush - this is great. One small change:
If the user specifies a style in the Survey object, it should override the default style in the element. For example:
async function runSurvey() {
const survey = new Survey({
styles: {
questionLabel: {
fontWeight: '400',
marginTop: '100px',
},
}
});
const q1 = new SingleSelect({
id: 'travel_frequency',
text: 'How often do you travel for business?',
options: ['Never', 'Once a year', '2-3 times a year', '4-6 times a year', 'Monthly', 'Weekly'],
required: true,
});
await survey.showPage({ id: 'page1', elements: [q1] });
survey.finishSurvey('Thank you for completing our business travel survey!');
};
This should set the font weight of the questionLabel to 400 (even though it's bold by default in SingleSelect), and the marginTop to '100px' (this works in your current implementation. The user can then override survey specific styling in the element:
async function runSurvey() {
const survey = new Survey({
styles: {
questionLabel: {
fontWeight: '400',
marginTop: '100px',
},
}
});
const q1 = new SingleSelect({
id: 'travel_frequency',
text: 'How often do you travel for business?',
options: ['Never', 'Once a year', '2-3 times a year', '4-6 times a year', 'Monthly', 'Weekly'],
required: true,
styles: {
questionLabel: {
fontWeight: '600', // Override the survey font weight for this element
},
}
});
await survey.showPage({ id: 'page1', elements: [q1] });
survey.finishSurvey('Thank you for completing our business travel survey!');
};
Other than that, looks great, and we just have to apply the same selector updates to every element type.
Thanks Ayush. Right now this only works for singleSelect - we should go through and update every element type so that the survey styling applies to it. I can take a stab at that and then merge it with your changes, but I'll hold off on approving the PR until that's ready.
This pull request addresses the following issue:
Issue: #24
Changes:
getSelectorForKey
method to handlequestionRoot
,label
, andsubText
styles.Example Usage: