2020-05-29 00:33:00 +03:00
|
|
|
/*
|
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from "react";
|
|
|
|
import { randomString } from "matrix-js-sdk/src/randomstring";
|
|
|
|
|
|
|
|
interface IProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
|
|
}
|
|
|
|
|
|
|
|
interface IState {
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class StyledCheckbox extends React.PureComponent<IProps, IState> {
|
2020-06-01 14:04:47 +03:00
|
|
|
private id: string;
|
2020-05-29 00:33:00 +03:00
|
|
|
|
|
|
|
public static readonly defaultProps = {
|
|
|
|
className: "",
|
2020-06-18 16:32:43 +03:00
|
|
|
};
|
2020-05-29 00:33:00 +03:00
|
|
|
|
|
|
|
constructor(props: IProps) {
|
|
|
|
super(props);
|
2020-06-01 17:36:55 +03:00
|
|
|
// 56^10 so unlikely chance of collision.
|
2020-06-01 14:04:47 +03:00
|
|
|
this.id = "checkbox_" + randomString(10);
|
2020-05-29 00:33:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
2020-08-29 03:11:08 +03:00
|
|
|
/* eslint @typescript-eslint/no-unused-vars: ["error", { "ignoreRestSiblings": true }] */
|
2020-05-29 00:33:00 +03:00
|
|
|
const { children, className, ...otherProps } = this.props;
|
2020-06-01 17:35:25 +03:00
|
|
|
return <span className={"mx_Checkbox " + className}>
|
|
|
|
<input id={this.id} {...otherProps} type="checkbox" />
|
|
|
|
<label htmlFor={this.id}>
|
|
|
|
{/* Using the div to center the image */}
|
|
|
|
<div className="mx_Checkbox_background">
|
2020-08-29 03:11:08 +03:00
|
|
|
<img src={require("../../../../res/img/feather-customised/check.svg")} />
|
2020-06-01 17:35:25 +03:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{ this.props.children }
|
|
|
|
</div>
|
|
|
|
</label>
|
2020-06-18 16:32:43 +03:00
|
|
|
</span>;
|
2020-05-29 00:33:00 +03:00
|
|
|
}
|
2020-08-29 03:11:08 +03:00
|
|
|
}
|