react-icons/fi#FiMinus TypeScript Examples

The following examples show how to use react-icons/fi#FiMinus. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.tsx    From rocketredis with MIT License 5 votes vote down vote up
Header: React.FC = () => {
  const handleCloseWindow = useCallback(() => {
    const window = remote.getCurrentWindow()

    window.close()
  }, [])

  const handleMaximize = useCallback(() => {
    const window = remote.getCurrentWindow()

    const isMacSystem = os.platform() === 'darwin'
    if (isMacSystem) {
      return window.setFullScreen(!window.isFullScreen())
    }

    const { width: currentWidth, height: currentHeight } = window.getBounds()

    const {
      width: maxWidth,
      height: maxHeight
    } = remote.screen.getPrimaryDisplay().workAreaSize

    const isMaximized = currentWidth === maxWidth && currentHeight === maxHeight

    if (!isMaximized) {
      window.maximize()
    } else {
      window.unmaximize()
    }
  }, [])

  const handleMinimize = useCallback(() => {
    const window = remote.getCurrentWindow()

    window.minimize()
  }, [])

  const useMacOSWindowActionButtons = useConfig('useMacOSWindowActionButtons')

  const shouldUseMacOSWindowActions = useMemo(() => {
    return useMacOSWindowActionButtons || os.platform() === 'darwin'
  }, [useMacOSWindowActionButtons])

  return (
    <Container>
      <strong>Rocket Redis</strong>

      {shouldUseMacOSWindowActions ? (
        <WindowActions position="left" shouldShowIconsOnHover>
          <MacActionButton color="close" onClick={handleCloseWindow}>
            <FiX />
          </MacActionButton>
          <MacActionButton color="minimize" onClick={handleMinimize}>
            <FiMinus />
          </MacActionButton>
          <MacActionButton color="maximize" onClick={handleMaximize}>
            <FiMaximize2 />
          </MacActionButton>
        </WindowActions>
      ) : (
        <WindowActions position="right">
          <DefaultActionButton onClick={handleMinimize}>
            <FiMinus />
          </DefaultActionButton>
          <DefaultActionButton onClick={handleMaximize}>
            <FiSquare />
          </DefaultActionButton>
          <DefaultActionButton onClick={handleCloseWindow}>
            <FiX />
          </DefaultActionButton>
        </WindowActions>
      )}
    </Container>
  )
}
Example #2
Source File: lyric.tsx    From cloudmusic-vscode with MIT License 4 votes vote down vote up
Lyric = (): JSX.Element => {
  const [focus, setFocus] = useState(FocusMode.center);
  const [fontSize, setFontSize] = useState(bigFontSize - 8);
  bigFontSize = fontSize + 8;
  const [lyric, setLyric] = useState<NeteaseTypings.LyricData["text"]>([]);

  useEffect(() => {
    const handler = ({ data }: { data: LyricSMsg }) => {
      switch (data.command) {
        case "lyric":
          cnt += 1;
          setLyric(data.text);
          window.scrollTo({ top: 0, behavior: "smooth" });
          break;
        case "index":
          {
            const prev = document.getElementById(`${cnt}-${active}`);
            if (prev) {
              prev.style.fontSize = "";
              prev.style.opacity = "";
              prev.style.fontWeight = "";
            }
            active = data.idx;
            const curr = document.getElementById(`${cnt}-${active}`);
            if (curr) {
              curr.style.fontSize = `${bigFontSize}px`;
              curr.style.opacity = "1";
              curr.style.fontWeight = "bold";
              if (focus === FocusMode.center) {
                curr.scrollIntoView({ block: "center", behavior: "smooth" });
              } else if (focus === FocusMode.inview) {
                const { top, bottom } = curr.getBoundingClientRect();
                if (top > innerHeight || bottom < 0)
                  curr.scrollIntoView({ block: "center", behavior: "smooth" });
              }
            }
          }
          break;
      }
    };

    window.addEventListener("message", handler);
    return () => window.removeEventListener("message", handler);
  }, [focus]);

  return (
    <>
      {useMemo(
        () => (
          <>
            <div
              className="fixed right-8 bottom-8 bg-slate-700 rounded-full p-1 cursor-pointer z-10"
              onClick={() => setFontSize((v) => v - 2)}
            >
              <FiMinus size={32} />
            </div>
            <div
              className="fixed right-8 bottom-24 bg-slate-700 rounded-full p-1 cursor-pointer z-10"
              onClick={() => setFontSize((v) => v + 2)}
            >
              <FiPlus size={32} />
            </div>
          </>
        ),
        []
      )}

      {useMemo(() => {
        // eslint-disable-next-line @typescript-eslint/naming-convention
        const Icon =
          focus === FocusMode.center
            ? FiCrosshair
            : focus === FocusMode.inview
            ? FiLifeBuoy
            : FiCircle;
        return (
          <div
            className="fixed right-8 bottom-40 bg-slate-700 rounded-full p-1 cursor-pointer z-10"
            onClick={() => setFocus((v) => (v + 1) % 3)}
          >
            <Icon size={32} />{" "}
          </div>
        );
      }, [focus])}

      <style>{"body::-webkit-scrollbar{display: none;}"}</style>
      <div style={{ fontSize }} className="my-80">
        {lyric.map(([otext, ttext, rtext], idx) => (
          <div
            id={`${cnt}-${idx}`}
            key={`${cnt}-${idx}`}
            className="text-center text-ellipsis whitespace-nowrap flex flex-col gap-y-1 opacity-80 mb-8"
          >
            <div>{otext}</div>
            {rtext && <div>{rtext}</div>}
            {ttext && <div>{ttext}</div>}
          </div>
        ))}
      </div>
    </>
  );
}