2020-01-20 15:52:19 -08:00
|
|
|
import "./ToolIcon.scss";
|
|
|
|
|
|
|
|
import React from "react";
|
2020-10-19 17:14:28 +03:00
|
|
|
import clsx from "clsx";
|
2020-01-20 15:52:19 -08:00
|
|
|
|
|
|
|
type LockIconSize = "s" | "m";
|
|
|
|
|
|
|
|
type LockIconProps = {
|
|
|
|
title?: string;
|
|
|
|
name?: string;
|
|
|
|
checked: boolean;
|
|
|
|
onChange?(): void;
|
2020-04-25 18:43:02 +05:30
|
|
|
zenModeEnabled?: boolean;
|
2020-01-20 15:52:19 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
const DEFAULT_SIZE: LockIconSize = "m";
|
|
|
|
|
|
|
|
const ICONS = {
|
|
|
|
CHECKED: (
|
|
|
|
<svg
|
|
|
|
width="1792"
|
|
|
|
height="1792"
|
|
|
|
viewBox="0 0 1792 1792"
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
>
|
|
|
|
<path d="M640 768h512v-192q0-106-75-181t-181-75-181 75-75 181v192zm832 96v576q0 40-28 68t-68 28h-960q-40 0-68-28t-28-68v-576q0-40 28-68t68-28h32v-192q0-184 132-316t316-132 316 132 132 316v192h32q40 0 68 28t28 68z" />
|
|
|
|
</svg>
|
|
|
|
),
|
|
|
|
UNCHECKED: (
|
|
|
|
<svg
|
|
|
|
width="1792"
|
|
|
|
height="1792"
|
|
|
|
viewBox="0 0 1792 1792"
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
2020-04-02 12:21:19 -04:00
|
|
|
className="unlocked-icon rtl-mirror"
|
2020-01-20 15:52:19 -08:00
|
|
|
>
|
|
|
|
<path d="M1728 576v256q0 26-19 45t-45 19h-64q-26 0-45-19t-19-45v-256q0-106-75-181t-181-75-181 75-75 181v192h96q40 0 68 28t28 68v576q0 40-28 68t-68 28h-960q-40 0-68-28t-28-68v-576q0-40 28-68t68-28h672v-192q0-185 131.5-316.5t316.5-131.5 316.5 131.5 131.5 316.5z" />
|
|
|
|
</svg>
|
2020-01-24 12:04:54 +02:00
|
|
|
),
|
2020-01-20 15:52:19 -08:00
|
|
|
};
|
|
|
|
|
2021-06-11 23:13:05 +02:00
|
|
|
export const LockButton = (props: LockIconProps) => {
|
2020-01-20 15:52:19 -08:00
|
|
|
return (
|
2020-02-21 14:34:18 -05:00
|
|
|
<label
|
2020-10-19 17:14:28 +03:00
|
|
|
className={clsx(
|
|
|
|
"ToolIcon ToolIcon__lock ToolIcon_type_floating zen-mode-visibility",
|
2021-06-11 23:13:05 +02:00
|
|
|
`ToolIcon_size_${DEFAULT_SIZE}`,
|
2020-10-19 17:14:28 +03:00
|
|
|
{
|
|
|
|
"zen-mode-visibility--hidden": props.zenModeEnabled,
|
|
|
|
},
|
|
|
|
)}
|
2020-04-07 14:39:06 +03:00
|
|
|
title={`${props.title} — Q`}
|
2020-02-21 14:34:18 -05:00
|
|
|
>
|
2020-01-20 15:52:19 -08:00
|
|
|
<input
|
|
|
|
className="ToolIcon_type_checkbox"
|
|
|
|
type="checkbox"
|
|
|
|
name={props.name}
|
|
|
|
onChange={props.onChange}
|
|
|
|
checked={props.checked}
|
2020-01-26 17:14:31 -03:00
|
|
|
aria-label={props.title}
|
2020-01-20 15:52:19 -08:00
|
|
|
/>
|
|
|
|
<div className="ToolIcon__icon">
|
|
|
|
{props.checked ? ICONS.CHECKED : ICONS.UNCHECKED}
|
|
|
|
</div>
|
|
|
|
</label>
|
|
|
|
);
|
2020-05-20 16:21:37 +03:00
|
|
|
};
|