From 09d11c0308846182976b6a8df9eb54488d7afac6 Mon Sep 17 00:00:00 2001 From: stvnrlly Date: Mon, 18 Dec 2023 21:48:58 -0500 Subject: [PATCH] remove unused textarea component --- app/main/forms.py | 43 ---------- .../components/components/textarea/README.md | 15 ---- .../components/textarea/macro-options.json | 85 ------------------- .../components/components/textarea/macro.njk | 3 - .../components/textarea/template.njk | 44 ---------- 5 files changed, 190 deletions(-) delete mode 100644 app/templates/components/components/textarea/README.md delete mode 100644 app/templates/components/components/textarea/macro-options.json delete mode 100644 app/templates/components/components/textarea/macro.njk delete mode 100644 app/templates/components/components/textarea/template.njk diff --git a/app/main/forms.py b/app/main/forms.py index 56fdca51b..a3b38f779 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -815,49 +815,6 @@ class GovukCheckboxField(BooleanField): ) -class GovukTextareaField(TextAreaField): - def __init__(self, label="", validators=None, param_extensions=None, **kwargs): - super(TextAreaField, self).__init__(label, validators, **kwargs) - self.param_extensions = param_extensions - - # self.__call__ renders the HTML for the field by: - # 1. delegating to self.meta.render_field which - # 2. calls field.widget - # this bypasses that by making self.widget a method with the same interface as widget.__call__ - def widget(self, field, param_extensions=None, **kwargs): - # error messages - error_message = None - if field.errors: - error_message = {"text": field.errors[0]} - - params = { - "name": field.name, - "id": field.id, - "rows": 8, - "label": { - "text": field.label.text, - "classes": None, - "isPageHeading": False, - }, - "hint": {"text": None}, - "errorMessage": error_message, - } - - # extend default params with any sent in during instantiation - if self.param_extensions: - merge_jsonlike(params, self.param_extensions) - - # add any sent in though use in templates - if param_extensions: - merge_jsonlike(params, param_extensions) - - return Markup( - render_template( - "components/components/textarea/template.njk", params=params - ) - ) - - # based on work done by @richardjpope: https://github.com/richardjpope/recourse/blob/master/recourse/forms.py#L6 class GovukCheckboxesField(SelectMultipleField): render_as_list = False diff --git a/app/templates/components/components/textarea/README.md b/app/templates/components/components/textarea/README.md deleted file mode 100644 index b8a8e0b3e..000000000 --- a/app/templates/components/components/textarea/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Textarea - -## Installation - -See the [main README quick start guide](https://github.com/alphagov/govuk-frontend#quick-start) for how to install this component. - -## Guidance and Examples - -Find out when to use the textarea component in your service in the [GOV.UK Design System](https://design-system.service.gov.uk/components/textarea). - -## Component options - -Use options to customize the appearance, content and behavior of a component when using a macro, for example, changing the text. - -See [options table](https://design-system.service.gov.uk/components/textarea/#options-example-default) for details. \ No newline at end of file diff --git a/app/templates/components/components/textarea/macro-options.json b/app/templates/components/components/textarea/macro-options.json deleted file mode 100644 index ea2eefa9f..000000000 --- a/app/templates/components/components/textarea/macro-options.json +++ /dev/null @@ -1,85 +0,0 @@ -[ - { - "name": "id", - "type": "string", - "required": true, - "description": "The id of the textarea." - }, - { - "name": "name", - "type": "string", - "required": true, - "description": "The name of the textarea, which is submitted with the form data." - }, - { - "name": "rows", - "type": "string", - "required": false, - "description": "Optional number of textarea rows (default is 5 rows)." - }, - { - "name": "value", - "type": "string", - "required": false, - "description": "Optional initial value of the textarea." - }, - { - "name": "describedBy", - "type": "string", - "required": false, - "description": "One or more element IDs to add to the `aria-describedby` attribute, used to provide additional descriptive information for screenreader users." - }, - { - "name": "label", - "type": "object", - "required": true, - "description": "Options for the label component.", - "isComponent": true - }, - { - "name": "hint", - "type": "object", - "required": false, - "description": "Options for the hint component.", - "isComponent": true - }, - { - "name": "errorMessage", - "type": "object", - "required": false, - "description": "Options for the errorMessage component (e.g. text).", - "isComponent": true - }, - { - "name": "formGroup", - "type": "object", - "required": false, - "description": "Options for the form-group wrapper", - "params": [ - { - "name": "classes", - "type": "string", - "required": false, - "description": "Classes to add to the form group (e.g. to show error state for the whole group)" - } - ] - }, - { - "name": "classes", - "type": "string", - "required": false, - "description": "Classes to add to the textarea." - }, - { - "name": "autocomplete", - "type": "string", - "required": false, - "description": "Attribute to [identify input purpose](https://www.w3.org/WAI/WCAG21/Understanding/identify-input-purpose.html), for instance \"postal-code\" or \"username\". See [autofill](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill) for full list of attributes that can be used." - }, - { - "name": "attributes", - "type": "object", - "required": false, - "description": "HTML attributes (for example data attributes) to add to the textarea." - } -] \ No newline at end of file diff --git a/app/templates/components/components/textarea/macro.njk b/app/templates/components/components/textarea/macro.njk deleted file mode 100644 index 36a1c4ee7..000000000 --- a/app/templates/components/components/textarea/macro.njk +++ /dev/null @@ -1,3 +0,0 @@ -{% macro govukTextarea(params) %} - {%- include "./template.njk" -%} -{% endmacro %} diff --git a/app/templates/components/components/textarea/template.njk b/app/templates/components/components/textarea/template.njk deleted file mode 100644 index 82c3ac751..000000000 --- a/app/templates/components/components/textarea/template.njk +++ /dev/null @@ -1,44 +0,0 @@ -{% from "../error-message/macro.njk" import usaErrorMessage -%} -{% from "../hint/macro.njk" import usaHint %} -{% from "../label/macro.njk" import usaLabel %} - -{#- a record of other elements that we need to associate with the input using - aria-describedby – for example hints or error messages -#} -{% set describedBy = params.describedBy if params.describedBy else "" %} -
- {{ usaLabel({ - html: params.label.html, - text: params.label.text, - classes: params.label.classes, - isPageHeading: params.label.isPageHeading, - attributes: params.label.attributes, - for: params.id - }) | indent(2) | trim }} -{% if params.hint %} - {% set hintId = params.id + '-hint' %} - {% set describedBy = describedBy + ' ' + hintId if describedBy else hintId %} - {{ usaHint({ - id: hintId, - classes: params.hint.classes, - attributes: params.hint.attributes, - html: params.hint.html, - text: params.hint.text - }) | indent(2) | trim }} -{% endif %} -{% if params.errorMessage %} - {% set errorId = params.id + '-error' %} - {% set describedBy = describedBy + ' ' + errorId if describedBy else errorId %} - {{ usaErrorMessage({ - id: errorId, - classes: params.errorMessage.classes, - attributes: params.errorMessage.attributes, - html: params.errorMessage.html, - text: params.errorMessage.text, - visuallyHiddenText: params.errorMessage.visuallyHiddenText - }) | indent(2) | trim }} -{% endif %} - -