@civic/auth 0.5.2-beta.1 → 0.5.3-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/dist/reactjs/components/UserButton.d.ts +3 -1
- package/dist/reactjs/components/UserButton.d.ts.map +1 -1
- package/dist/reactjs/components/UserButton.js +9 -9
- package/dist/reactjs/components/UserButton.js.map +1 -1
- package/dist/shared/version.d.ts +1 -1
- package/dist/shared/version.js +1 -1
- package/dist/shared/version.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
# 0.5.3 UserButton component styling
|
|
2
|
+
- fix the UserButton styling to make it look better with darkmode and more consistent with the other buttons.
|
|
3
|
+
|
|
1
4
|
# 0.5.2 Fix NextJS multiple router refresh bug
|
|
2
5
|
- fix a bug that was causing the NextJS router to refresh multiple times post-login
|
|
3
6
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type CSSProperties } from "react";
|
|
2
|
-
declare const UserButton: ({ className, wrapperClassName, style, wrapperStyle, }: {
|
|
2
|
+
declare const UserButton: ({ className, wrapperClassName, dropdownButtonClassName, style, wrapperStyle, dropdownButtonStyle, }: {
|
|
3
3
|
className?: string;
|
|
4
4
|
wrapperClassName?: string;
|
|
5
|
+
dropdownButtonClassName?: string;
|
|
5
6
|
style?: CSSProperties;
|
|
6
7
|
wrapperStyle?: CSSProperties;
|
|
8
|
+
dropdownButtonStyle?: CSSProperties;
|
|
7
9
|
}) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
8
10
|
export { UserButton };
|
|
9
11
|
//# sourceMappingURL=UserButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserButton.d.ts","sourceRoot":"","sources":["../../../src/reactjs/components/UserButton.tsx"],"names":[],"mappings":"AAEA,OAAc,EAKZ,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AAuCf,QAAA,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"UserButton.d.ts","sourceRoot":"","sources":["../../../src/reactjs/components/UserButton.tsx"],"names":[],"mappings":"AAEA,OAAc,EAKZ,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AAuCf,QAAA,MAAM,UAAU,wGAOb;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,mBAAmB,CAAC,EAAE,aAAa,CAAC;CACrC,qDAsOA,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { AuthStatus } from "../../types.js";
|
|
|
7
7
|
import { shouldShowLoader } from "./utils.js";
|
|
8
8
|
const ChevronDown = () => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "lucide lucide-chevron-down", children: _jsx("path", { d: "m6 9 6 6 6-6" }) }));
|
|
9
9
|
const ChevronUp = () => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "lucide lucide-chevron-up", children: _jsx("path", { d: "m18 15-6-6-6 6" }) }));
|
|
10
|
-
const UserButton = ({ className, wrapperClassName, style, wrapperStyle, }) => {
|
|
10
|
+
const UserButton = ({ className, wrapperClassName, dropdownButtonClassName, style, wrapperStyle, dropdownButtonStyle, }) => {
|
|
11
11
|
const [isOpen, setIsOpen] = useState(false);
|
|
12
12
|
const [buttonWidth, setButtonWidth] = useState(null);
|
|
13
13
|
const { user, signIn, signOut, authStatus, displayMode } = useUser();
|
|
@@ -99,35 +99,35 @@ const UserButton = ({ className, wrapperClassName, style, wrapperStyle, }) => {
|
|
|
99
99
|
? {
|
|
100
100
|
position: "absolute",
|
|
101
101
|
left: 0,
|
|
102
|
+
background: "transparent",
|
|
102
103
|
width: buttonWidth || "auto",
|
|
103
104
|
marginTop: "0.5rem",
|
|
104
105
|
borderRadius: "0.5rem",
|
|
105
|
-
backgroundColor: "white",
|
|
106
|
-
padding: "0.5rem 0",
|
|
107
|
-
color: "#6b7280",
|
|
108
106
|
boxShadow: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",
|
|
109
107
|
zIndex: 1000,
|
|
110
108
|
}
|
|
111
|
-
: { display: "none" }, children: _jsx("ul", { css: { listStyleType: "none", margin: 0, padding: 0 }, children: _jsx("li", { children: _jsx("button", { css: {
|
|
109
|
+
: { display: "none" }, children: _jsx("ul", { css: { listStyleType: "none", margin: 0, padding: 0 }, children: _jsx("li", { children: _jsx("button", { className: dropdownButtonClassName, style: dropdownButtonStyle, css: {
|
|
112
110
|
display: "block",
|
|
113
111
|
width: "100%",
|
|
114
112
|
padding: "0.5rem 1rem",
|
|
115
113
|
transition: "background-color 0.2s",
|
|
116
|
-
background: "none",
|
|
117
|
-
border: "none",
|
|
118
114
|
textAlign: "center",
|
|
115
|
+
color: "#6b7280",
|
|
119
116
|
cursor: "pointer",
|
|
117
|
+
"&:hover": {
|
|
118
|
+
backgroundColor: "#f3f4f6",
|
|
119
|
+
},
|
|
120
120
|
}, onClick: () => {
|
|
121
121
|
setUserActionStarted(true);
|
|
122
122
|
!shouldShowLoader(authStatus, displayMode) && handleSignOut();
|
|
123
|
-
},
|
|
123
|
+
}, children: "Logout" }) }) }) })] }));
|
|
124
124
|
}
|
|
125
125
|
return (_jsx("button", { ref: buttonRef, "data-testid": "sign-in-button", css: {
|
|
126
126
|
cursor: "pointer",
|
|
127
127
|
borderRadius: "9999px",
|
|
128
128
|
border: "1px solid #6b7280",
|
|
129
129
|
padding: "0.75rem 1rem",
|
|
130
|
-
|
|
130
|
+
color: "#6b7280",
|
|
131
131
|
transition: "background-color 0.2s",
|
|
132
132
|
minWidth: "9em", // this stops the button from going too small when in loading mode
|
|
133
133
|
"&:hover": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserButton.js","sourceRoot":"","sources":["../../../src/reactjs/components/UserButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,EACZ,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,CACxB,cACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EACtB,SAAS,EAAC,4BAA4B,YAEtC,eAAM,CAAC,EAAC,cAAc,GAAG,GACrB,CACP,CAAC;AAEF,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,CACtB,cACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EACtB,SAAS,EAAC,0BAA0B,YAE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\";\nimport React, {\n useCallback,\n useEffect,\n useRef,\n useState,\n type CSSProperties,\n} from \"react\";\nimport { ButtonContentOrLoader } from \"./ButtonContentOrLoader.js\";\nimport { AuthStatus } from \"@/types.js\";\nimport { shouldShowLoader } from \"./utils.js\";\n\nconst ChevronDown = () => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"lucide lucide-chevron-down\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n);\n\nconst ChevronUp = () => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"lucide lucide-chevron-up\"\n >\n <path d=\"m18 15-6-6-6 6\" />\n </svg>\n);\n\nconst UserButton = ({\n className,\n wrapperClassName,\n style,\n wrapperStyle,\n}: {\n className?: string;\n wrapperClassName?: string;\n style?: CSSProperties;\n wrapperStyle?: CSSProperties;\n}) => {\n const [isOpen, setIsOpen] = useState(false);\n const [buttonWidth, setButtonWidth] = useState<number | null>(null);\n const { user, signIn, signOut, authStatus, displayMode } = useUser();\n const buttonRef = useRef<HTMLButtonElement>(null);\n const dropdownRef = useRef<HTMLDivElement>(null);\n const [userActionStarted, setUserActionStarted] = useState(false);\n\n useEffect(() => {\n if (\n [AuthStatus.AUTHENTICATED, AuthStatus.UNAUTHENTICATED].includes(\n authStatus,\n )\n ) {\n setUserActionStarted(false);\n }\n }, [authStatus]);\n\n useEffect(() => {\n if (buttonRef.current) {\n setButtonWidth(buttonRef.current.offsetWidth);\n }\n }, [isOpen]);\n\n const handleClickOutside = useCallback((event: MouseEvent) => {\n const target = event.target as HTMLElement;\n\n if (\n buttonRef.current &&\n dropdownRef.current &&\n !buttonRef.current.contains(target) &&\n !dropdownRef.current.contains(target)\n ) {\n setIsOpen(false);\n }\n }, []);\n\n const handleSignOut = useCallback(async () => {\n setIsOpen(false);\n await signOut();\n }, [signOut]);\n\n const handleSignIn = useCallback(async () => {\n setIsOpen(false);\n await signIn();\n }, [signIn]);\n\n const handleEscape = useCallback((event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n setIsOpen(false);\n }\n }, []);\n\n useEffect(() => {\n if (isOpen) {\n window.addEventListener(\"click\", handleClickOutside);\n\n window.addEventListener(\"keydown\", handleEscape);\n }\n\n return () => {\n window.removeEventListener(\"click\", handleClickOutside);\n\n window.removeEventListener(\"keydown\", handleEscape);\n };\n }, [handleClickOutside, handleEscape, isOpen]);\n\n if (user) {\n return (\n <div\n css={{ position: \"relative\", width: \"auto\" }}\n className={wrapperClassName}\n style={wrapperStyle}\n id=\"civic-dropdown-container\"\n >\n <button\n ref={buttonRef}\n css={{\n cursor: \"pointer\",\n display: \"flex\",\n minWidth: \"10rem\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n gap: \"0.5rem\",\n borderRadius: \"9999px\",\n border: \"1px solid #6b7280\",\n padding: \"0.75rem 1rem\",\n color: \"#6b7280\",\n transition: \"background-color 0.2s\",\n \"&:hover\": {\n backgroundColor: \"#f3f4f6\",\n },\n }}\n className={className}\n style={style}\n onClick={() => {\n setUserActionStarted(true);\n authStatus !== AuthStatus.SIGNING_OUT &&\n setIsOpen((isOpen) => !isOpen);\n }}\n >\n <>\n {user?.picture ? (\n <span\n css={{\n position: \"relative\",\n display: \"flex\",\n height: \"1.5rem\",\n width: \"1.5rem\",\n flexShrink: 0,\n gap: \"0.5rem\",\n overflow: \"hidden\",\n borderRadius: \"9999px\",\n }}\n >\n <img\n css={{\n height: \"100%\",\n width: \"100%\",\n objectFit: \"cover\",\n }}\n src={user.picture}\n alt={user?.name || user?.email}\n />\n </span>\n ) : (\n <span css={{ display: \"block\" }} />\n )}\n\n <ButtonContentOrLoader\n authStatus={authStatus}\n displayMode={displayMode}\n userActionStarted={userActionStarted}\n >\n {user?.name || user?.email}\n </ButtonContentOrLoader>\n <span\n css={{\n display: \"block\",\n pointerEvents: \"none\",\n visibility: shouldShowLoader(authStatus, displayMode)\n ? \"hidden\"\n : \"visible\",\n }}\n >\n {isOpen ? <ChevronUp /> : <ChevronDown />}\n </span>\n </>\n </button>\n <div\n ref={dropdownRef}\n css={\n isOpen\n ? {\n position: \"absolute\",\n left: 0,\n width: buttonWidth || \"auto\",\n marginTop: \"0.5rem\",\n borderRadius: \"0.5rem\",\n backgroundColor: \"white\",\n padding: \"0.5rem 0\",\n color: \"#6b7280\",\n boxShadow:\n \"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)\",\n zIndex: 1000,\n }\n : { display: \"none\" }\n }\n >\n <ul css={{ listStyleType: \"none\", margin: 0, padding: 0 }}>\n <li>\n <button\n css={{\n display: \"block\",\n width: \"100%\",\n padding: \"0.5rem 1rem\",\n transition: \"background-color 0.2s\",\n background: \"none\",\n border: \"none\",\n textAlign: \"center\",\n cursor: \"pointer\",\n }}\n onClick={() => {\n setUserActionStarted(true);\n !shouldShowLoader(authStatus, displayMode) && handleSignOut();\n }}\n onMouseEnter={(e) =>\n (e.currentTarget.style.backgroundColor = \"#f3f4f6\")\n }\n onMouseLeave={(e) =>\n (e.currentTarget.style.backgroundColor = \"transparent\")\n }\n >\n Logout\n </button>\n </li>\n </ul>\n </div>\n </div>\n );\n }\n\n return (\n <button\n ref={buttonRef}\n data-testid=\"sign-in-button\"\n css={{\n cursor: \"pointer\",\n borderRadius: \"9999px\",\n border: \"1px solid #6b7280\",\n padding: \"0.75rem 1rem\",\n background: \"none\",\n transition: \"background-color 0.2s\",\n minWidth: \"9em\", // this stops the button from going too small when in loading mode\n \"&:hover\": {\n backgroundColor: \"#f3f4f6\",\n },\n }}\n className={className}\n style={style}\n onClick={() => {\n setUserActionStarted(true);\n !shouldShowLoader(authStatus, displayMode) && handleSignIn();\n }}\n >\n <ButtonContentOrLoader\n authStatus={authStatus}\n displayMode={displayMode}\n userActionStarted={userActionStarted}\n >\n Sign in\n </ButtonContentOrLoader>\n </button>\n );\n};\n\nexport { UserButton };\n"]}
|
|
1
|
+
{"version":3,"file":"UserButton.js","sourceRoot":"","sources":["../../../src/reactjs/components/UserButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,EACZ,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,CACxB,cACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EACtB,SAAS,EAAC,4BAA4B,YAEtC,eAAM,CAAC,EAAC,cAAc,GAAG,GACrB,CACP,CAAC;AAEF,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,CACtB,cACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EACtB,SAAS,EAAC,0BAA0B,YAEpC,eAAM,CAA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K,EAAE,SAAS;oCAChB,MAAM,EAAE,SAAS;oCACjB,SAAS,EAAE;wCACT,eAAe,EAAE,SAAS;qCAC3B;iCACF,EACD,OAAO,EAAE,GAAG,EAAE;oCACZ,oBAAoB,CAAC,IAAI,CAAC,CAAC;oCAC3B,CAAC,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,aAAa,EAAE,CAAC;gCAChE,CAAC,uBAGM,GACN,GACF,GACD,IACF,CACP,CAAC;IACJ,CAAC;IAED,OAAO,CACL,iBACE,GAAG,EAAE,SAAS,iBACF,gBAAgB,EAC5B,GAAG,EAAE;YACH,MAAM,EAAE,SAAS;YACjB,YAAY,EAAE,QAAQ;YACtB,MAAM,EAAE,mBAAmB;YAC3B,OAAO,EAAE,cAAc;YACvB,KAAK,EAAE,SAAS;YAChB,UAAU,EAAE,uBAAuB;YACnC,QAAQ,EAAE,KAAK,EAAE,kEAAkE;YACnF,SAAS,EAAE;gBACT,eAAe,EAAE,SAAS;aAC3B;SACF,EACD,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,GAAG,EAAE;YACZ,oBAAoB,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,YAAY,EAAE,CAAC;QAC/D,CAAC,YAED,KAAC,qBAAqB,IACpB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,iBAAiB,wBAGd,GACjB,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["\"use client\";\nimport { useUser } from \"@/reactjs/hooks/index.js\";\nimport React, {\n useCallback,\n useEffect,\n useRef,\n useState,\n type CSSProperties,\n} from \"react\";\nimport { ButtonContentOrLoader } from \"./ButtonContentOrLoader.js\";\nimport { AuthStatus } from \"@/types.js\";\nimport { shouldShowLoader } from \"./utils.js\";\n\nconst ChevronDown = () => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"lucide lucide-chevron-down\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n);\n\nconst ChevronUp = () => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"lucide lucide-chevron-up\"\n >\n <path d=\"m18 15-6-6-6 6\" />\n </svg>\n);\n\nconst UserButton = ({\n className,\n wrapperClassName,\n dropdownButtonClassName,\n style,\n wrapperStyle,\n dropdownButtonStyle,\n}: {\n className?: string;\n wrapperClassName?: string;\n dropdownButtonClassName?: string;\n style?: CSSProperties;\n wrapperStyle?: CSSProperties;\n dropdownButtonStyle?: CSSProperties;\n}) => {\n const [isOpen, setIsOpen] = useState(false);\n const [buttonWidth, setButtonWidth] = useState<number | null>(null);\n const { user, signIn, signOut, authStatus, displayMode } = useUser();\n const buttonRef = useRef<HTMLButtonElement>(null);\n const dropdownRef = useRef<HTMLDivElement>(null);\n const [userActionStarted, setUserActionStarted] = useState(false);\n\n useEffect(() => {\n if (\n [AuthStatus.AUTHENTICATED, AuthStatus.UNAUTHENTICATED].includes(\n authStatus,\n )\n ) {\n setUserActionStarted(false);\n }\n }, [authStatus]);\n\n useEffect(() => {\n if (buttonRef.current) {\n setButtonWidth(buttonRef.current.offsetWidth);\n }\n }, [isOpen]);\n\n const handleClickOutside = useCallback((event: MouseEvent) => {\n const target = event.target as HTMLElement;\n\n if (\n buttonRef.current &&\n dropdownRef.current &&\n !buttonRef.current.contains(target) &&\n !dropdownRef.current.contains(target)\n ) {\n setIsOpen(false);\n }\n }, []);\n\n const handleSignOut = useCallback(async () => {\n setIsOpen(false);\n await signOut();\n }, [signOut]);\n\n const handleSignIn = useCallback(async () => {\n setIsOpen(false);\n await signIn();\n }, [signIn]);\n\n const handleEscape = useCallback((event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n setIsOpen(false);\n }\n }, []);\n\n useEffect(() => {\n if (isOpen) {\n window.addEventListener(\"click\", handleClickOutside);\n\n window.addEventListener(\"keydown\", handleEscape);\n }\n\n return () => {\n window.removeEventListener(\"click\", handleClickOutside);\n\n window.removeEventListener(\"keydown\", handleEscape);\n };\n }, [handleClickOutside, handleEscape, isOpen]);\n\n if (user) {\n return (\n <div\n css={{ position: \"relative\", width: \"auto\" }}\n className={wrapperClassName}\n style={wrapperStyle}\n id=\"civic-dropdown-container\"\n >\n <button\n ref={buttonRef}\n css={{\n cursor: \"pointer\",\n display: \"flex\",\n minWidth: \"10rem\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n gap: \"0.5rem\",\n borderRadius: \"9999px\",\n border: \"1px solid #6b7280\",\n padding: \"0.75rem 1rem\",\n color: \"#6b7280\",\n transition: \"background-color 0.2s\",\n \"&:hover\": {\n backgroundColor: \"#f3f4f6\",\n },\n }}\n className={className}\n style={style}\n onClick={() => {\n setUserActionStarted(true);\n authStatus !== AuthStatus.SIGNING_OUT &&\n setIsOpen((isOpen) => !isOpen);\n }}\n >\n <>\n {user?.picture ? (\n <span\n css={{\n position: \"relative\",\n display: \"flex\",\n height: \"1.5rem\",\n width: \"1.5rem\",\n flexShrink: 0,\n gap: \"0.5rem\",\n overflow: \"hidden\",\n borderRadius: \"9999px\",\n }}\n >\n <img\n css={{\n height: \"100%\",\n width: \"100%\",\n objectFit: \"cover\",\n }}\n src={user.picture}\n alt={user?.name || user?.email}\n />\n </span>\n ) : (\n <span css={{ display: \"block\" }} />\n )}\n\n <ButtonContentOrLoader\n authStatus={authStatus}\n displayMode={displayMode}\n userActionStarted={userActionStarted}\n >\n {user?.name || user?.email}\n </ButtonContentOrLoader>\n <span\n css={{\n display: \"block\",\n pointerEvents: \"none\",\n visibility: shouldShowLoader(authStatus, displayMode)\n ? \"hidden\"\n : \"visible\",\n }}\n >\n {isOpen ? <ChevronUp /> : <ChevronDown />}\n </span>\n </>\n </button>\n <div\n ref={dropdownRef}\n css={\n isOpen\n ? {\n position: \"absolute\",\n left: 0,\n background: \"transparent\",\n width: buttonWidth || \"auto\",\n marginTop: \"0.5rem\",\n borderRadius: \"0.5rem\",\n boxShadow:\n \"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)\",\n zIndex: 1000,\n }\n : { display: \"none\" }\n }\n >\n <ul css={{ listStyleType: \"none\", margin: 0, padding: 0 }}>\n <li>\n <button\n className={dropdownButtonClassName}\n style={dropdownButtonStyle}\n css={{\n display: \"block\",\n width: \"100%\",\n padding: \"0.5rem 1rem\",\n transition: \"background-color 0.2s\",\n textAlign: \"center\",\n color: \"#6b7280\",\n cursor: \"pointer\",\n \"&:hover\": {\n backgroundColor: \"#f3f4f6\",\n },\n }}\n onClick={() => {\n setUserActionStarted(true);\n !shouldShowLoader(authStatus, displayMode) && handleSignOut();\n }}\n >\n Logout\n </button>\n </li>\n </ul>\n </div>\n </div>\n );\n }\n\n return (\n <button\n ref={buttonRef}\n data-testid=\"sign-in-button\"\n css={{\n cursor: \"pointer\",\n borderRadius: \"9999px\",\n border: \"1px solid #6b7280\",\n padding: \"0.75rem 1rem\",\n color: \"#6b7280\",\n transition: \"background-color 0.2s\",\n minWidth: \"9em\", // this stops the button from going too small when in loading mode\n \"&:hover\": {\n backgroundColor: \"#f3f4f6\",\n },\n }}\n className={className}\n style={style}\n onClick={() => {\n setUserActionStarted(true);\n !shouldShowLoader(authStatus, displayMode) && handleSignIn();\n }}\n >\n <ButtonContentOrLoader\n authStatus={authStatus}\n displayMode={displayMode}\n userActionStarted={userActionStarted}\n >\n Sign in\n </ButtonContentOrLoader>\n </button>\n );\n};\n\nexport { UserButton };\n"]}
|
package/dist/shared/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "@civic/auth:0.5.
|
|
1
|
+
export declare const VERSION = "@civic/auth:0.5.3-beta.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/shared/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/shared/version.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC","sourcesContent":["// This is an auto-generated file. Do not edit.\n\nexport const VERSION = \"@civic/auth:0.5.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/shared/version.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC","sourcesContent":["// This is an auto-generated file. Do not edit.\n\nexport const VERSION = \"@civic/auth:0.5.3-beta.1\";\n"]}
|