Skip to content

Commit

Permalink
Remove margin between file input field and link
Browse files Browse the repository at this point in the history
The file input field is wrapped by a `div` with class `.form-item` and
thus gets a bottom margin. The `p` element containing the link to the
current file has a top margin. So there is a lot of space between input
field and link. This change sets these margins to `0`.
  • Loading branch information
Dominic Tubach committed Oct 4, 2024
1 parent 62fe681 commit 3a40208
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions modules/civiremote_entity/civiremote_entity.libraries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
file-field:
css:
theme:
css/file-field.css: {}
9 changes: 9 additions & 0 deletions modules/civiremote_entity/css/file-field.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.form-item:has(+.civiremote-form-file-link) {
/* No margin between file form item and link. */
margin-bottom: 0;
}

.civiremote-form-file-link {
/* No margin between file form item and link. */
margin-top: 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public function createFormArray(
&& is_string($form['file']['#default_value']->url ?? NULL)
&& is_string($form['file']['#default_value']->filename ?? NULL)
) {
// @phpstan-ignore offsetAccess.nonOffsetAccessible, offsetAccess.nonOffsetAccessible
$form['file']['#attached']['library'][] = 'civiremote_entity/file-field';

$url = $form['file']['#default_value']->url;
$filename = $form['file']['#default_value']->filename;

Expand All @@ -82,7 +85,7 @@ public function createFormArray(
'#title' => $filename,
'#url' => $this->civiCRMUrlManager->addRemoteUrl($url, $filename),
'#attributes' => ['target' => '_blank'],
'#prefix' => '<p>',
'#prefix' => '<p class="civiremote-form-file-link">',
'#suffix' => '</p>',
];

Expand Down

0 comments on commit 3a40208

Please sign in to comment.