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

Add textarea variant to checkbox component #3403

Merged
merged 10 commits into from
Oct 29, 2024
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/checkboxes/_checkbox-macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"name": params.other.name,
"value": params.other.value,
"label": {
rmccar marked this conversation as resolved.
Show resolved Hide resolved
"id": params.other.id + "-label",
"text": params.other.label.text,
"description": params.other.label.description,
"classes": 'ons-u-fw-n'
Expand Down
1 change: 1 addition & 0 deletions src/components/checkboxes/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ describe('macro: checkboxes', () => {
it('renders the text area with expected parameters', () => {
const $ = cheerio.load(renderComponent('checkboxes', EXAMPLE_CHECKBOX_ITEM_CHECKBOXES_WITH_TEXTAREA));
expect($('.ons-input--textarea').attr('name')).toBe('other answer');
expect($('.ons-input--textarea').attr('maxlength')).toBe('300');
expect($('.ons-input__limit').attr('data-charcount-singular')).toBe('You have {x} character remaining');
expect($('.ons-input__limit').attr('data-charcount-plural')).toBe('You have {x} characters remaining');
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{% from "components/question/_macro.njk" import onsQuestion %}
{% from "components/checkboxes/_macro.njk" import onsCheckboxes %}

{%
call onsQuestion({
"title": "Do you have any dietary requirements?",
"legendIsQuestionTitle": true,
"classes": "ons-u-mt-no"
})
%}
{{
onsCheckboxes({
"checkboxesLabel": "Select all that apply",
"dontWrap": true,
"checkboxes": [
{
"id": "gluten-free-example-checkbox-with-revealed-text-area",
"label": {
"text": "Gluten free"
},
"value": "gluten-free"
},
{
"id": "lactose-intolerant-example-checkbox-with-revealed-text-area",
"label": {
"text": "Lactose intolerant"
},
"value": "lactose-intolerant"
},
{
"id": "vegan-example-checkbox-with-revealed-text-area",
"label": {
"text": "Vegan"
},
"value": "vegan"
},
{
"id": "vegetarian-example-checkbox-with-revealed-text-area",
"label": {
"text": "Vegetarian"
},
"value": "vegetarian"
},
{
"id": "other-checkbox-with-revealed-text-area",
"label": {
"text": "Other"
},
"value": "other",
"checked": true,
rmccar marked this conversation as resolved.
Show resolved Hide resolved
"other": {
"otherType": "textarea",
"id": "other-textbox-example-checkbox-with-revealed-text-area",
"name": "other-answer",
"label": {
"text": "Provide more details"
},
"charCheckLimit": {
"limit": 200,
"charCountSingular": "You have {x} character remaining",
"charCountPlural": "You have {x} characters remaining"
}
rmccar marked this conversation as resolved.
Show resolved Hide resolved
}
}
]
})
}}
{% endcall %}
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,35 @@
"dontWrap": true,
"checkboxes": [
{
"id": "gluten-free-example-checkbox-with-revealed-text-input",
"id": "gluten-free-example-checkbox-with-revealed-text-area",
"label": {
"text": "Gluten free"
},
"value": "gluten-free"
},
{
"id": "lactose-intolerant-example-checkbox-with-revealed-text-input",
"id": "lactose-intolerant-example-checkbox-with-revealed-text-area",
"label": {
"text": "Lactose intolerant"
},
"value": "lactose-intolerant"
},
{
"id": "vegan-example-checkbox-with-revealed-text-input",
"id": "vegan-example-checkbox-with-revealed-text-area",
"label": {
"text": "Vegan"
},
"value": "vegan"
},
{
"id": "vegetarian-example-checkbox-with-revealed-text-input",
"id": "vegetarian-example-checkbox-with-revealed-text-area",
"label": {
"text": "Vegetarian"
},
"value": "vegetarian"
},
{
"id": "other-checkbox-with-revealed-text-input",
"id": "other-checkbox-with-revealed-text-area",
"label": {
"text": "Other"
},
Expand All @@ -55,7 +55,7 @@
"text": "Provide more details"
},
"charCheckLimit": {
"limit": 400,
"limit": 200,
"charCountSingular": "You have {x} character remaining",
"charCountPlural": "You have {x} characters remaining"
}
Expand Down