-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
button-social.tsx
54 lines (49 loc) · 1.4 KB
/
button-social.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright © 2024 Ory Corp
// SPDX-License-Identifier: Apache-2.0
import cn from "classnames"
import { JSX } from "react"
import {
buttonSocialIconEndStyle,
buttonSocialIconStartStyle,
ButtonSocialStyle,
buttonSocialStyle,
} from "../theme/button-social.css"
// required since interfaces cannot extend types whose properties are not statically known
type buttonSocialStyle = ButtonSocialStyle & Record<string, unknown>
export interface ButtonSocialProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
buttonSocialStyle {
header: string
brand: string
fullWidth?: boolean
className?: string
}
export const ButtonSocial = ({
header: title,
brand,
size,
variant,
fullWidth,
className,
...props
}: ButtonSocialProps): JSX.Element => {
const brandClass =
brand !== "generic" ? `fa-brands fa-${brand}` : "fa-solid fa-layer-group"
return (
<div className={className}>
<button
className={buttonSocialStyle({ size, variant })}
style={{ width: fullWidth ? "100%" : "auto" }}
{...props}
>
<i className={cn(brandClass, buttonSocialIconStartStyle({ size }))}></i>
{title}
{/* add another hidden icon to the end to center the text */}
<i
className={cn(brandClass, buttonSocialIconEndStyle({ size }))}
style={{ visibility: "hidden", opacity: 0 }}
></i>
</button>
</div>
)
}