Skip to content

Commit

Permalink
Update login button appearance and add support for dynamic images (#245)
Browse files Browse the repository at this point in the history
The style changes are temporary and will likely be reverted in the
future. The ability to include images will be kept.
  • Loading branch information
Gcolon021 authored Oct 7, 2024
1 parent bf64cd7 commit 692053e
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 2 deletions.
48 changes: 48 additions & 0 deletions src/lib/assets/login/NIH_2013_logo_vertical_text_removed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/lib/components/LoginButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
resetSearch();
});
};
let imageSrc: string | undefined = undefined;
if (provider.imagesrc) {
imageSrc = './' + provider.imagesrc;
}
</script>

<button
Expand All @@ -23,6 +28,9 @@
class={$$props.class ?? 'btn variant-filled-primary m-1'}
on:click={() => login(redirectTo, provider.type)}
>
{#if imageSrc}
<img src={imageSrc} alt={provider.imageAlt} class="h-8 mr-2" />
{/if}
{buttonText}
</button>

Expand Down
6 changes: 6 additions & 0 deletions src/lib/models/AuthProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export interface AuthData extends Indexable {
helpText?: string;
enabled: boolean;
alt: boolean;
imageSrc?: string;
imageAlt?: string;
}

export default class AuthProvider implements AuthData {
Expand All @@ -21,6 +23,8 @@ export default class AuthProvider implements AuthData {
logouturl?: string | undefined;
callbackurl?: string | undefined;
alt: boolean;
imageSrc?: string | undefined;
imageAlt?: string | undefined;

constructor(data: AuthData) {
this.name = data.name;
Expand All @@ -29,6 +33,8 @@ export default class AuthProvider implements AuthData {
this.icon = data.icon;
this.enabled = data.enabled;
this.alt = data.alt || false;
this.imageSrc = data.imagesrc;
this.imageAlt = data.imagealt;
}

protected getRedirectURI(): string {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(authentication)/login/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
provider={selectedProvider}
{redirectTo}
helpText={selectedProvider.helptext}
class="btn variant-filled-primary m-1 mt-2 w-full"
class="btn variant-outline-primary m-1 mt-2 w-full"
/>
{/if}
{:else}
Expand All @@ -78,7 +78,7 @@
{provider}
{redirectTo}
helpText={provider.helptext}
class="btn variant-filled-primary w-full"
class="btn variant-outline-primary text-primary-500 w-full"
/>
{/each}
{/if}
Expand Down
48 changes: 48 additions & 0 deletions static/NIH_2013_logo_vertical_text_removed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 692053e

Please sign in to comment.