File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -17,12 +17,29 @@ const uiConfig = {
1717
1818const FirebaseAuthGithub : React . FC = ( ) => {
1919 const [ user , setUser ] = useState < User | null > ( null ) ;
20+ const [ githubText , setGithubText ] = useState ( "Sign in with GitHub" ) ; // ✅ new state
2021
2122 useEffect ( ( ) => {
2223 const unregisterAuthObserver = auth . onAuthStateChanged ( ( user ) =>
2324 setUser ( user as User ) ,
2425 ) ;
25- return ( ) => unregisterAuthObserver ( ) ;
26+
27+ // ✅ new effect to change text on resize
28+ const handleResize = ( ) => {
29+ if ( window . innerWidth <= 1110 ) {
30+ setGithubText ( "Sign in" ) ;
31+ } else {
32+ setGithubText ( "Sign in with GitHub" ) ;
33+ }
34+ } ;
35+
36+ handleResize ( ) ; // initial call
37+ window . addEventListener ( "resize" , handleResize ) ;
38+
39+ return ( ) => {
40+ unregisterAuthObserver ( ) ;
41+ window . removeEventListener ( "resize" , handleResize ) ;
42+ } ;
2643 } , [ ] ) ;
2744
2845 if ( user ) {
@@ -88,7 +105,8 @@ const FirebaseAuthGithub: React.FC = () => {
88105 >
89106 < path d = "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.65 7.65 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z" />
90107 </ svg >
91- < span className = "github-text" > Sign in with GitHub</ span >
108+ { /* ✅ dynamic text */ }
109+ < span className = "github-text" > { githubText } </ span >
92110 </ button >
93111 </ div >
94112 ) ;
You can’t perform that action at this time.
0 commit comments