Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

1.3 KB
Raw Blame
import { IconButton } from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { allNonRasterLayersIsHiddenToggled } from 'features/controlLayers/store/canvasSlice';
import { selectNonRasterLayersIsHidden } from 'features/controlLayers/store/selectors';
import type { MouseEventHandler } from 'react';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { PiEyeBold, PiEyeClosedBold } from 'react-icons/pi';

export const EntityListNonRasterLayerToggle = memo(() => {
  const { t } = useTranslation();
  const dispatch = useAppDispatch();
  const isHidden = useAppSelector(selectNonRasterLayersIsHidden);

  const onClick = useCallback<MouseEventHandler>(
    (e) => {
      e.stopPropagation();
      dispatch(allNonRasterLayersIsHiddenToggled());
    },
    [dispatch]
  );

  return (
    <IconButton
      size="sm"
      aria-label={t(isHidden ? 'controlLayers.showNonRasterLayers' : 'controlLayers.hideNonRasterLayers')}
      tooltip={t(isHidden ? 'controlLayers.showNonRasterLayers' : 'controlLayers.hideNonRasterLayers')}
      variant="link"
      icon={isHidden ? <PiEyeClosedBold /> : <PiEyeBold />}
      onClick={onClick}
      alignSelf="stretch"
    />
  );
});

EntityListNonRasterLayerToggle.displayName = 'EntityListNonRasterLayerToggle';