Skip to content

Commit 3df47db

Browse files
committed
feat(react-sdk): add UrUserButton component
1 parent c58b82b commit 3df47db

9 files changed

Lines changed: 596 additions & 8 deletions

File tree

examples/react-sdk-demo/src/App.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useEffect } from 'react';
2-
import { UrAuth, useAuth, useUser, ProtectedRoute, GuestRoute } from '@urbackend/react';
2+
import { UrAuth, ProtectedRoute, GuestRoute, useUser, UrUserButton } from '@urbackend/react';
33
import './App.css';
44

55
// Mini router component for the demo
@@ -43,11 +43,17 @@ function App() {
4343
}
4444

4545
function Dashboard() {
46-
const { user } = useUser();
47-
const { logout } = useAuth();
46+
const { user, logout } = useUser();
4847

4948
return (
5049
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', minHeight: '100vh', background: '#f8fafc', padding: '24px' }}>
50+
51+
{/* Naya component yahan dal diya! */}
52+
<UrUserButton
53+
onSettingsClick={() => alert('Settings Clicked')}
54+
onProfileClick={() => alert('Profile Clicked')}
55+
/>
56+
5157
<div style={{
5258
width: '100%',
5359
maxWidth: '500px',

sdks/urbackend-react/dist/index.d.mts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,29 @@ interface UrAuthProps {
9090
}
9191
declare const UrAuth: React.FC<UrAuthProps>;
9292

93-
export { GuestRoute, type GuestRouteProps, ProtectedRoute, type ProtectedRouteProps, UrAuth, type UrAuthProps, UrProvider, type UrProviderProps, useAuth, useDb, useStorage, useUrContext, useUser };
93+
interface UrUserButtonProps {
94+
/**
95+
* Shape of the profile avatar. Defaults to 'square' as requested.
96+
*/
97+
shape?: 'square' | 'circle';
98+
/**
99+
* Position of the button on the screen. Defaults to 'top-right'.
100+
* Use 'inline' if you want to place it within a normal flex/grid layout instead of absolute positioning.
101+
*/
102+
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'inline';
103+
/**
104+
* Called when "Profile" is clicked.
105+
*/
106+
onProfileClick?: () => void;
107+
/**
108+
* Called when "Settings" is clicked.
109+
*/
110+
onSettingsClick?: () => void;
111+
/**
112+
* Z-index for the fixed container. Defaults to 999.
113+
*/
114+
zIndex?: number;
115+
}
116+
declare const UrUserButton: React.FC<UrUserButtonProps>;
117+
118+
export { GuestRoute, type GuestRouteProps, ProtectedRoute, type ProtectedRouteProps, UrAuth, type UrAuthProps, UrProvider, type UrProviderProps, UrUserButton, type UrUserButtonProps, useAuth, useDb, useStorage, useUrContext, useUser };

sdks/urbackend-react/dist/index.d.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,29 @@ interface UrAuthProps {
9090
}
9191
declare const UrAuth: React.FC<UrAuthProps>;
9292

93-
export { GuestRoute, type GuestRouteProps, ProtectedRoute, type ProtectedRouteProps, UrAuth, type UrAuthProps, UrProvider, type UrProviderProps, useAuth, useDb, useStorage, useUrContext, useUser };
93+
interface UrUserButtonProps {
94+
/**
95+
* Shape of the profile avatar. Defaults to 'square' as requested.
96+
*/
97+
shape?: 'square' | 'circle';
98+
/**
99+
* Position of the button on the screen. Defaults to 'top-right'.
100+
* Use 'inline' if you want to place it within a normal flex/grid layout instead of absolute positioning.
101+
*/
102+
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'inline';
103+
/**
104+
* Called when "Profile" is clicked.
105+
*/
106+
onProfileClick?: () => void;
107+
/**
108+
* Called when "Settings" is clicked.
109+
*/
110+
onSettingsClick?: () => void;
111+
/**
112+
* Z-index for the fixed container. Defaults to 999.
113+
*/
114+
zIndex?: number;
115+
}
116+
declare const UrUserButton: React.FC<UrUserButtonProps>;
117+
118+
export { GuestRoute, type GuestRouteProps, ProtectedRoute, type ProtectedRouteProps, UrAuth, type UrAuthProps, UrProvider, type UrProviderProps, UrUserButton, type UrUserButtonProps, useAuth, useDb, useStorage, useUrContext, useUser };

sdks/urbackend-react/dist/index.js

Lines changed: 162 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/urbackend-react/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)