@@ -2,7 +2,7 @@ import React, { useRef } from "react";
22import type { supportUsButtonProps } from "../types/index" ;
33import type { Theme } from "../types/index" ;
44import { useParentStyles } from "../hooks/useParentStyles" ;
5-
5+ import { validateProps } from "../utils/validateProps" ;
66function sRgbLuminance ( c : number ) : number {
77 const norm = c / 255 ;
88 return norm <= 0.04045 ? norm / 12.92 : Math . pow ( ( norm + 0.055 ) / 1.055 , 2.4 ) ;
@@ -62,28 +62,37 @@ function validateUrl(url?: string): string | undefined {
6262}
6363
6464// Main component function that renders the support us button, taking in various props for customization and rendering different sections such as hero, organization information, sponsors, and call-to-action based on the provided data and selected theme and button variant
65- function SupportUsButton ( {
66- Theme = "auto" ,
67- organizationInformation,
68- sponsors,
69- ctaSection,
70- projectInformation,
71- Logo = true ,
72- className = "" ,
73- border = {
74- TopX1 : "-1000" ,
75- TopX2 : "1000" ,
76- BottomX1 : "-1000" ,
77- BottomX2 : "1000" ,
78- LeftY1 : "-1000" ,
79- LeftY2 : "1000" ,
80- RightY1 : "-1000" ,
81- RightY2 : "1000" ,
82- } ,
83- } : supportUsButtonProps ) : React . JSX . Element {
65+ function SupportUsButton (
66+ props : supportUsButtonProps ,
67+ ) : React . JSX . Element {
68+ const validatedProps = validateProps ( props ?? ( { } as supportUsButtonProps ) ) ;
69+
70+ const {
71+ Theme = "auto" ,
72+ organizationInformation,
73+ sponsors = [ ] ,
74+ ctaSection,
75+ projectInformation,
76+ Logo = true ,
77+ className = "" ,
78+ } = validatedProps ?? ( { } as supportUsButtonProps ) ;
79+
80+ const border = validatedProps . border ?? {
81+ TopX1 : "-1000" ,
82+ TopX2 : "1000" ,
83+ BottomX1 : "-1000" ,
84+ BottomX2 : "1000" ,
85+ LeftY1 : "-1000" ,
86+ LeftY2 : "1000" ,
87+ RightY1 : "-1000" ,
88+ RightY2 : "1000" ,
89+ } ;
8490 const containerRef = useRef < HTMLDivElement > ( null ) ;
91+
8592 const isAuto = Theme === "auto" || Theme === "inherit" ;
93+
8694 const parentStyles = useParentStyles ( containerRef , isAuto ) ;
95+
8796 const darkThemeActive =
8897 Theme === "dark" || ( isAuto && isDarkColor ( parentStyles . backgroundColor ) ) ;
8998
0 commit comments