refactor icons in links and buttons

This commit is contained in:
Rachid Mrad 2024-08-29 19:16:53 -04:00
parent 87bde33ca2
commit 8f609fef95
No known key found for this signature in database
7 changed files with 47 additions and 37 deletions

View file

@ -1910,7 +1910,7 @@ document.addEventListener('DOMContentLoaded', function() {
let editableFormGroup = button.parentElement.parentElement.parentElement; let editableFormGroup = button.parentElement.parentElement.parentElement;
if (editableFormGroup){ if (editableFormGroup){
let readonlyField = editableFormGroup.querySelector(".input-with-edit-button__readonly-field") let readonlyField = editableFormGroup.querySelector(".toggleable_input__readonly-field")
let inputField = document.getElementById(`id_${fieldName}`); let inputField = document.getElementById(`id_${fieldName}`);
if (!inputField || !readonlyField) { if (!inputField || !readonlyField) {
return; return;
@ -1936,8 +1936,8 @@ document.addEventListener('DOMContentLoaded', function() {
// Keep the path before '#' and replace the part after '#' with 'invalid' // Keep the path before '#' and replace the part after '#' with 'invalid'
const newHref = parts[0] + '#error'; const newHref = parts[0] + '#error';
svg.setAttribute('xlink:href', newHref); svg.setAttribute('xlink:href', newHref);
fullNameField.classList.add("input-with-edit-button__error") fullNameField.classList.add("toggleable_input__error")
label = fullNameField.querySelector(".input-with-edit-button__readonly-field") label = fullNameField.querySelector(".toggleable_input__readonly-field")
label.innerHTML = "Unknown"; label.innerHTML = "Unknown";
} }
} }

View file

@ -199,3 +199,7 @@ abbr[title] {
max-width: 50ch; max-width: 50ch;
} }
} }
.margin-right-neg-4px {
margin-right: -4px;
}

View file

@ -124,10 +124,6 @@ a.withdraw:active {
background-color: color('error-darker'); background-color: color('error-darker');
} }
.usa-button--unstyled .usa-icon {
vertical-align: bottom;
}
a.usa-button--unstyled:visited { a.usa-button--unstyled:visited {
color: color('primary'); color: color('primary');
} }
@ -162,14 +158,14 @@ a.usa-button--unstyled:visited {
} }
} }
.input-with-edit-button { .toggleable_input {
svg.usa-icon { svg.usa-icon {
width: 1.5em !important; width: 1.5em !important;
height: 1.5em !important; height: 1.5em !important;
color: #{$dhs-green}; color: #{$dhs-green};
position: absolute; position: absolute;
} }
&.input-with-edit-button__error { &.toggleable_input__error {
svg.usa-icon { svg.usa-icon {
color: #{$dhs-red}; color: #{$dhs-red};
} }
@ -205,12 +201,36 @@ a.usa-button--unstyled:visited {
} }
} }
.dotgov-table a,
.usa-link--icon,
.usa-button--with-icon {
display: flex;
align-items: flex-start;
color: color('primary');
column-gap: units(.5);
align-items: center;
}
.dotgov-table a,
.usa-link--icon {
&:visited {
color: color('primary');
}
}
a .usa-icon,
.usa-button--with-icon .usa-icon {
height: 1.2em;
width: 1.2em;
}
a .usa-icon {
margin-top: -.1rem;
}
.usa-icon.usa-icon--big { .usa-icon.usa-icon--big {
margin: 0; margin: 0;
height: 1.5em; height: 1.5em;
width: 1.5em; width: 1.5em;
}
.margin-right-neg-4px {
margin-right: -4px;
} }

View file

@ -1,18 +1,4 @@
@use "uswds-core" as *; @use "uswds-core" as *;
.dotgov-table a,
.usa-link--icon {
display: flex;
align-items: flex-start;
color: color('primary');
&:visited {
color: color('primary');
}
.usa-icon {
// align icon with x height
margin-top: units(0.5);
margin-right: units(0.5);
}
}

View file

@ -63,10 +63,10 @@
<div class="grid-row margin-top-1"> <div class="grid-row margin-top-1">
<div class="grid-col"> <div class="grid-col">
<button type="button" class="usa-button usa-button--unstyled display-block float-right-tablet delete-record"> <button type="button" class="usa-button usa-button--unstyled usa-button--with-icon float-right-tablet delete-record">
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24"> <svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
<use xlink:href="{%static 'img/sprite.svg'%}#delete"></use> <use xlink:href="{%static 'img/sprite.svg'%}#delete"></use>
</svg><span class="margin-left-05">Delete</span> </svg>Delete
</button> </button>
</div> </div>
</div> </div>
@ -74,10 +74,10 @@
</fieldset> </fieldset>
{% endfor %} {% endfor %}
<button type="button" class="usa-button usa-button--unstyled display-block margin-bottom-2" id="add-form"> <button type="button" class="usa-button usa-button--unstyled usa-button--with-icon margin-bottom-2" id="add-form">
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24"> <svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
<use xlink:href="{%static 'img/sprite.svg'%}#add_circle"></use> <use xlink:href="{%static 'img/sprite.svg'%}#add_circle"></use>
</svg><span class="margin-left-05">Add new record</span> </svg>Add new record
</button> </button>
<button <button

View file

@ -52,20 +52,20 @@
{% endwith %} {% endwith %}
</div> </div>
<div class="tablet:grid-col-2"> <div class="tablet:grid-col-2">
<button type="button" class="usa-button usa-button--unstyled display-block delete-record margin-bottom-075"> <button type="button" class="usa-button usa-button--unstyled usa-button--with-icon delete-record margin-bottom-075">
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24"> <svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
<use xlink:href="{%static 'img/sprite.svg'%}#delete"></use> <use xlink:href="{%static 'img/sprite.svg'%}#delete"></use>
</svg><span class="margin-left-05">Delete</span> </svg>Delete
</button> </button>
</div> </div>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
<button type="button" class="usa-button usa-button--unstyled display-block" id="add-form"> <button type="button" class="usa-button usa-button--unstyled usa-button--with-icon" id="add-form">
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24"> <svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
<use xlink:href="{%static 'img/sprite.svg'%}#add_circle"></use> <use xlink:href="{%static 'img/sprite.svg'%}#add_circle"></use>
</svg><span class="margin-left-05">Add another name server</span> </svg>Add another name server
</button> </button>
{% comment %} Work around USWDS' button margins to add some spacing between the submit and the 'add more' {% comment %} Work around USWDS' button margins to add some spacing between the submit and the 'add more'

View file

@ -1,6 +1,6 @@
{% load static field_helpers url_helpers custom_filters %} {% load static field_helpers url_helpers custom_filters %}
<div id="{{field.name}}__edit-button-readonly" class="margin-top-2 margin-bottom-1 input-with-edit-button {% if not field.value and field.field.required %}input-with-edit-button__error{% endif %}"> <div id="{{field.name}}__edit-button-readonly" class="margin-top-2 margin-bottom-1 toggleable_input {% if not field.value and field.field.required %}toggleable_input__error{% endif %}">
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24"> <svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
{% if field.value or not field.field.required %} {% if field.value or not field.field.required %}
<use xlink:href="{%static 'img/sprite.svg'%}#check_circle"></use> <use xlink:href="{%static 'img/sprite.svg'%}#check_circle"></use>
@ -8,7 +8,7 @@
<use xlink:href="{%static 'img/sprite.svg'%}#error"></use> <use xlink:href="{%static 'img/sprite.svg'%}#error"></use>
{%endif %} {%endif %}
</svg> </svg>
<div class="display-inline padding-left-05 margin-left-3 input-with-edit-button__readonly-field {% if not field.field.required %}text-base{% endif %}"> <div class="display-inline padding-left-05 margin-left-3 toggleable_input__readonly-field {% if not field.field.required %}text-base{% endif %}">
{% if field.name != "phone" %} {% if field.name != "phone" %}
{{ field.value }} {{ field.value }}
{% else %} {% else %}