Update file upload component to use govuk-frontend buttons

This commit is contained in:
Katie Smith
2020-02-06 13:35:08 +00:00
parent 2cbfaf1b6f
commit e53c5e17b3
4 changed files with 9 additions and 15 deletions

View File

@@ -6,13 +6,17 @@
this.submit = () => this.$form.trigger('submit');
this.showCancelButton = () => $('.file-upload-button', this.$form).replaceWith(`
<a href="" class='file-upload-button-cancel'>Cancel upload</a>
<a href="" class='govuk-button govuk-button--warning govuk-!-margin-right-1'>Cancel upload</a>
`);
this.start = function(component) {
this.$form = $(component);
// The label gets styled like a button and is used to hide the native file upload control. This is so that
// users see a button that looks like the others on the site.
this.$form.find('label.file-upload-button').addClass('govuk-button govuk-!-margin-right-1');
// Clear the form if the user navigates back to the page
$(window).on("pageshow", () => this.$form[0].reset());