fix: hide while no social buttons
This commit is contained in:
@@ -329,3 +329,7 @@ input[type="number"]::-webkit-outer-spin-button {
|
|||||||
appearance: none;
|
appearance: none;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
/* 登录注册页面的底部社会化登录,如果为空,则不显示or分割线 */
|
||||||
|
.or:has(+ .socials:empty) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const Divider: FC<Props> = ({ content, className = "" }) => {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
"relative border-none h-[1px] bg-slate-200 dark:bg-gray-500 my-6 overflow-visible",
|
"or relative border-none h-[1px] bg-slate-200 dark:bg-gray-500 my-6 overflow-visible",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import { useAppSelector } from "@/app/store";
|
|||||||
import Divider from "@/components/Divider";
|
import Divider from "@/components/Divider";
|
||||||
import Button from "@/components/styled/Button";
|
import Button from "@/components/styled/Button";
|
||||||
import Input from "@/components/styled/Input";
|
import Input from "@/components/styled/Input";
|
||||||
import useGoogleAuthConfig from "@/hooks/useGoogleAuthConfig";
|
|
||||||
import MagicLinkLogin from "./MagicLinkLogin";
|
import MagicLinkLogin from "./MagicLinkLogin";
|
||||||
import SignUpLink from "./SignUpLink";
|
import SignUpLink from "./SignUpLink";
|
||||||
import SocialLoginButtons from "./SocialLoginButtons";
|
import SocialLoginButtons from "./SocialLoginButtons";
|
||||||
@@ -22,7 +21,6 @@ export default function LoginPage() {
|
|||||||
const { t: ct } = useTranslation();
|
const { t: ct } = useTranslation();
|
||||||
const { data: enableSMTP, isLoading: loadingSMTPStatus } = useGetSMTPStatusQuery();
|
const { data: enableSMTP, isLoading: loadingSMTPStatus } = useGetSMTPStatusQuery();
|
||||||
const [login, { isSuccess, isLoading, error }] = useLoginMutation();
|
const [login, { isSuccess, isLoading, error }] = useLoginMutation();
|
||||||
const { clientId } = useGoogleAuthConfig();
|
|
||||||
const { data: loginConfig, isSuccess: loginConfigSuccess } = useGetLoginConfigQuery();
|
const { data: loginConfig, isSuccess: loginConfigSuccess } = useGetLoginConfigQuery();
|
||||||
const [input, setInput] = useState({
|
const [input, setInput] = useState({
|
||||||
email: "",
|
email: "",
|
||||||
@@ -110,19 +108,9 @@ export default function LoginPage() {
|
|||||||
const { email, password } = input;
|
const { email, password } = input;
|
||||||
if (!loginConfigSuccess) return null;
|
if (!loginConfigSuccess) return null;
|
||||||
|
|
||||||
const {
|
const { magic_link, who_can_sign_up: whoCanSignUp } = loginConfig;
|
||||||
magic_link,
|
|
||||||
github: enableGithubLogin,
|
|
||||||
google: enableGoogleLogin,
|
|
||||||
metamask: enableMetamaskLogin,
|
|
||||||
oidc = [],
|
|
||||||
who_can_sign_up: whoCanSignUp
|
|
||||||
} = loginConfig;
|
|
||||||
|
|
||||||
const enableMagicLink = enableSMTP && magic_link;
|
const enableMagicLink = enableSMTP && magic_link;
|
||||||
const googleLogin = enableGoogleLogin && clientId;
|
|
||||||
const hasDivider =
|
|
||||||
enableMagicLink || googleLogin || enableMetamaskLogin || oidc.length > 0 || enableGithubLogin;
|
|
||||||
|
|
||||||
if (loadingSMTPStatus) return null;
|
if (loadingSMTPStatus) return null;
|
||||||
return (
|
return (
|
||||||
@@ -163,8 +151,8 @@ export default function LoginPage() {
|
|||||||
{isLoading ? "Signing" : t("sign_in")}
|
{isLoading ? "Signing" : t("sign_in")}
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
{hasDivider && <Divider content="OR" />}
|
<Divider content="OR" />
|
||||||
<div className="flex flex-col gap-3">
|
<div className="socials flex flex-col gap-3">
|
||||||
{enableMagicLink && <MagicLinkLogin />}
|
{enableMagicLink && <MagicLinkLogin />}
|
||||||
<SocialLoginButtons />
|
<SocialLoginButtons />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ export default function Register() {
|
|||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
<Divider content="OR" />
|
<Divider content="OR" />
|
||||||
<div className="flex flex-col gap-3 py-3">
|
<div className="socials flex flex-col gap-3 py-3 empty:hidden">
|
||||||
<SocialLoginButtons type="register" />
|
<SocialLoginButtons type="register" />
|
||||||
</div>
|
</div>
|
||||||
<SignInLink token={magic_token} />
|
<SignInLink token={magic_token} />
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export default function SendMagicLinkPage() {
|
|||||||
<Button onClick={handlePwdPath} className="w-full">
|
<Button onClick={handlePwdPath} className="w-full">
|
||||||
{t("login.password")}
|
{t("login.password")}
|
||||||
</Button>
|
</Button>
|
||||||
<div className="flex flex-col gap-3 py-3">
|
<div className="flex flex-col gap-3 py-3 empty:hidden">
|
||||||
<SocialLoginButtons />
|
<SocialLoginButtons />
|
||||||
</div>
|
</div>
|
||||||
<SignInLink />
|
<SignInLink />
|
||||||
|
|||||||
Reference in New Issue
Block a user