Browse Source

Fix styling issues

pull/235/head
baarkerlounger 3 years ago
parent
commit
0881fc804f
  1. 25
      app/helpers/question_view_helper.rb
  2. 4
      app/views/form/_checkbox_question.html.erb
  3. 4
      app/views/form/_date_question.html.erb
  4. 4
      app/views/form/_numeric_question.html.erb
  5. 4
      app/views/form/_radio_question.html.erb
  6. 4
      app/views/form/_select_question.html.erb
  7. 4
      app/views/form/_text_question.html.erb
  8. 4
      app/views/form/_textarea_question.html.erb
  9. 2
      app/views/form/page.html.erb

25
app/helpers/question_view_helper.rb

@ -0,0 +1,25 @@
module QuestionViewHelper
def caption(caption, page_header, conditional)
return nil unless caption && page_header.blank? && !conditional
{ text: caption.html_safe, size: "l" }
end
def legend(question, page_header, conditional)
{
text: question.header.html_safe,
size: label_size(page_header, conditional),
tag: label_tag(page_header, conditional),
}
end
private
def label_size(page_header, conditional)
page_header.blank? && !conditional ? "l" : "m"
end
def label_tag(page_header, conditional)
page_header.blank? && !conditional ? "h1" : "h2"
end
end

4
app/views/form/_checkbox_question.html.erb

@ -1,8 +1,8 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %> <%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= f.govuk_check_boxes_fieldset question.id.to_sym, <%= f.govuk_check_boxes_fieldset question.id.to_sym,
caption: caption && !page_header.present? ? { text: caption.html_safe, size: "l" } : nil, caption: caption(caption, page_header, conditional),
legend: { text: question.header.html_safe, size: !page_header.present? ? "l" : "m", tag: !page_header.present? ? "h1" : "h2" }, legend: legend(question, page_header, conditional),
hint: { text: question.hint_text&.html_safe } do %> hint: { text: question.hint_text&.html_safe } do %>
<% question.answer_options.map do |key, val| %> <% question.answer_options.map do |key, val| %>

4
app/views/form/_date_question.html.erb

@ -1,8 +1,8 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %> <%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= f.govuk_date_field question.id.to_sym, <%= f.govuk_date_field question.id.to_sym,
caption: caption && !page_header.present? ? { text: caption.html_safe, size: "l" } : nil, caption: caption(caption, page_header, conditional),
legend: { text: question.header.html_safe, size: !page_header.present? ? "l" : "m", tag: !page_header.present? ? "h1" : "h2" }, legend: legend(question, page_header, conditional),
hint: { text: question.hint_text&.html_safe }, hint: { text: question.hint_text&.html_safe },
width: 20, width: 20,
**stimulus_html_attributes(question) **stimulus_html_attributes(question)

4
app/views/form/_numeric_question.html.erb

@ -1,8 +1,8 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %> <%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= f.govuk_number_field question.id.to_sym, <%= f.govuk_number_field question.id.to_sym,
caption: caption && !page_header.present? ? { text: caption.html_safe, size: "l" } : nil, caption: caption(caption, page_header, conditional),
label: { text: question.header.html_safe, size: !page_header.present? ? "l" : "m", tag: !page_header.present? ? "h1" : "h2" }, label: legend(question, page_header, conditional),
hint: { text: question.hint_text&.html_safe }, hint: { text: question.hint_text&.html_safe },
min: question.min, max: question.max, step: question.step, min: question.min, max: question.max, step: question.step,
width: question.width, :readonly => question.read_only?, width: question.width, :readonly => question.read_only?,

4
app/views/form/_radio_question.html.erb

@ -1,8 +1,8 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %> <%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= f.govuk_radio_buttons_fieldset question.id.to_sym, <%= f.govuk_radio_buttons_fieldset question.id.to_sym,
caption: caption && !page_header.present? ? { text: caption.html_safe, size: "l" } : nil, caption: caption(caption, page_header, conditional),
legend: { text: question.header.html_safe, size: !page_header.present? ? "l" : "m", tag: !page_header.present? ? "h1" : "h2" }, legend: legend(question, page_header, conditional),
hint: { text: question.hint_text&.html_safe } do %> hint: { text: question.hint_text&.html_safe } do %>
<% question.answer_options.map do |key, val| %> <% question.answer_options.map do |key, val| %>

4
app/views/form/_select_question.html.erb

@ -6,8 +6,8 @@
answers, answers,
:id, :id,
:name, :name,
caption: caption && !page_header.present? ? { text: caption.html_safe, size: "l" } : nil, caption: caption(caption, page_header, conditional),
label: { text: question.header, size: !page_header.present? ? "l" : "m", tag: !page_header.present? ? "h1" : "h2" }, label: legend(question, page_header, conditional),
hint: { text: question.hint_text&.html_safe }, hint: { text: question.hint_text&.html_safe },
options: { disabled: [""], selected: selected }, options: { disabled: [""], selected: selected },
"data-controller": "accessible-autocomplete" "data-controller": "accessible-autocomplete"

4
app/views/form/_text_question.html.erb

@ -1,8 +1,8 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %> <%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= f.govuk_text_field question.id.to_sym, <%= f.govuk_text_field question.id.to_sym,
caption: caption && !page_header.present? ? { text: caption.html_safe, size: "l" } : nil, caption: caption(caption, page_header, conditional),
label: { text: question.header.html_safe, size: !page_header.present? ? "l" : "m", tag: !page_header.present? ? "h1" : "h2" }, label: legend(question, page_header, conditional),
hint: { text: question.hint_text&.html_safe }, hint: { text: question.hint_text&.html_safe },
width: question.width ? question.width : nil, width: question.width ? question.width : nil,
**stimulus_html_attributes(question) **stimulus_html_attributes(question)

4
app/views/form/_textarea_question.html.erb

@ -1,8 +1,8 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %> <%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= f.govuk_text_area question.id.to_sym, <%= f.govuk_text_area question.id.to_sym,
caption: caption && !page_header.present? ? { text: caption.html_safe, size: "l" } : nil, caption: caption(caption, page_header, conditional),
label: { text: question.header.html_safe, size: !page_header.present? ? "l" : "m", tag: !page_header.present? ? "h1" : "h2" }, label: legend(question, page_header, conditional),
hint: { text: question.hint_text&.html_safe }, hint: { text: question.hint_text&.html_safe },
width: question.width ? question.width : nil, width: question.width ? question.width : nil,
**stimulus_html_attributes(question) **stimulus_html_attributes(question)

2
app/views/form/page.html.erb

@ -36,7 +36,7 @@
<% if question.read_only? %> <% if question.read_only? %>
<hr class="govuk-section-break govuk-section-break--visible govuk-section-break--m"> <hr class="govuk-section-break govuk-section-break--visible govuk-section-break--m">
<% end %> <% end %>
<%= render partial: "form/#{question.type}_question", locals: { question: question, caption: @subsection.label, page_header: @page.header, f: f } %> <%= render partial: "form/#{question.type}_question", locals: { question: question, caption: @subsection.label, page_header: @page.header, f: f, conditional: false } %>
</div> </div>
<% end %> <% end %>

Loading…
Cancel
Save