Improve styling of SSO Buttons for multiple IdPs
This commit is contained in:
parent
3115c4f3f3
commit
928ddeb718
2 changed files with 31 additions and 12 deletions
|
@ -16,8 +16,15 @@ limitations under the License.
|
||||||
|
|
||||||
.mx_SSOButtons {
|
.mx_SSOButtons {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
|
.mx_SSOButtons_row {
|
||||||
|
& + .mx_SSOButtons_row {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.mx_SSOButton {
|
.mx_SSOButton {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -36,6 +43,8 @@ limitations under the License.
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 50px; // 48px + 1px border on all sides
|
width: 50px; // 48px + 1px border on all sides
|
||||||
height: 50px; // 48px + 1px border on all sides
|
height: 50px; // 48px + 1px border on all sides
|
||||||
|
min-width: 50px; // prevent crushing by the flexbox
|
||||||
|
padding: 12px;
|
||||||
|
|
||||||
> img {
|
> img {
|
||||||
left: 12px;
|
left: 12px;
|
||||||
|
@ -43,7 +52,7 @@ limitations under the License.
|
||||||
}
|
}
|
||||||
|
|
||||||
& + .mx_SSOButton_mini {
|
& + .mx_SSOButton_mini {
|
||||||
margin-left: 24px;
|
margin-left: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,14 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { chunk } from "lodash";
|
||||||
|
import classNames from "classnames";
|
||||||
import {MatrixClient} from "matrix-js-sdk/src/client";
|
import {MatrixClient} from "matrix-js-sdk/src/client";
|
||||||
|
|
||||||
import PlatformPeg from "../../../PlatformPeg";
|
import PlatformPeg from "../../../PlatformPeg";
|
||||||
import AccessibleButton from "./AccessibleButton";
|
import AccessibleButton from "./AccessibleButton";
|
||||||
import {_t} from "../../../languageHandler";
|
import {_t} from "../../../languageHandler";
|
||||||
import {IIdentityProvider, ISSOFlow} from "../../../Login";
|
import {IIdentityProvider, ISSOFlow} from "../../../Login";
|
||||||
import classNames from "classnames";
|
|
||||||
|
|
||||||
interface ISSOButtonProps extends Omit<IProps, "flow"> {
|
interface ISSOButtonProps extends Omit<IProps, "flow"> {
|
||||||
idp: IIdentityProvider;
|
idp: IIdentityProvider;
|
||||||
|
@ -83,6 +84,8 @@ interface IProps {
|
||||||
primary?: boolean;
|
primary?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MAX_PER_ROW = 6;
|
||||||
|
|
||||||
const SSOButtons: React.FC<IProps> = ({matrixClient, flow, loginType, fragmentAfterLogin, primary}) => {
|
const SSOButtons: React.FC<IProps> = ({matrixClient, flow, loginType, fragmentAfterLogin, primary}) => {
|
||||||
const providers = flow["org.matrix.msc2858.identity_providers"] || [];
|
const providers = flow["org.matrix.msc2858.identity_providers"] || [];
|
||||||
if (providers.length < 2) {
|
if (providers.length < 2) {
|
||||||
|
@ -97,8 +100,13 @@ const SSOButtons: React.FC<IProps> = ({matrixClient, flow, loginType, fragmentAf
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const rows = Math.ceil(providers.length / MAX_PER_ROW);
|
||||||
|
const size = Math.ceil(providers.length / rows);
|
||||||
|
|
||||||
return <div className="mx_SSOButtons">
|
return <div className="mx_SSOButtons">
|
||||||
{ providers.map(idp => (
|
{ chunk(providers, size).map(chunk => (
|
||||||
|
<div key={chunk[0].id} className="mx_SSOButtons_row">
|
||||||
|
{ chunk.map(idp => (
|
||||||
<SSOButton
|
<SSOButton
|
||||||
key={idp.id}
|
key={idp.id}
|
||||||
matrixClient={matrixClient}
|
matrixClient={matrixClient}
|
||||||
|
@ -109,6 +117,8 @@ const SSOButtons: React.FC<IProps> = ({matrixClient, flow, loginType, fragmentAf
|
||||||
primary={primary}
|
primary={primary}
|
||||||
/>
|
/>
|
||||||
)) }
|
)) }
|
||||||
|
</div>
|
||||||
|
)) }
|
||||||
</div>;
|
</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue