Add more checkbox styles (#7058)
Add a "kind" param for StyledCheckbox, allowing designers to choose different styles of checkbox as needed. In addition to the preexisting default kind (now called Solid), there's an Outline kind with a green checkmark and a transparent fill. This is used in the device trust view, since the default checkbox style looks too much like the green "verified" shield and it's awkward to have those next to each other.
This commit is contained in:
@@ -17,8 +17,15 @@ limitations under the License.
|
||||
import React from "react";
|
||||
import { randomString } from "matrix-js-sdk/src/randomstring";
|
||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||
import classnames from 'classnames';
|
||||
|
||||
export enum CheckboxStyle {
|
||||
Solid = "solid",
|
||||
Outline = "outline",
|
||||
}
|
||||
|
||||
interface IProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||
kind?: CheckboxStyle;
|
||||
}
|
||||
|
||||
interface IState {
|
||||
@@ -40,13 +47,21 @@ export default class StyledCheckbox extends React.PureComponent<IProps, IState>
|
||||
|
||||
public render() {
|
||||
/* eslint @typescript-eslint/no-unused-vars: ["error", { "ignoreRestSiblings": true }] */
|
||||
const { children, className, ...otherProps } = this.props;
|
||||
return <span className={"mx_Checkbox " + className}>
|
||||
const { children, className, kind = CheckboxStyle.Solid, ...otherProps } = this.props;
|
||||
const newClassName = classnames(
|
||||
"mx_Checkbox",
|
||||
className,
|
||||
{
|
||||
"mx_Checkbox_hasKind": kind,
|
||||
[`mx_Checkbox_kind_${kind}`]: kind,
|
||||
},
|
||||
);
|
||||
return <span className={newClassName}>
|
||||
<input id={this.id} {...otherProps} type="checkbox" />
|
||||
<label htmlFor={this.id}>
|
||||
{ /* Using the div to center the image */ }
|
||||
<div className="mx_Checkbox_background">
|
||||
<img src={require("../../../../res/img/feather-customised/check.svg")} />
|
||||
<div className="mx_Checkbox_checkmark" />
|
||||
</div>
|
||||
<div>
|
||||
{ this.props.children }
|
||||
|
||||
Reference in New Issue
Block a user