Outline styling, refactor help text logic

This commit is contained in:
zandercymatics 2024-01-31 12:54:32 -07:00
parent a682796570
commit 340e395c00
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
3 changed files with 34 additions and 25 deletions

View file

@ -28,8 +28,10 @@
td {
.no-click-outline, .no-click-outline:hover, .no-click-outline:focus{
cursor: default !important;
outline: none !important;
outline: none;
}
.cursor-help{
cursor: help;
}
}

View file

@ -139,6 +139,33 @@ class Domain(TimeStampedModel, DomainHelper):
# previously existed but has been deleted from the registry
DELETED = "deleted", "Deleted"
@classmethod
def get_help_text(cls, state) -> str:
"""Returns a help message for a desired state. If none is found, an empty string is returned"""
help_texts = {
# For now, unknown has the same message as DNS_NEEDED
cls.UNKNOWN:(
"Before this domain can be used, "
"youll need to add name server addresses."
),
cls.DNS_NEEDED: (
"Before this domain can be used, "
"youll need to add name server addresses."
),
cls.READY: "This domain has name servers and is ready for use.",
cls.ON_HOLD: (
"This domain is administratively paused, "
"so it cant be edited and wont resolve in DNS. "
"Contact help@get.gov for details."
),
cls.DELETED: (
"This domain has been removed and "
"is no longer registered to your organization."
)
}
return help_texts.get(state, "")
class Cache(property):
"""
Python descriptor to turn class methods into properties.
@ -1399,27 +1426,7 @@ class Domain(TimeStampedModel, DomainHelper):
def get_state_help_text(self) -> str:
"""Returns a str containing additional information about a given state"""
help_text = ""
print(f"self state is {self.state}")
match self.state:
case self.State.DNS_NEEDED | self.State.UNKNOWN:
help_text = (
"Before this domain can be used, "
"youll need to add name server addresses."
)
case self.State.READY:
help_text = "This domain has name servers and is ready for use."
case self.State.ON_HOLD:
help_text = (
"This domain is administratively paused, "
"so it cant be edited and wont resolve in DNS. "
"Contact help@get.gov for details."
)
case self.State.DELETED:
help_text = (
"This domain has been removed and "
"is no longer registered to your organization."
)
help_text = Domain.State.get_help_text(self.state)
return help_text
def _disclose_fields(self, contact: PublicContact):

View file

@ -48,7 +48,7 @@
</th>
<td data-sort-value="{{ domain.expiration_date|date:"U" }}" data-label="Expires">{{ domain.expiration_date|date }}</td>
<td data-label="Status">
<span class="usa-tooltip"
<span class="usa-tooltip no-click-outline cursor-help"
data-position="top"
title="{{domain.get_state_help_text}}"
aria-ignore="true"
@ -62,7 +62,7 @@
{{ domain.state|capfirst }}
{% endif %}
<svg
class="usa-icon usa-tooltip text-middle margin-bottom-05 text-accent-cool"
class="usa-icon usa-tooltip text-middle margin-bottom-05 text-accent-cool no-click-outline cursor-help"
role="img"
data-position="top"
title="{{domain.get_state_help_text}}"