Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
e568af2
Add table of SMS/Voice support dynamically loaded from IDP
zachmargolis Oct 19, 2021
fd8f7ea
fix indentation
zachmargolis Oct 19, 2021
430c712
Update table markup
zachmargolis Oct 19, 2021
6eb954c
table style updates
zachmargolis Oct 19, 2021
54a812d
Handle translation via partials, data- attributes
zachmargolis Oct 20, 2021
af97694
Update _includes/sign_in.html
zachmargolis Oct 20, 2021
b3d947c
Update _includes/country_support_table.html
zachmargolis Oct 20, 2021
96c25c8
Move early abort
zachmargolis Oct 20, 2021
d7571a2
Try adding a sticky table, hiding emoji from screen readers
zachmargolis Oct 20, 2021
432b8c7
Add placeholder translations
zachmargolis Oct 20, 2021
bd26f85
Use String#localeCompare
zachmargolis Oct 20, 2021
b6b456d
Update assets/js/country_support.js
zachmargolis Oct 20, 2021
31c4cf7
Quick translation approximations
zachmargolis Oct 21, 2021
e9df0dd
wip
zachmargolis Oct 21, 2021
04371ae
Remove emojis, use font-awesome icons
zachmargolis Oct 21, 2021
c882cb4
Merge remote-tracking branch 'origin/main' into margolis-country-support
zachmargolis Oct 21, 2021
f13af97
Try adding a spec
zachmargolis Oct 21, 2021
06e5b07
Add newlines to files
zachmargolis Oct 21, 2021
8e85293
try fixing spec file
zachmargolis Oct 21, 2021
a499537
remove extra JSDoc
zachmargolis Oct 21, 2021
f070897
Put icon first so that there aren't any rivers
zachmargolis Oct 21, 2021
5bcec6e
margin-right-05 after icons
zachmargolis Oct 21, 2021
4e5bf14
Update spec/e2e/country_suport_spec.js
zachmargolis Oct 22, 2021
f43ef83
Update spec/e2e/country_suport_spec.js
zachmargolis Oct 22, 2021
e0a24df
Update spec/e2e/country_suport_spec.js
zachmargolis Oct 22, 2021
3835aa1
Update spec/e2e/country_suport_spec.js
zachmargolis Oct 22, 2021
af6dea4
Rename file
zachmargolis Oct 22, 2021
cb1ef76
Update content/_fr/help/manage-your-account/international-phone-suppo…
zachmargolis Oct 22, 2021
d6c3058
fix JSDoc
zachmargolis Oct 22, 2021
384236d
Fix multiple spec file runs in Jest + Puppeteer
aduth Oct 22, 2021
c5b0035
double dollar
zachmargolis Oct 22, 2021
35ce65b
Add wrapper <div>, stop using <caption> for hidden content
zachmargolis Oct 22, 2021
2593584
trailing space
zachmargolis Oct 22, 2021
4285c71
Convert more globals to process.env
aduth Oct 22, 2021
7005704
attempt to fix type annotations
zachmargolis Oct 22, 2021
2f0fb5d
Trailing spaces
zachmargolis Oct 22, 2021
88c9df0
Add in ISO country code and dialing code
zachmargolis Oct 22, 2021
06baa4b
Dialing code goes in its own column
zachmargolis Oct 22, 2021
f631155
Update spec
zachmargolis Oct 22, 2021
82d11e9
Pretty format the dialing code
zachmargolis Oct 22, 2021
5a7d4b0
Merge pull request #709 from 18F/margolis-add-dialing-code
zachmargolis Oct 22, 2021
72fba67
Update _includes/country_support_table.html
zachmargolis Oct 22, 2021
45212e9
fix camelCase
zachmargolis Oct 22, 2021
bd799b9
eslint --fix
zachmargolis Oct 22, 2021
0b272c8
Rotate some variable names
zachmargolis Oct 22, 2021
da23b25
Juggle some more variable names
zachmargolis Oct 22, 2021
71a36b0
Fix table selector for country spec
aduth Oct 26, 2021
ac472fe
Rename "accessibility" job to "e2e"
aduth Oct 26, 2021
bebb949
Fix CircleCI missing build name
aduth Oct 26, 2021
4f179bf
Empty commit to kick off a rebuild with new federalist config
zachmargolis Oct 28, 2021
5afc5bc
Update assets/js/country_support.js
zachmargolis Oct 28, 2021
2d2c160
Update _sass/components/_svg.scss
zachmargolis Oct 28, 2021
0b41650
simplify selector with color
zachmargolis Oct 28, 2021
b68f93b
reorder pages
zachmargolis Oct 28, 2021
66d6022
use color tokens
zachmargolis Oct 28, 2021
f564b71
WIP: fetch polyfill
zachmargolis Oct 28, 2021
91d5833
Add pretty import name
zachmargolis Oct 28, 2021
105b01b
Add useBuiltins
zachmargolis Oct 28, 2021
5ebf732
corejs too
zachmargolis Oct 28, 2021
ad842e5
javascript transpiler shenanigans
zachmargolis Oct 28, 2021
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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
name: Run htmlproofer (no external links)
command: bundle exec scripts/htmlproofer --internal

accessibility:
e2e:
docker:
- image: cimg/ruby:2.7-browsers
environment:
Expand Down Expand Up @@ -148,7 +148,7 @@ workflows:
- test-external-links:
requires:
- build
- accessibility:
- e2e:
requires:
- build
daily-external-link-checker:
Expand Down
5 changes: 5 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ contact_form_captcha_enabled: true
contact_form_action: "https://webto.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8"
contact_form_orgid: "00DU0000000Leux"

# Used to load country code support
idp_base_url: https://secure.login.gov
# for local development:
# idp_base_url: http://localhost:3000

# Pages
collections_dir: content
collections:
Expand Down
44 changes: 44 additions & 0 deletions _includes/country_support_table.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{% comment %}
Should include these translations as includes:
- heading_country
- heading_dialing_code
- heading_sms
Comment thread
zachmargolis marked this conversation as resolved.
- heading_voice
- option_yes
- option_no
{% endcomment %}

<div
class="js-country-support"
data-idp-base-url="{{ site.idp_base_url }}"
data-translation-option-yes="{{ include.option_yes }}"
data-translation-option-no="{{ include.option_no }}"
hidden
>
<span hidden data-item="icon-success" class="svg-wrapper svg-success">{% include svg/font-awesome-check-circle-solid.svg %}</span>
<span hidden data-item="icon-error" class="svg-wrapper svg-error">{% include svg/font-awesome-times-circle-solid.svg %}</span>
<table class="usa-table--borderless usa-table--sticky-header">
<thead>
<tr>
<th scope="col" class="usa-table--sticky-header--heading">{{ include.heading_country }}</th>
<th scope="col" class="usa-table--sticky-header--heading">{{ include.heading_dialing_code }}</th>
<th scope="col" class="usa-table--sticky-header--heading">{{ include.heading_sms }}</th>
<th scope="col" class="usa-table--sticky-header--heading">{{ include.heading_voice }}</th>
</tr>
</thead>
<tbody>
<tr data-item="template-row">
<td data-item="country"></td>
<td data-item="dialing-code"></td>
<td data-item="sms">
<span class="margin-right-05" data-item="icon" aria-hidden="true"></span>
<span data-item="text"></span>
</td>
<td data-item="voice">
<span class="margin-right-05" data-item="icon" aria-hidden="true"></span>
<span data-item="text"></span>
</td>
</tr>
</tbody>
</table>
</div>
2 changes: 1 addition & 1 deletion _includes/one_account_banner.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% if page.url == '/create-an-account/' %}
{% assign link_class = 'usa-button usa-button--big' %}
{% assign link_url = 'https://secure.login.gov/sign_up/enter_email' %}
{% assign link_url = site.idp_base_url | append: '/sign_up/enter_email' %}
{% capture link_content %}
{{ site.data.[page.lang].settings.banner.one-account-for-govt.create }}
{% endcapture %}
Expand Down
2 changes: 1 addition & 1 deletion _includes/sign_in.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<a
class="{{include.mobile}} usa-button sign-in-logo"
href="https://secure.login.gov/{% if page.lang!= 'en' %}{{page.lang}}{% endif %}"
href="{{ site.idp_base_url }}/{% if page.lang!= 'en' %}{{page.lang}}{% endif %}"
title="Login.gov"
aria-label="Login.gov"
tabindex="0"
Expand Down
1 change: 1 addition & 0 deletions _includes/svg/font-awesome-check-circle-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions _includes/svg/font-awesome-times-circle-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions _sass/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ $blue-mid: color("primary-dark");
$navy: color("primary-darker");

$red: color("secondary");

$error: color("error");
$success: color("success");
10 changes: 10 additions & 0 deletions _sass/components/_sticky-table.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.usa-table--sticky-header {
position: relative;

.usa-table--sticky-header--heading,
thead th.usa-table--sticky-header--heading {
background-color: $white;
position: sticky;
top: 0;
}
}
Comment thread
zachmargolis marked this conversation as resolved.
8 changes: 8 additions & 0 deletions _sass/components/_svg.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@
fill: $grey;
}
}

.svg-success {
color: $success;
}

.svg-error {
color: $error;
}
2 changes: 2 additions & 0 deletions _sass/components/all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
@import "layout";
@import "box-info";
@import "card";

@import "sticky-table";
104 changes: 104 additions & 0 deletions assets/js/country_support.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/**
* @typedef Country
* @property {string} name
* @property {string} country_code The international dialing code (ex "1" for the US)
* @property {boolean} supports_sms
* @property {boolean} supports_voice
*/

/**
* @typedef CountrySupport
* @property {Record<string,Country>} countries
*/

/**
* @example
* prettyDialingCode('1') => '+1'
* prettyDialingCode('1234') => '+1-234'
* prettyDialingCode('789') => '+789'
* @param {string} dialingCode
* @return {string}
*/
const prettyDialingCode = (dialingCode) => {
if (dialingCode.length > 1 && dialingCode.indexOf('1') === 0) {
return `+1-${dialingCode.slice(1)}`;
}
return `+${dialingCode}`;
};

/**
* @typedef {(input: RequestInfo, init?: RequestInit) => Promise<Response>} Fetch
*/

/**
* @param {HTMLElement} elem
* @param {Fetch} fetch
*/
function loadCountrySupportTable(elem, fetch) {
const tbody = elem.querySelector('tbody');
const templateRow = elem.querySelector('[data-item=template-row]');
const successIcon = elem.querySelector('[data-item=icon-success]');
const errorIcon = elem.querySelector('[data-item=icon-error]');
if (!tbody || !templateRow || !successIcon || !errorIcon) {
return;
}

const { idpBaseUrl, translationOptionYes, translationOptionNo } = elem.dataset;

/**
* @param {HTMLElement} cell
* @param {boolean} enabled
*/
const updateCell = (cell, enabled) => {
cell.querySelector('[data-item=text]').innerText = enabled
? translationOptionYes
: translationOptionNo;

const clonedIcon = (enabled ? successIcon : errorIcon).cloneNode(true);
clonedIcon.hidden = false;
cell.querySelector('[data-item=icon]').appendChild(clonedIcon);
};

fetch(`${idpBaseUrl || ''}/api/country-support`)
.then((response) => response.json())
.then((/** @type {CountrySupport} */ { countries }) => {
Object.entries(countries)
.sort(([_isoCodeA, { name: a }], [_isoCodeB, { name: b }]) => a.localeCompare(b))
.forEach(
([
isoCode,
{
name,
country_code: countryCode,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One thing we may consider in the future is to have the API respond with locale-translated country names? For example, Germany is "Allemagne" in French, but currently we show all country names in English.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes definitely! The IDP itself only has English names right now, but that is a great idea. In the meantime we do that the ISO country codes too

Copy link
Copy Markdown
Contributor

@aduth aduth Oct 28, 2021

Choose a reason for hiding this comment

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

Yeah, I bet we're probably showing English names in some of our translated alert texts. Thinking ones like this in particular:

https://github.com/18F/identity-idp/blob/ef4418520046674acb903d13ddb5552d76a36d3d/config/locales/two_factor_authentication/en.yml#L90

I'll plan to confirm and create a ticket as necessary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For posterity: LG-5321

supports_sms: supportsSms,
supports_voice: supportsVoice,
},
]) => {
const row = templateRow.cloneNode(true);

row.querySelector('[data-item=country]').innerText = `${name} (${isoCode})`;
row.querySelector('[data-item=dialing-code]').innerText = prettyDialingCode(
countryCode,
);
updateCell(row.querySelector('[data-item=sms]'), supportsSms);
updateCell(row.querySelector('[data-item=voice]'), supportsVoice);
tbody.appendChild(row);
},
);

tbody.removeChild(templateRow);
elem.hidden = false;
});
}

/** @type {Promise<Fetch>} */
const fetchPromise =
'fetch' in window
? new Promise((resolve) => resolve(window.fetch))
: import(/* webpackChunkName: "whatwg-fetch" */ 'whatwg-fetch').then(({ fetch }) => fetch);

fetchPromise.then((fetch) => {
Array.from(document.querySelectorAll('.js-country-support')).forEach((elem) =>
loadCountrySupportTable(elem, fetch),
);
});
19 changes: 17 additions & 2 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
{
"presets": [["@babel/preset-env", { "targets": { "ie": "11" } }]],
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": 3,
"targets": { "ie": "11" }
}
]
],
"env": {
"test": {
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]]
}
}
},
"overrides": [
{
"test": "node_modules",
"sourceType": "unambiguous"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: help
title: Add or change your authentication method
category: manage-your-account
order: 6
order: 7
---
[An authentication method](https://login.gov/help/get-started/authentication-options/) is an additional layer of security for your account. We recommend having at least two authentication methods for your account in case you lose one method.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
layout: help
title: International phone number support
category: manage-your-account
order: 5
scripts:
- /assets/js/build/country_support.js
---

<noscript>
We need JavaScript in order to load the list of supported countries.
</noscript>

{% include country_support_table.html
heading_country="Country"
heading_dialing_code="Dialing Code"
heading_sms="Supports SMS"
heading_voice="Supports Voice"
option_yes="Yes"
option_no="No" %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: help
title: "Relink your accounts "
category: manage-your-account
order: 5
order: 6
---
If you have problems signing in to a Login.gov partner website after changing your email address, then it is possible the partner linked your account to a different email address. You may want to relink your account to access your information or profile on the partner website. 

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Añadir o cambiar el método de autenticación
category: manage-your-account
order: 6
order: 7
---
[Un método de autenticación](https://login.gov/es/help/get-started/authentication-options/) es una medida adicional de seguridad para tu cuenta. Te aconsejamos que tengas al menos dos métodos de autenticación para tu cuenta en caso de que pierdas uno de ellos.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
layout: help
title: Soporte de número de teléfono internacional
category: manage-your-account
order: 5
scripts:
- /assets/js/build/country_support.js
---

<noscript>
Necesitamos JavaScript para cargar la lista de países admitidos.
</noscript>

{% include country_support_table.html
heading_country="País"
heading_dialing_code="Codigo para marcar"
heading_sms="Compatible con SMS"
heading_voice="Admite marcación por voz"
option_yes="Sí"
option_no="No" %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: help
category: manage-your-account
title: "Revincular tus cuentas"
order: 5
order: 6
---
Si tienes problemas para iniciar sesión en un sitio web asociado a Login.gov después de cambiar tu dirección de correo electrónico, es posible que dicho socio haya vinculado tu cuenta a una dirección de correo electrónico diferente. Puede que desees volver a vincular tu cuenta para acceder a tu información o perfil en el sitio web asociado.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Ajouter ou modifier votre méthode d’authentification "
category: manage-your-account
order: 6
order: 7
---
[Une méthode d’authentification](https://login.gov/fr/help/get-started/authentication-options/) est une couche supplémentaire de sécurité pour votre compte. Nous vous recommandons d’avoir au moins deux méthodes d’authentification pour votre compte au cas où vous en perdriez une. 

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
layout: help
title: Prise en charge des numéros de téléphone internationaux
category: manage-your-account
order: 5
scripts:
- /assets/js/build/country_support.js
---

<noscript>
Nous avons besoin de JavaScript pour charger la liste des pays pris en charge.
</noscript>

{% include country_support_table.html
heading_country="Pays"
heading_dialing_code="Indicatif"
heading_sms="Prend en charge les SMS"
heading_voice="Prend en charge la numérotation vocale"
option_yes="Oui"
option_no="Non" %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: help
category: manage-your-account
title: "Relier tes comptes"
order: 5
order: 6
---
Si tu rencontres des problèmes pour te connecter à un site Web partenaire de Login.gov après avoir changé ton adresse électronique, il se peut que le partenaire ait lié ton compte à une adresse électronique différente. Au cas où tu souhaiterais relier ton compte pour accéder à tes informations ou à ton profil sur le site Web partenaire, sache que c’est possible.

Expand Down
Loading