Skip to content

Commit 9f9c047

Browse files
committed
align items
1 parent 6f195c7 commit 9f9c047

File tree

2 files changed

+71
-35
lines changed

2 files changed

+71
-35
lines changed

src/login/pages/Login.stories.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,33 @@ export const WithFranceConnectAndProConnectProviders: Story = {
138138
)
139139
};
140140

141+
export const WithFranceConnectNotOnFirstPosition: Story = {
142+
render: () => (
143+
<KcPageStory
144+
kcContext={{
145+
social: {
146+
displayInfo: true,
147+
providers: [
148+
{
149+
loginUrl: "proConnect",
150+
alias: "Pro Connect",
151+
providerId: "agentconnect", // NOTE: It is still agentconnect, pro connect is a rebrand of agentconnect.
152+
displayName: "Pro Connect",
153+
iconClasses: ""
154+
},{
155+
loginUrl: "france-connect",
156+
alias: "france-connect",
157+
providerId: "franceconnect",
158+
displayName: "France Connect",
159+
iconClasses: ""
160+
},
161+
]
162+
}
163+
}}
164+
/>
165+
)
166+
};
167+
141168
export const WithGitHub: Story = {
142169
render: () => (
143170
<KcPageStory

src/login/pages/Login.tsx

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { useState } from "react";
1010
import type { KcContext } from "../KcContext";
1111
import type { I18n } from "../i18n";
1212
import "./login.css";
13+
const franceConnectProviderIds = ["franceconnect", "franceconnect-particulier"];
1314
export default function Login(props: PageProps<Extract<KcContext, { pageId: "login.ftl" }>, I18n>) {
1415
const { kcContext, i18n, doUseDefaultCss, Template, classes } = props;
1516

@@ -52,12 +53,15 @@ export default function Login(props: PageProps<Extract<KcContext, { pageId: "log
5253
<hr />
5354
<div>
5455
{social.providers
55-
.map((...[p]) => {
56+
.map((p, index) => {
5657
if (p.providerId === "agentconnect" || p.providerId === "proconnect") {
5758
return <ProConnectButton key={p.alias} style={{ textAlign: "center" }} url={p.loginUrl} />;
5859
}
5960

60-
if (p.providerId === "franceconnect" || p.providerId === "franceconnect-particulier") {
61+
if (franceConnectProviderIds.includes(p.providerId)) {
62+
if (index !== 0) {
63+
throw new Error('Le bouton FranceConnect doit être le premier bouton de connexion');
64+
}
6165
return (
6266
<>
6367
<p className={fr.cx("fr-text--light")}>
@@ -70,42 +74,47 @@ export default function Login(props: PageProps<Extract<KcContext, { pageId: "log
7074
}
7175

7276
return (
73-
<Button
74-
className={fr.cx("fr-m-1w")}
75-
key={p.alias}
76-
iconId={(() => {
77-
switch (p.providerId) {
78-
case "github":
79-
return "ri-github-fill";
80-
case "google":
81-
return "ri-google-fill";
82-
case "facebook":
83-
return "ri-facebook-fill";
84-
case "microsoft":
85-
return "ri-microsoft-fill";
86-
case "twitter":
87-
return "ri-twitter-fill";
88-
case "instagram":
89-
return "ri-instagram-fill";
90-
case "linkedin":
91-
return "ri-linkedin-fill";
92-
case "stackoverflow":
93-
return "ri-stack-overflow-fill";
94-
case "gitlab":
95-
return "ri-gitlab-fill";
96-
}
97-
return "ri-external-link-line";
98-
})()}
99-
linkProps={{
100-
href: p.loginUrl
101-
}}
102-
>
103-
{p.displayName}
104-
</Button>
77+
<div style={{
78+
display: 'flex',
79+
justifyContent: 'center'
80+
}}>
81+
<Button
82+
className={fr.cx("fr-m-1w")}
83+
key={p.alias}
84+
iconId={(() => {
85+
switch (p.providerId) {
86+
case "github":
87+
return "ri-github-fill";
88+
case "google":
89+
return "ri-google-fill";
90+
case "facebook":
91+
return "ri-facebook-fill";
92+
case "microsoft":
93+
return "ri-microsoft-fill";
94+
case "twitter":
95+
return "ri-twitter-fill";
96+
case "instagram":
97+
return "ri-instagram-fill";
98+
case "linkedin":
99+
return "ri-linkedin-fill";
100+
case "stackoverflow":
101+
return "ri-stack-overflow-fill";
102+
case "gitlab":
103+
return "ri-gitlab-fill";
104+
}
105+
return "ri-external-link-line";
106+
})()}
107+
linkProps={{
108+
href: p.loginUrl
109+
}}
110+
>
111+
{p.displayName}
112+
</Button>
113+
</div>
105114
);
106115
})
107116
.map((value, index) => {
108-
if (index >= 1) {
117+
if (index >= 1 && franceConnectProviderIds.includes(social.providers?.[0].providerId ?? '')) {
109118
return (
110119
<>
111120
<div className="separator">OU</div>

0 commit comments

Comments
 (0)