File tree Expand file tree Collapse file tree 3 files changed +37
-10
lines changed
react-static-web-apps-auth Expand file tree Collapse file tree 3 files changed +37
-10
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog for ` react-static-web-apps-auth `
2
2
3
+ ## [ 1.7.1] - 2024-03-26
4
+
5
+ ## Added
6
+
7
+ - Custom render function support for User Purge component
8
+
3
9
## [ 1.7.0] - 2024-03-26
4
10
5
11
### Added
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @aaronpowell/react-static-web-apps-auth" ,
3
- "version" : " 1.7.0 " ,
3
+ "version" : " 1.7.1 " ,
4
4
"description" : " A library to help creating authenticated React apps on Azure Static Web Apps" ,
5
5
"main" : " build/index.js" ,
6
6
"types" : " build/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -2,29 +2,50 @@ import React from "react";
2
2
import { StaticWebAppsClassName } from "./constants" ;
3
3
import { AuthProviders } from "./types" ;
4
4
5
+ type UserPurgeRenderProps = {
6
+ label : string ;
7
+ href : string ;
8
+ className : string ;
9
+ } ;
10
+
5
11
const UserPurge = ( {
6
12
globally,
7
13
provider,
8
- label
14
+ label,
15
+ customRenderer,
9
16
} : {
10
17
globally : boolean ;
11
18
provider : AuthProviders ;
12
- label ?: string
19
+ label ?: string ;
20
+ customRenderer ?: ( props : UserPurgeRenderProps ) => JSX . Element ;
13
21
} ) => {
14
22
const host = globally ? "identity.azurestaticapps.net" : location . hostname ;
23
+ const href = `https://${ host } /.auth/purge/${ provider } ` ;
24
+ const className = `purge ${ StaticWebAppsClassName } ` ;
15
25
16
- return (
17
- < a
18
- href = { `https://${ host } /.auth/purge/${ provider } ` }
19
- className = { `purge ${ StaticWebAppsClassName } ` }
20
- >
21
- { label ?? "Purge user information" }
22
- </ a >
26
+ return customRenderer ? (
27
+ customRenderer ( {
28
+ href,
29
+ className,
30
+ label : label ?? "Purge user information" ,
31
+ } )
32
+ ) : (
33
+ < DefaultRenderer
34
+ href = { href }
35
+ className = { className }
36
+ label = { label ?? "Purge user information" }
37
+ />
23
38
) ;
24
39
} ;
25
40
26
41
UserPurge . defaultProps = {
27
42
globally : false ,
28
43
} ;
29
44
45
+ const DefaultRenderer = ( props : UserPurgeRenderProps ) => (
46
+ < a href = { props . href } className = { props . className } >
47
+ { props . label }
48
+ </ a >
49
+ ) ;
50
+
30
51
export { UserPurge } ;
You can’t perform that action at this time.
0 commit comments