Skip to content

Modular logistics and supply chain operating system (LSOS)

feat(oauth): brand the sign-in buttons per provider

Ronald A. Richardson91aab64e6061
diff --git a/console/app/components/account/connected-accounts.hbs b/console/app/components/account/connected-accounts.hbs
index a556c2f1..9d00cfa1 100644
--- a/console/app/components/account/connected-accounts.hbs
+++ b/console/app/components/account/connected-accounts.hbs
@@ -8,9 +8,9 @@
{{#each this.identities as |identity|}}
<div class="flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 px-3 py-2">
<div class="flex items-center">
- {{#if identity.icon}}
- <FaIcon @icon={{identity.icon}} @prefix="fab" class="mr-3 text-gray-600 dark:text-gray-300" />
- {{/if}}
+ <span class="mr-3 inline-flex text-gray-700 dark:text-gray-200">
+ <Auth::OauthProviderLogo @provider={{identity.provider}} @icon={{identity.icon}} />
+ </span>
<div>
<div class="text-sm font-semibold text-gray-900 dark:text-white">{{identity.label}}</div>
{{#if identity.provider_email}}
@@ -41,7 +41,9 @@
{{#each this.available as |provider|}}
<div class="flex items-center justify-between rounded-md border border-dashed border-gray-300 dark:border-gray-700 px-3 py-2">
<div class="flex items-center">
- <FaIcon @icon={{provider.icon}} @prefix="fab" class="mr-3 text-gray-400" />
+ <span class="mr-3 inline-flex text-gray-700 dark:text-gray-200">
+ <Auth::OauthProviderLogo @provider={{provider.id}} @icon={{provider.icon}} />
+ </span>
<div class="text-sm text-gray-700 dark:text-gray-300">{{provider.label}}</div>
</div>
<Button @size="xs" @icon="link" @text={{t "auth.login.oauth.link-button"}} @isLoading={{this.link.isRunning}} @onClick={{perform this.link provider}} />
diff --git a/console/app/components/auth/oauth-provider-logo.hbs b/console/app/components/auth/oauth-provider-logo.hbs
new file mode 100644
index 00000000..63ff8bfb
--- /dev/null
+++ b/console/app/components/auth/oauth-provider-logo.hbs
@@ -0,0 +1,27 @@
+{{!-- A provider's own logo, as its brand guidelines require it to be shown.
+ Google and Microsoft must be full colour (a single-colour Google "G" is not
+ allowed), so they are inline SVG. Apple and GitHub are single colour by design
+ and follow the button's text colour. Any other provider falls back to its icon. --}}
+{{#if (eq @provider "google")}}
+ <span class="oauth-provider-logo oauth-provider-logo-google" aria-hidden="true">
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="18" height="18">
+ <path fill="#EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z" />
+ <path fill="#4285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z" />
+ <path fill="#FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z" />
+ <path fill="#34A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z" />
+ </svg>
+ </span>
+{{else if (eq @provider "microsoft")}}
+ <span class="oauth-provider-logo oauth-provider-logo-microsoft" aria-hidden="true">
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21 21" width="18" height="18">
+ <rect x="1" y="1" width="9" height="9" fill="#F25022" />
+ <rect x="11" y="1" width="9" height="9" fill="#7FBA00" />
+ <rect x="1" y="11" width="9" height="9" fill="#00A4EF" />
+ <rect x="11" y="11" width="9" height="9" fill="#FFB900" />
+ </svg>
+ </span>
+{{else if @icon}}
+ <span class="oauth-provider-logo oauth-provider-logo-{{@provider}}" aria-hidden="true">
+ <FaIcon @icon={{@icon}} @prefix="fab" />
+ </span>
+{{/if}}
diff --git a/console/app/styles/console.css b/console/app/styles/console.css
index 8b6c0672..2e9cb599 100644
--- a/console/app/styles/console.css
+++ b/console/app/styles/console.css
@@ -243,3 +243,100 @@ body[data-theme='dark'] .console-dashboard-title h1 {
padding: 1rem;
}
}
+
+
+/*
+ * Sign-in provider buttons, branded as each provider's guidelines ask, on Fleetbase's
+ * own button shape, size and shadow (the .btn-wrapper is left alone).
+ *
+ * Google developers.google.com/identity/branding-guidelines
+ * light #FFFFFF / stroke #747775 / text #1F1F1F
+ * dark #131314 / stroke #8E918F / text #E3E3E3
+ * The full-colour "G" must sit on white, so on dark it gets a white disc.
+ * Microsoft learn.microsoft.com/entra/identity-platform/howto-add-branding-in-apps
+ * light #FFFFFF / stroke #8C8C8C / text #5E5E5E; dark #2F2F2F / text #FFFFFF
+ * Apple Human Interface Guidelines: black on light backgrounds, white on dark.
+ * GitHub The mark is only ever black or white: same treatment as Apple.
+ *
+ * Only these providers are listed, so one added later keeps the default button.
+ * `body` in each selector outranks ember-ui's `body[data-theme='dark'] .btn.btn-default`.
+ */
+.oauth-provider-google {
+ --oauth-bg: #ffffff;
+ --oauth-bg-hover: #f8f9fa;
+ --oauth-border: #747775;
+ --oauth-text: #1f1f1f;
+}
+.oauth-provider-microsoft {
+ --oauth-bg: #ffffff;
+ --oauth-bg-hover: #f3f3f3;
+ --oauth-border: #8c8c8c;
+ --oauth-text: #5e5e5e;
+}
+.oauth-provider-apple,
+.oauth-provider-github {
+ --oauth-bg: #000000;
+ --oauth-bg-hover: #1f1f1f;
+ --oauth-border: #000000;
+ --oauth-text: #ffffff;
+}
+.oauth-provider-github {
+ --oauth-bg: #24292f;
+ --oauth-bg-hover: #32383f;
+ --oauth-border: #24292f;
+}
+body[data-theme='dark'] .oauth-provider-google {
+ --oauth-bg: #131314;
+ --oauth-bg-hover: #1f1f20;
+ --oauth-border: #8e918f;
+ --oauth-text: #e3e3e3;
+}
+body[data-theme='dark'] .oauth-provider-microsoft {
+ --oauth-bg: #2f2f2f;
+ --oauth-bg-hover: #3a3a3a;
+ --oauth-border: #2f2f2f;
+ --oauth-text: #ffffff;
+}
+body[data-theme='dark'] .oauth-provider-apple,
+body[data-theme='dark'] .oauth-provider-github {
+ --oauth-bg: #ffffff;
+ --oauth-bg-hover: #f2f2f2;
+ --oauth-border: #ffffff;
+ --oauth-text: #000000;
+}
+
+body :is(.oauth-provider-google, .oauth-provider-microsoft, .oauth-provider-apple, .oauth-provider-github) > button.btn.btn-default {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 0.625rem;
+ background-color: var(--oauth-bg);
+ border: 1px solid var(--oauth-border);
+ color: var(--oauth-text);
+}
+
+body :is(.oauth-provider-google, .oauth-provider-microsoft, .oauth-provider-apple, .oauth-provider-github) > button.btn.btn-default:hover:not(:disabled),
+body :is(.oauth-provider-google, .oauth-provider-microsoft, .oauth-provider-apple, .oauth-provider-github) > button.btn.btn-default:focus {
+ background-color: var(--oauth-bg-hover);
+ border-color: var(--oauth-border);
+ color: var(--oauth-text);
+}
+
+.oauth-provider-logo {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ line-height: 1;
+}
+
+.oauth-provider-logo svg.svg-inline--fa {
+ width: 18px;
+ height: 18px;
+}
+
+body[data-theme='dark'] .oauth-provider-google .oauth-provider-logo-google {
+ background-color: #ffffff;
+ border-radius: 9999px;
+ padding: 2px;
+}
diff --git a/console/app/templates/auth/login.hbs b/console/app/templates/auth/login.hbs
index 741fcb7f..ce422be3 100644
--- a/console/app/templates/auth/login.hbs
+++ b/console/app/templates/auth/login.hbs
@@ -101,15 +101,18 @@
<div class="flex-grow border-t border-gray-300 dark:border-gray-700"></div>
</div>
+ {{!-- Branded per provider (see .oauth-provider-button in console.css): each
+ provider's colours and logo, on Fleetbase's own button shape and shadow. --}}
{{#each this.oauth.providers as |provider|}}
<Button
- @text={{t "auth.login.oauth.continue-with" provider=provider.label}}
- @icon={{provider.icon}}
- @iconPrefix="fab"
- @wrapperClass="btn-block"
+ @wrapperClass="btn-block oauth-provider-button oauth-provider-{{provider.id}}"
@disabled={{this.isLoading}}
@onClick={{fn this.continueWithProvider provider}}
- />
+ data-test-oauth-provider={{provider.id}}
+ >
+ <Auth::OauthProviderLogo @provider={{provider.id}} @icon={{provider.icon}} />
+ <span>{{t "auth.login.oauth.continue-with" provider=provider.label}}</span>
+ </Button>
{{/each}}
{{/if}}
<RegistryYield @type="menu" @registry="auth:login" as |menuItem|>
diff --git a/console/tests/integration/components/auth/oauth-provider-logo-test.js b/console/tests/integration/components/auth/oauth-provider-logo-test.js
new file mode 100644
index 00000000..6cff6c7e
--- /dev/null
+++ b/console/tests/integration/components/auth/oauth-provider-logo-test.js
@@ -0,0 +1,37 @@
+import { module, test } from 'qunit';
+import { setupRenderingTest } from '@fleetbase/console/tests/helpers';
+import { render } from '@ember/test-helpers';
+import { hbs } from 'ember-cli-htmlbars';
+
+module('Integration | Component | auth/oauth-provider-logo', function (hooks) {
+ setupRenderingTest(hooks);
+
+ test('google gets its full-colour G, never a single-colour icon', async function (assert) {
+ await render(hbs`<Auth::OauthProviderLogo @provider="google" @icon="google" />`);
+
+ const fills = [...this.element.querySelectorAll('path')].map((path) => path.getAttribute('fill'));
+
+ assert.deepEqual(fills, ['#EA4335', '#4285F4', '#FBBC05', '#34A853']);
+ assert.dom('.svg-inline--fa').doesNotExist();
+ });
+
+ test('microsoft gets its four-colour logo', async function (assert) {
+ await render(hbs`<Auth::OauthProviderLogo @provider="microsoft" @icon="microsoft" />`);
+
+ const fills = [...this.element.querySelectorAll('rect')].map((rect) => rect.getAttribute('fill'));
+
+ assert.deepEqual(fills, ['#F25022', '#7FBA00', '#00A4EF', '#FFB900']);
+ });
+
+ test('apple, github and any later provider use their brand icon', async function (assert) {
+ await render(hbs`<Auth::OauthProviderLogo @provider="github" @icon="github" />`);
+
+ assert.dom('.oauth-provider-logo-github .svg-inline--fa').exists();
+ });
+
+ test('it is hidden from screen readers; the button text names the provider', async function (assert) {
+ await render(hbs`<Auth::OauthProviderLogo @provider="google" />`);
+
+ assert.dom('.oauth-provider-logo').hasAttribute('aria-hidden', 'true');
+ });
+});