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 12 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
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
89 changes: 78 additions & 11 deletions _includes/layouts/info-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,84 @@
This template is for longer information pages
{% endcomment %}


{% comment %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Blocking: If we have to duplicate this code, you should put comments on both sides in all caps so that we do not update this in one place and miss it in the other. I'm particularly thinking about that comment on Ticket #267.

But first, see next comment on trying things to avoid this particular code duplication.

Copy link
Contributor Author

@zandercymatics zandercymatics Apr 17, 2024

Choose a reason for hiding this comment

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

Figured out how to do this without CSRF issues by moving it to the meta file. This comes with the added benefit of centralizing all our scripts moving forward.
I tried directly embedding the script in app.js, then a custom script called get-gov-home.js but:

  1. app.js is imported at the bottom of the file (so custom content doesn't work)
  2. Using a custom script falls prey to the CSRF issue, even when defined in the build

I suggest resolving that issue in another ticket, it is purely a config thing

Insert custom scripts for all info-pages here
{% 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!
<br>
<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>
`
)
} 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}
<a class="usa-link" href="www.whois.com/whois/${requested_domain_display_string}">
Learn about this domain.
</a>
</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>`;
Fixed Show fixed Hide fixed
}
</script>

<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>
40 changes: 39 additions & 1 deletion pages/domains/domains_choosing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,45 @@ eleventyNavigation:
title: Choosing your .gov domain name
---


## 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.
<form class="usa-search usa-search--domain-choosing" role="search">
zandercymatics marked this conversation as resolved.
Show resolved Hide resolved

<div class="grid-row">
<div class="grid-col grid-col__input-grid">
<label class="usa-sr-only" for="domain-input">Search</label>
<input
id="domain-input"
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 class="grid-row margin-top-2">
<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()"
onsubmit="return false"
aria-label="Check availability of Domain Name"
title="Check Domain Availability"
>
Check availability
</button>
</div>
</div>
</form>

## 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
44 changes: 44 additions & 0 deletions styles/_uswds-theme-custom-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,40 @@ 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;
}

// todo: fix
/*
@include at-media(mobile-lg) {
input.usa-input {
max-width: 250px;
}
}
*/
}

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

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

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



.usa-search--domain_message {
@include at-media(mobile-lg) {
max-width: 50%;
Expand Down
Loading