'use client'; //=========================================== // THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template //=========================================== import { BrandIcons, Button, SimpleTooltip } from '@hexclave/ui'; import Color, { ColorInstance } from 'color'; import type { ReactElement } from 'react'; import { useEffect, useId, useState } from 'react'; import { useStackApp } from '../lib/hooks'; import { useTranslation } from '../lib/translations'; import { useInIframe } from './use-in-iframe'; const iconSize = 22; const changeColor = (c: ColorInstance, value: number) => { if (c.isLight()) { value = -value; } return c.hsl(c.hue(), c.saturationl(), c.lightness() + value).toString(); }; export function OAuthButton({ provider, type, isMock = false, onAuthenticate, }: { provider: string, type: 'sign-in' | 'sign-up', isMock?: boolean, onAuthenticate?: () => Promise, }) { const { t } = useTranslation(); const hexclaveApp = useStackApp(); const styleId = useId().replaceAll(':', '-'); const isIframe = useInIframe(); const [lastUsed, setLastUsed] = useState(null); useEffect(() => { // Hexclave rebrand: UI hint key — straight rename (dot delimiter preserved). setLastUsed(localStorage.getItem('_HEXCLAVE.lastUsed')); }, []); let style : { backgroundColor?: string, textColor?: string, name: string, icon: ReactElement | null, border?: string, }; switch (provider) { case 'google': { style = { backgroundColor: '#fff', textColor: '#000', name: 'Google', border: '1px solid #ddd', icon: , }; break; } case 'github': { style = { backgroundColor: '#111', textColor: '#fff', border: '1px solid #333', name: 'GitHub', icon: , }; break; } case 'facebook': { style = { backgroundColor: '#1877F2', textColor: '#fff', name: 'Facebook', icon: , }; break; } case 'microsoft': { style = { backgroundColor: '#2f2f2f', textColor: '#fff', name: 'Microsoft', icon: , }; break; } case 'spotify': { style = { backgroundColor: '#1DB954', textColor: '#fff', name: 'Spotify', icon: , }; break; } case 'discord': { style = { backgroundColor: '#5865F2', textColor: '#fff', name: 'Discord', icon: , }; break; } case 'gitlab': { style = { backgroundColor: "#111", textColor: "#fff", border: "1px solid #333", name: "Gitlab", icon: , }; break; } case 'apple': { style = { backgroundColor: "#000", textColor: "#fff", border: "1px solid #333", name: "Apple", icon: , }; break; } case "bitbucket": { style = { backgroundColor: "#fff", textColor: "#000", border: "1px solid #ddd", name: "Bitbucket", icon: , }; break; } case 'linkedin': { style = { backgroundColor: "#0073b1", textColor: "#fff", name: "LinkedIn", icon: , }; break; } case 'x': { style = { backgroundColor: "#000", textColor: "#fff", name: "X", icon: , }; break; } case 'twitch': { style = { backgroundColor: "#6441a5", textColor: "#fff", name: "Twitch", icon: , }; break; } default: { style = { name: provider, icon: null, }; } } const styleSheet = ` .stack-oauth-button-${styleId} { background-color: ${style.backgroundColor} !important; color: ${style.textColor} !important; border: ${style.border} !important; } .stack-oauth-button-${styleId}:hover { background-color: ${changeColor(Color(style.backgroundColor), 10)} !important; } `; return ( <> ); }