Skip to content

Commit

Permalink
amelioration(design): ETQ usager la cohabitation du design d'un form …
Browse files Browse the repository at this point in the history
…mi-DSFR, mi-DS n'est pas trop moche

amelioration(design): ETQ usager la cohabitation du design d'un form mi-DSFR, mi-DS n'est pas trop moche
  • Loading branch information
Martin authored and mfo committed Jul 6, 2023
1 parent 7be1036 commit fb53190
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 25 deletions.
14 changes: 5 additions & 9 deletions app/assets/stylesheets/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
}

&.editable-champ-checkbox {
p,
label {
padding-left: 28px;
font-weight: normal;
Expand Down Expand Up @@ -157,7 +156,7 @@
user-select: none;

&:last-of-type {
margin-bottom: $default-fields-spacer;
margin-bottom: 0;
}

&:hover {
Expand Down Expand Up @@ -193,6 +192,7 @@
font-weight: normal;
}
}

.fr-label {
// la description d'un champ peut contenir du markup (markdown->html),
// on herite donc la fontsize/mrgin/padding du fr-hint-text
Expand All @@ -202,10 +202,12 @@
padding: inherit;
}
}

input[type=password],
select {
display: block;
margin-bottom: $default-fields-spacer;
margin-bottom: 0;

&.small-margin {
margin-bottom: $default-spacer;
Expand Down Expand Up @@ -330,7 +332,7 @@

margin-left: 5px;
margin-right: 4px;
margin-bottom: $default-fields-spacer;
margin-bottom: 0;
}

select {
Expand Down Expand Up @@ -542,12 +544,6 @@
}
}

[data-react-component-value]:not([data-react-component-value^="ComboMultiple"]) {
[data-reach-combobox-input]:not(.no-margin) {
margin-bottom: $default-fields-spacer;
}
}

[data-react-component-value^="ComboMultiple"] {
margin-bottom: $default-fields-spacer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.attachment.fr-upload-group{ { id: attachment ? dom_id(attachment, :edit) : nil, class: class_names("fr-mb-2w": !(as_multiple? && downloadable?)) }.compact, **replace_controller_attributes }
.attachment.fr-upload-group{ { id: attachment ? dom_id(attachment, :edit) : nil, class: class_names("fr-mb-1w": !(as_multiple? && downloadable?)) }.compact, **replace_controller_attributes }
- if persisted?
%div{ id: dom_id(attachment, :persisted_row) }
.flex.flex-gap-2{ class: class_names("attachment-error": attachment.virus_scanner_error?) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.fr-mb-4w.attachment-multiple{ class: class_names("fr-downloads-group": view_as == :download, "destroyable": user_can_destroy?), **replace_controller_attributes }
.attachment-multiple{ class: class_names("fr-downloads-group": view_as == :download, "destroyable": user_can_destroy?), **replace_controller_attributes }
= template
%ul
- each_attachment do |attachment, index|
%li{ id: dom_id(attachment) }
= render Attachment::EditComponent.new(champ:, attached_file:, attachment:, index:, as_multiple: true, view_as:, user_can_destroy:, user_can_replace:, form_object_name:)
- if @attachments.size >= 1
%ul.fr-my-1v
- each_attachment do |attachment, index|
%li{ id: dom_id(attachment) }
= render Attachment::EditComponent.new(champ:, attached_file:, attachment:, index:, as_multiple: true, view_as:, user_can_destroy:, user_can_replace:, form_object_name:)
%div{ id: empty_component_id, class: class_names("hidden": !can_attach_next?) }
= render Attachment::EditComponent.new(champ:, attached_file:, attachment: nil, index: attachments_count, user_can_destroy:, user_can_replace:, form_object_name:)
Expand Down
3 changes: 0 additions & 3 deletions app/components/dsfr/input_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def label
object.class.human_attribute_name(@attribute)
end


# kind of input helpers
def password?
@input_type == :password_field
Expand All @@ -64,6 +63,4 @@ def show_password_id
end

private


end
4 changes: 2 additions & 2 deletions app/components/dsfr/input_errorable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def input_opts(other_opts = {})
end

def describedby_id
dom_id(@champ, :error_messages)
dom_id(@champ, :error_full_messages)
end

def errors_on_another_attribute?
Expand All @@ -78,7 +78,7 @@ def errors_on_attribute?
end

# errors helpers
def error_messages
def error_full_messages
errors.full_messages_for(attribute_or_rich_body)
end

Expand Down
2 changes: 1 addition & 1 deletion app/components/editable_champ/editable_champ_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def html_options
'editable-champ': true,
"editable-champ-#{@champ.type_champ}": true,
"hidden": !@champ.visible?,
"fr-input-group": true,
"fr-input-group": true
}.merge(input_group_error_class_names)
),
id: @champ.input_group_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
= render component_class.new(form: @form, champ: @champ, seen_at: @seen_at)

- if errors_on_attribute?
- if error_messages.size == 1
%p.fr-error-text{ id: describedby_id }= error_messages.first
- if error_full_messages.size == 1
%p.fr-error-text{ id: describedby_id }= error_full_messages.first
- else
.fr-error-text{ id: describedby_id }
%ul.list-style-type-none.fr-pl-0
- error_messages.map do |error_message|
- error_full_messages.each do |error_message|
%li= error_message

= @form.hidden_field :id, value: @champ.id
2 changes: 1 addition & 1 deletion app/views/users/dossiers/update.turbo_stream.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
= render EditableChamp::EditableChampComponent.new champ:, form:
- else
= turbo_stream.update champ.labelledby_id do
= render EditableChamp::ChampLabelContentComponent.new champ:
= render EditableChamp::ChampLabelContentComponent.new champ:, form:

= turbo_stream.remove_all(".editable-champ .spinner-removable");
= turbo_stream.hide_all(".editable-champ .spinner");
Expand Down

0 comments on commit fb53190

Please sign in to comment.