Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket #1693: Implement "check availability" section on get.gov/domains/choosing/ #269

Merged
merged 42 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
35d6ab6
Basic search
zandercymatics Apr 10, 2024
309edd3
Update domains_choosing.md
zandercymatics Apr 10, 2024
4ae3742
Update domains_choosing.md
zandercymatics Apr 10, 2024
57f9c60
Test wrapping in grid
zandercymatics Apr 11, 2024
ce5ed93
Update styling
zandercymatics Apr 11, 2024
16a71a2
Add padding
zandercymatics Apr 11, 2024
637cdc2
Embed script
zandercymatics Apr 11, 2024
691bf75
Fix button
zandercymatics Apr 11, 2024
d676f93
Move script location
zandercymatics Apr 11, 2024
aa29e80
Fine tuning
zandercymatics Apr 11, 2024
d42fee7
Add margin top
zandercymatics Apr 11, 2024
84853e6
Add whois link
zandercymatics Apr 12, 2024
44b7b09
Update info-page.html
zandercymatics Apr 12, 2024
73d7a7c
Update info-page.html
zandercymatics Apr 12, 2024
0ed140f
Add whois section
zandercymatics Apr 12, 2024
0cd1bfc
Update info-page.html
zandercymatics Apr 12, 2024
e01db2b
Add styles for mobile
zandercymatics Apr 12, 2024
c778608
Remove br
zandercymatics Apr 12, 2024
0d8a199
Add to includes
zandercymatics Apr 12, 2024
d5aa787
Remove white space
zandercymatics Apr 12, 2024
ae50d31
Show/hide error message dynamically
zandercymatics Apr 12, 2024
1150ab8
Fix display none
zandercymatics Apr 12, 2024
4c13c90
Update info-page.html
zandercymatics Apr 12, 2024
199828b
Add custom height to error alert
zandercymatics Apr 12, 2024
d977cc3
Add margin bottom
zandercymatics Apr 17, 2024
9490b60
Test consolidating scripts
zandercymatics Apr 17, 2024
bf03a09
Link script
zandercymatics Apr 17, 2024
3db9cba
Test
zandercymatics Apr 17, 2024
4e1fe10
Move script location
zandercymatics Apr 17, 2024
db094f7
Add flag
zandercymatics Apr 17, 2024
ebb1d5c
Change id
zandercymatics Apr 17, 2024
6b1c398
THE apostrophe
zandercymatics Apr 17, 2024
83770bb
Add manage.get.gov colors
zandercymatics Apr 18, 2024
8bbfc6c
Cleanup
zandercymatics Apr 18, 2024
6ca7441
Test
zandercymatics Apr 18, 2024
7522251
test2
zandercymatics Apr 18, 2024
a4f4ea8
Move availability form
zandercymatics Apr 18, 2024
d6def4d
Add DOM loaded listener
zandercymatics Apr 18, 2024
7726cce
Revert "Add DOM loaded listener"
zandercymatics Apr 18, 2024
47d0df1
Fix styling issues, move to js
zandercymatics Apr 18, 2024
f205961
Fix hatch - revert js change
zandercymatics Apr 18, 2024
471223c
Change excerpt
zandercymatics Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions _includes/content-blocks/domain-availability-form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<form class="usa-search usa-search--domain-choosing" role="search">
<div class="grid-row">
<div class="grid-col grid-col__input-grid">
<label class="usa-sr-only" for="domain-input-choosing">Search</label>
<input
id="domain-input-choosing"
class="usa-input"
type="search"
aria-label="Check Domain Name input"
title="Check Domain input"
/>
<span class="padding-left-05">.gov</span>
</div>
</div>
<div id="grid-row--domain_message-choosing" class="grid-row margin-top-2 display-none">
<div class="grid-col">
<div class="usa-search--domain_message-choosing" id="usa-search--domain_message"></div>
</div>
</div>
<div class="grid-row margin-top-2">
<div class="grid-col">
<button
class="usa-button"
type="submit"
onclick="checkDomainAvailability('domain-input-choosing', true)"
onsubmit="return false"
aria-label="Check availability of Domain Name"
title="Check Domain Availability"
>
Check availability
</button>
</div>
</div>
</form>
2 changes: 1 addition & 1 deletion _includes/content-blocks/general_domain_requirements.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Your domain name must:

- Be available [(Check availability)](../../#domain-input)
- Be available
- Relate to your organization’s name, location, and/or services
- Be clear to the general public. Your domain name must not be easily confused with other organizations.

Expand Down
59 changes: 0 additions & 59 deletions _includes/domain-search.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,6 @@
is available as a .gov domain.
{% endcomment %}

<script>
function checkDomainAvailability() {
// Cancel the default action
event.preventDefault();

const baseUrl = "https://manage.get.gov/api/v1/available/?domain="

var requested_domain = document.getElementById('domain-input').value

if (requested_domain === null || requested_domain.length === 0) {
render_result(``)
}

var searchEndpoint = new URL("", baseUrl + requested_domain);

fetch(searchEndpoint).then(function(reply) {
return reply.json()
}).then(function(response) {
var requested_domain_display_string = requested_domain
if (!requested_domain_display_string.endsWith('.gov')) {
requested_domain_display_string += '.gov'
}
if (response.available) {
render_result(`
<div class="usa-alert usa-alert--success usa-alert--slim" role="alert">
<div class="usa-alert__body">
<p class="usa-alert__text">
That domain is available!
<a class="usa-link" href="{{ '/domains/before/' | url }}">
Read about next steps to take before requesting your .gov domain.
</a>
</p>
</div>
</div>
`
)
} else {
render_result(`
<div class="usa-alert usa-alert--error usa-alert--slim" role="alert">
<div class="usa-alert__body">
<p class="usa-alert__text">
${response.message}
</p>
</div>
</div>
`
)
}
}).catch(function(err) {
console.log('parsing failed', err);
})
}

function render_result(content, append = true){
document.getElementById('usa-search--domain_message').innerHTML = (append == true) ? content : `<div></div>`;
}

</script>

<section class="usa-section domain-section padding-bottom-5 bg-accent-cool-lighter">
<div class="grid-container">
<div class="domain-section__image">
Expand Down
22 changes: 11 additions & 11 deletions _includes/layouts/info-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
{% endcomment %}

<div class="usa-layout-docs" >
<div class="grid-container margin-top-5">
<div class="grid-row grid-gap">
{% if sidenav == true %}
{% assign collection = collections[tags] %}
{% include "sidenav.html" with collection %}
{% endif %}
<main id="main-content"class="usa-layout-docs__main desktop:grid-col-9 usa-prose margin-top-neg-1">
<h1>{{- title -}} </h1>
{{ content }}
</main>
<div class="grid-container margin-top-5">
<div class="grid-row grid-gap">
{% if sidenav == true %}
{% assign collection = collections[tags] %}
{% include "sidenav.html" with collection %}
{% endif %}
<main id="main-content"class="usa-layout-docs__main desktop:grid-col-9 usa-prose margin-top-neg-1">
<h1>{{- title -}} </h1>
{{ content }}
</main>
</div>
</div>
</div>
</div>
108 changes: 108 additions & 0 deletions _includes/meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,114 @@
gtag('js', new Date());

gtag('config', '{{ site.ga.gtag }}');
function checkDomainAvailability(requestedDomainId="domain-input", isDomainChoosing=false, alertId="usa-search--domain_message") {

// Cancel the default action
event.preventDefault();

const baseUrl = "https://manage.get.gov/api/v1/available/?domain="

let requested_domain = document.getElementById(requestedDomainId).value

if (requested_domain === null || requested_domain.length === 0) {
render_result(``)
}

let searchEndpoint = new URL("", baseUrl + requested_domain);
fetch(searchEndpoint).then(function(reply) {
return reply.json()
}).then(function(response) {
let requested_domain_display_string = requested_domain
if (!requested_domain_display_string.endsWith('.gov')) {
requested_domain_display_string += '.gov'
}

let successMessage = `
<div class="usa-alert usa-alert--success usa-alert--slim" role="alert">
<div class="usa-alert__body">
<p class="usa-alert__text">
That domain is available!
<a class="usa-link" href="{{ '/domains/before/' | url }}">
Read about next steps to take before requesting your .gov domain.
</a>
</p>
</div>
</div>
`

let errorMessage = null
if (isDomainChoosing) {
errorMessage = document.getElementById("grid-row--domain_message-choosing");
if (errorMessage) {
// Check if the 'display-none' class is not already present
if (!errorMessage.classList.contains("display-none")) {
errorMessage.classList.add("display-none");
}
}

successMessage = `
<div class="usa-alert usa-alert--success usa-alert--slim" role="alert">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zandercymatics I can't believe I'm just now noticing this, but the success and error alerts on this page and on the home page check availability don't use our .gov custom color alerts. Can we make these alerts match the ones on the registrar?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

<div class="usa-alert__body">
<p class="usa-alert__text">
That domain is available!
<div class="display-inline"></div>
<strong>We’ll try to give you the domain you want, but it’s not guaranteed.</strong>
<a class="usa-link" href="{{ '/domains/before/' | url }}">
Read about next steps to take before requesting your .gov domain.
</a>
</p>
</div>
</div>
`
}

let failMessage = `
<div class="usa-alert usa-alert--error usa-alert--slim" role="alert">
<div class="usa-alert__body">
<p class="usa-alert__text">
${response.message}
</p>
</div>
</div>
`

if (response.available) {
render_result(alertId, successMessage)
} else if (isDomainChoosing && response.message.includes("That domain isn’t available.")){
let unavailableMessage = `
<div class="usa-alert usa-alert--error usa-alert--slim" role="alert">
<div class="usa-alert__body">
<p class="usa-alert__text">
That domain isn’t available.
</p>
</div>
</div>
`
render_result(alertId, unavailableMessage)
/* TODO: Ticket #267
<a class="usa-link" href="{{ '/domains/whois/' | url }}?domain=${requested_domain_display_string}">
Learn about this domain.
</a>
*/
}
else {
render_result(alertId, failMessage)
}

if (isDomainChoosing && errorMessage) {
errorMessage.classList.remove("display-none");
}
}).catch(function(err) {
console.log('parsing failed', err);
})
}

function render_result(elementId, content, append = true){
document.getElementById(elementId).innerHTML = (append == true) ? content : `<div></div>`;
}

</script>


{% endif %}
</head>
5 changes: 4 additions & 1 deletion pages/domains/domains_choosing.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Choosing your .gov domain name
permalink: /domains/choosing/
layout: layouts/info-page
sidenav: true
excerpt: Requirements and tips for .gov domain names
excerpt: Check if a domain is available and read name requirements for your organization
tags: domains
eleventyNavigation:
key: domains
Expand All @@ -12,6 +12,9 @@ eleventyNavigation:
---


## Start your .gov domain search
Check if the .gov domain you want is available. We’ll work with you to find the best domain for your organization that meets our requirements.
{% include 'content-blocks/domain-availability-form.html' %}

## General rules for .gov domain names
Your domain name represents your organization and your services to the world online. Good domain names are memorable and easy to say out loud (like over the phone or in a presentation).
Expand Down
60 changes: 60 additions & 0 deletions styles/_uswds-theme-custom-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,42 @@ HOME
}
}

// ## DOMAIN SEARCH (domains_choosing page) ---------------------------------------
zandercymatics marked this conversation as resolved.
Show resolved Hide resolved
.usa-search--domain-choosing {
flex-direction: column;
// The default input styling has no styling on the right.
// Lets correct that.
input.usa-input {
border-right-style: solid;
border-right-width: 0.8px;
border-right-color: rgb(86, 92, 101);
max-width: 400px;
height: 36px;
font-size: inherit;
}

span {
line-height: 2;
}

button.usa-button {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
height: 36px;
}

@media (max-width: 500px) {
input.usa-input {
width: 90%;
}

button.usa-button {
width: 100%;
}
}

}

// ## DOMAIN SEARCH ---------------------------------------
.usa-search--domain {
flex-direction: column;
Expand Down Expand Up @@ -322,6 +358,25 @@ HOME
line-height: 1.59rem;
}

.usa-search--domain_message-choosing {
max-width: 400px;

.usa-alert--success.usa-alert--slim::before {
height: 3.5rem;
}

.usa-alert--error.usa-alert--slim::before {
height: 3.5rem;
}

p:last-of-type {
margin-bottom: 0.5rem;
}

}



.usa-search--domain_message {
@include at-media(mobile-lg) {
max-width: 50%;
Expand Down Expand Up @@ -470,3 +525,8 @@ CHECKLIST
padding-left: units(3);
}
}

// This style gets overriden by other class overrides. We can fix this here.
.display-none {
display: none !important;
}
18 changes: 18 additions & 0 deletions styles/_uswds-theme-settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,23 @@ USWDS Settings and Overrides
$theme-summary-box-background-color: 'primary-lightest',
$theme-summary-box-border-color: 'accent-cool-light',

/*---------------------------
## Error state
----------------------------*/
$theme-color-error-darker: $dhs-red-70,
$theme-color-error-dark: $dhs-red-60,
$theme-color-error: $dhs-red,
$theme-color-error-light: $dhs-red-30,
$theme-color-error-lighter: $dhs-red-15,

/*---------------------------
## Success state
----------------------------*/
$theme-color-success-darker: $dhs-green-70,
$theme-color-success-dark: $dhs-green-60,
$theme-color-success: $dhs-green,
$theme-color-success-light: $dhs-green-30,
$theme-color-success-lighter: $dhs-green-15,

);

Loading