Skip to content

Commit

Permalink
chore: remove custom logic used for Google
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Oct 31, 2024
1 parent 5ecadcc commit 57fc986
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
13 changes: 9 additions & 4 deletions js/src/forum/extenders/extendLoginSignup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import { openOAuthPopup } from '../utils/popupUtils';
import type Mithril from 'mithril';
import type ItemList from 'flarum/common/utils/ItemList';

export type OAuthProvider = {
name: string;
icon: string;
priority: number;
} | null;

export default function () {
extend(LogInButton, 'initAttrs', function (_returnedValue, attrs) {
attrs.onclick = function () {
Expand All @@ -21,14 +27,13 @@ export default function () {

extend(LogInButtons.prototype, 'items', function (items: ItemList<Mithril.Children>) {
const onlyIcons = !!app.forum.attribute('fof-oauth.only_icons');
const buttons = app.forum.attribute('fof-oauth').filter(Boolean);
const googleButton = buttons.splice(buttons.indexOf(buttons.find((b) => b.name === 'google')), 1);
const enabledOAuthProviders = app.forum.attribute<OAuthProvider[]>('fof-oauth').filter(Boolean);

buttons.concat(googleButton).forEach(({ name, icon, priority }) => {
enabledOAuthProviders.forEach(({ name, icon, priority }) => {
let className = `Button FoFLogInButton LogInButton--${name}`;

// Google branding does not allow inline icon, so we'll keep the full button
if (onlyIcons && name !== 'google') {
if (onlyIcons) {
className += ' Button--icon';
}

Expand Down
18 changes: 4 additions & 14 deletions resources/less/forum.less
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,19 @@
.Button--color(#fff, #2867b2);
}

// Custom CSS that meets the bare minimum of https://developers.google.com/identity/branding-guidelines
&.LogInButton--google {
.Button--color(#757575, #fff);

.Button-icon {
&::before {
content: "";
display: inline-block;
width: 18px; // Same size as other icons, which happen to match Google minimums
height: 18px;
width: 30px;
height: 30px;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAMAAABHPGVmAAAABGdBTUEAALGPC/xhBQ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P4I+6Xh9WDWXwR5dM1KVLz3SlejH98ITu/rMSKWMOoTLHWYUkS104x2Qc8fX1JPkP/4UWKEIpNclX1bASSirMlYSKYVcyCoScNQpO0YhkgoxkcVgfVIrnbKxai3T4mXcjhY0t6p+fRQVpZyGwfmC7tb+fB2s2hrG96z12F3Q3do9Bv34c8woVK4TNnshz5RZ9RHl45SBKQHH6aVMtFUnbnR/d2rVNnxmSm9EvdEfnraIDExhdGxGm8yj28OLLJMMKVSP5cudx5dFcyEAeAVN08Z+sb036k7sVM+4HVEpZlhbDAzSovh6Jd8gZsevDVUqpUgDKgZak/UbyZTBSaf1p3RIoaYhsf37wWT/2V7pzc6Q/QYTeYF9/Llsy0ur5b8R1u6Z6gzbcKZeaFk2lmWF3iQ6ff1bg1lre72iWapqRpFpkj/PF7VFKvWnRUtV4z8PZBtLJI9CCoQlfCZtKd05vbOC9pRN/PO6XSSJUsvAQ6I95et13rBTYfv0GfYDtFqe5Ihp09kTtQUjZbxKwVA4GNVjvUhBYcuigOca1ffMS5ax737uZKYB/1/eYTDlwOC9JvYvRewYYcSmaTyG3jQnQct/jLLD8x14RJiGNpAgO/BS0jJUzdQL8eaX9U0LxKBJhYS38NQLLEaX/gIGHNymY/90kQAAAABJRU5ErkJggg==");
background-position: center;
background-repeat: no-repeat;
background-size: 18px 18px;
background-size: 30px;
margin-bottom: -2px; // -2 px is so the button still has the same height as the other ones
}
}
Expand All @@ -74,7 +73,7 @@
flex-flow: row wrap;
margin-bottom: 10px;

.FoFLogInButton:not(.LogInButton--google) {
.FoFLogInButton {
width: 50px;
height: 50px;
padding: 0;
Expand All @@ -90,15 +89,6 @@
height: 50px;
margin-bottom: 0;
}

.LogInButtonContainer--google {
flex-basis: 100%;

.FoFLogInButton {
width: min-content;
margin: 0 auto;
}
}
}

.SettingsPage {
Expand Down

0 comments on commit 57fc986

Please sign in to comment.