LibraryButton.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import React from "react";
  2. import clsx from "clsx";
  3. import { t } from "../i18n";
  4. import { AppState } from "../types";
  5. import { capitalizeString } from "../utils";
  6. const LIBRARY_ICON = (
  7. <svg viewBox="0 0 576 512">
  8. <path
  9. fill="currentColor"
  10. d="M542.22 32.05c-54.8 3.11-163.72 14.43-230.96 55.59-4.64 2.84-7.27 7.89-7.27 13.17v363.87c0 11.55 12.63 18.85 23.28 13.49 69.18-34.82 169.23-44.32 218.7-46.92 16.89-.89 30.02-14.43 30.02-30.66V62.75c.01-17.71-15.35-31.74-33.77-30.7zM264.73 87.64C197.5 46.48 88.58 35.17 33.78 32.05 15.36 31.01 0 45.04 0 62.75V400.6c0 16.24 13.13 29.78 30.02 30.66 49.49 2.6 149.59 12.11 218.77 46.95 10.62 5.35 23.21-1.94 23.21-13.46V100.63c0-5.29-2.62-10.14-7.27-12.99z"
  11. ></path>
  12. </svg>
  13. );
  14. export const LibraryButton: React.FC<{
  15. appState: AppState;
  16. setAppState: React.Component<any, AppState>["setState"];
  17. isMobile?: boolean;
  18. }> = ({ appState, setAppState, isMobile }) => {
  19. return (
  20. <label
  21. className={clsx(
  22. "ToolIcon ToolIcon_type_floating ToolIcon__library",
  23. `ToolIcon_size_medium`,
  24. {
  25. "is-mobile": isMobile,
  26. },
  27. )}
  28. title={`${capitalizeString(t("toolBar.library"))} — 0`}
  29. >
  30. <input
  31. className="ToolIcon_type_checkbox"
  32. type="checkbox"
  33. name="editor-library"
  34. onChange={(event) => {
  35. setAppState({ isLibraryOpen: event.target.checked });
  36. }}
  37. checked={appState.isLibraryOpen}
  38. aria-label={capitalizeString(t("toolBar.library"))}
  39. aria-keyshortcuts="0"
  40. />
  41. <div className="ToolIcon__icon">{LIBRARY_ICON}</div>
  42. </label>
  43. );
  44. };