// ~/src/siteplane/components/social-button/social-button.tsx "use client"; import * as React from "react"; import { useSiteplaneMessages } from "../../system/locale/messages-context"; import { Button, type ButtonDefaultProfileProps } from "../button"; import { AppleLogo, DribbbleLogo, FacebookLogo, FigmaLogo, FigmaOutlinedLogo, GoogleLogo, XLogo, } from "./social-logos"; import "./social-button.css"; /** The account providers a SocialButton signs in with. */ export type SocialButtonProvider = "apple" | "dribbble" | "facebook" | "figma" | "google" | "x"; /** * How the provider shows. `brand` fills the button with the provider's colour * and a white logo: blue for Facebook, pink for Dribbble and black for Apple, * X and Figma, whose logo keeps its own colours. Google stays the neutral * button with its colour logo. `color` is the neutral button with the * full-colour logo, Apple and X in the text colour. `gray` is the neutral * button with the logo in the quaternary text colour. */ export type SocialButtonTheme = "brand" | "color" | "gray"; /** * The sizes of the Button that a SocialButton is, the control sizes: sm is * 36 px and md 40 px with a 16 px logo, lg 44 px and xl 48 px with a 20 px * logo. */ export type SocialButtonSize = "sm" | "md" | "lg" | "xl"; const providerNames = { apple: "Apple", dribbble: "Dribbble", facebook: "Facebook", figma: "Figma", google: "Google", x: "X", } as const satisfies Record; export type SocialButtonProps = Omit< ButtonDefaultProfileProps, | "children" | "loading" | "multiline" | "profile" | "profileTone" | "shape" | "size" | "variant" > & { /** The provider, which picks the logo and the brand colour. */ social: SocialButtonProvider; /** How the provider shows; `brand` by default. */ theme?: SocialButtonTheme | undefined; /** * sm (36 px), md (40 px), lg (44 px) or xl (48 px). The control size of the * SiteplaneUIProvider by default, sm unless it sets another, as every * Button's. */ size?: SocialButtonSize | undefined; /** * The label after the logo, such as "Sign in with Google". Without one the * button is the square of its size with the logo alone, named "Sign in with" * and the provider unless `aria-label` names it. */ children?: React.ReactNode; }; // The logo of a provider in a theme. It is decoration: the label or the // button's name says the provider. function logoFor( social: SocialButtonProvider, theme: SocialButtonTheme, ): React.ReactElement { const logo = { "aria-hidden": true, className: "sp-social-button-logo", "data-slot": "social-button-logo", } as const; switch (social) { case "apple": return ; case "dribbble": return ; case "facebook": return ; case "figma": return theme === "gray" ? ( ) : ( ); case "google": return ; case "x": return ; } } /** * A button that signs in with an account provider: the kit Button with the * provider's logo before its label. The neutral look is the default Button, * opaque with the control's rim and shadow, so it reads on the kit's grey page * where an outline Button would show the page through; the brand fill is the solid accent Button in the provider's colour * (social-button.css). Size, focus, hover, press, disabled and cursor are the * Button's: it takes the provider's control size, as high as a Button beside * it (Lukas, 4 November 2026; it was fixed at lg, 44 px). Without children it * is the square of its size with the logo alone. Button props pass through, * such as `disabled`, `width`, `onClick` and `render` for a link to the * application's sign-in route. */ export function SocialButton({ "aria-label": ariaLabel, children, size, social, theme = "brand", ...props }: SocialButtonProps): React.ReactElement { const messages = useSiteplaneMessages("socialButton"); const iconOnly = React.Children.toArray(children).length === 0; const filled = theme === "brand" && social !== "google"; return ( ); } // ~/src/siteplane/components/social-button/social-logos.tsx /* * The path data of these provider logos is adapted from Untitled UI React * (components/base/buttons/social-logos.tsx, https://github.com/untitleduico/react), * which is licensed as follows: * * MIT License * * Copyright (c) 2025 Untitled UI * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import type * as React from "react"; /** The props of a provider logo: an svg on a 24 x 24 grid. */ export type SocialLogoProps = React.SVGProps; /** The props of a logo that also comes in the provider's own colours. */ export type ColorfulSocialLogoProps = SocialLogoProps & { /** The provider's colours; without them the logo takes the text colour. */ colorful?: boolean | undefined; }; export function GoogleLogo({ colorful = false, ...props }: ColorfulSocialLogoProps): React.ReactElement { return ( ); } export function FacebookLogo({ colorful = false, ...props }: ColorfulSocialLogoProps): React.ReactElement { return ( ); } /** The Apple logo is monochrome: it always takes the text colour. */ export function AppleLogo(props: SocialLogoProps): React.ReactElement { return ( ); } /** The X logo is monochrome: it always takes the text colour. */ export function XLogo(props: SocialLogoProps): React.ReactElement { return ( ); } /** * The Figma logo in its five colours. Its shapes touch, so a single colour * would merge them; the monochrome Figma logo is the outlined one below. */ export function FigmaLogo(props: SocialLogoProps): React.ReactElement { return ( ); } /** The outlined Figma logo, monochrome in the text colour. */ export function FigmaOutlinedLogo(props: SocialLogoProps): React.ReactElement { return ( ); } /** * The Dribbble ball. In colour it is the pink ball with its seams; in a single * colour only the seams are drawn, so the fill behind the logo shows through. */ export function DribbbleLogo({ colorful = false, ...props }: ColorfulSocialLogoProps): React.ReactElement { return ( ); } // ~/src/siteplane/components/social-button/social-button.css @layer theme, base, components, siteplane, utilities; @layer siteplane { /* A SocialButton is the kit Button at the control size of its provider, as * high as a Button beside it (Lukas, 4 November 2026; it was fixed at lg): * sm and md are Button sm and md (36 and 40 px, 14/20) with a 16 px logo, * lg and xl are Button lg and xl (44 and 48 px, 16/24) with their 20 px * icon, and each icon-only one is the square of its size. The logo stands * 8 px (sm, md) and 10 px (lg, xl) from the label; the label keeps the * Button's 2 px inset, so the content gap is 2 px less. Height, padding, * text, radius, focus, hover, press, disabled and cursor stay the Button's. * The extra [data-chassis] ranks these rules above the Button's size rules, * so the two sheets can load in any order. */ :root .sp-social-button[data-chassis][data-size="sm"], :root .sp-social-button[data-chassis][data-size="md"], :root .sp-social-button[data-chassis][data-size="icon-sm"], :root .sp-social-button[data-chassis][data-size="icon-md"] { --sp-rw-button-icon: var(--sp-rw-space-4); } :root .sp-social-button[data-chassis][data-size="sm"], :root .sp-social-button[data-chassis][data-size="md"] { --sp-rw-button-content-gap: var(--sp-rw-space-1-5); } :root .sp-social-button[data-chassis][data-size="lg"], :root .sp-social-button[data-chassis][data-size="xl"] { --sp-rw-button-content-gap: var(--sp-rw-space-2); } /* The brand theme is the solid chassis of the accent Button filled with the * provider's colour, which its depth, spotlights, dome and rim derive from; * Google's brand button stays the neutral default one. Text and logo are * white on every fill, whatever the application's accent text is. The * provider's hover colour is the Button's interaction layer at full * strength, on hover and on press, where the chassis also flattens as on * every solid Button. */ :root .sp-social-button[data-social-theme="brand"][data-variant="accent"] { --sp-rw-button-text: var(--sp-rw-fg-emphasis); } :root .sp-social-button[data-social-theme="brand"][data-social="facebook"] { --sp-rw-button-source: #1877f2; --sp-rw-button-interaction: #0c63d4; --sp-rw-button-interaction-hover: 1; --sp-rw-button-interaction-pressed: 1; } :root .sp-social-button[data-social-theme="brand"][data-social="dribbble"] { --sp-rw-button-source: #ea4c89; --sp-rw-button-interaction: #e62872; --sp-rw-button-interaction-hover: 1; --sp-rw-button-interaction-pressed: 1; } /* Apple, X and Figma fill black in Light and Dark. Black has no darker * step, so hover and press lift it with a veil in its white text, at the * steps of the inverse Button, the kit's black Button. */ :root .sp-social-button[data-social-theme="brand"][data-social="apple"], :root .sp-social-button[data-social-theme="brand"][data-social="x"], :root .sp-social-button[data-social-theme="brand"][data-social="figma"] { --sp-rw-button-source: oklch(0% 0 0); --sp-rw-button-interaction: var(--sp-rw-button-text); --sp-rw-button-interaction-hover: 0.08; --sp-rw-button-interaction-pressed: 0.12; } /* A logo keeps its full colour, without the Button's 80 % icon opacity; in * the gray theme it takes the quaternary text colour. */ :root .sp-social-button-logo { opacity: 1; } :root .sp-social-button[data-social-theme="gray"] .sp-social-button-logo { color: var(--sp-rw-fg-quaternary); } } // ~/src/siteplane/components/social-button/index.ts export * from "./social-button";