@material-ui/icons#ArrowRightAlt JavaScript Examples

The following examples show how to use @material-ui/icons#ArrowRightAlt. 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.js    From Queen with MIT License 5 votes vote down vote up
ButtonContinue = ({ setPendingChangePage }) => {
  const { readonly, isLastPage, page } = useContext(OrchestratorContext);
  const classes = useStyles();

  const lastLabel = readonly ? D.simpleQuit : D.saveAndQuit;
  const getNextLabel = isLastPage ? lastLabel : D.continueButton;

  const continueButtonRef = useRef();

  const [pageChanging, setPageChanging] = useState(null);

  const localPageNext = () => setPageChanging('next');
  const localFinalQuit = () => setPageChanging('quit');

  const pageNextFunction = isLastPage ? localFinalQuit : localPageNext;

  const [focus, setFocus] = useState(false);
  const onfocus = value => () => setFocus(value);

  useEffect(() => {
    setPageChanging(false);
  }, [page]);

  const keysToHandle = ['alt+enter'];

  const keyboardShortcut = (key, e) => {
    e.preventDefault();
    if (key === 'alt+enter') {
      if (continueButtonRef && continueButtonRef.current) {
        continueButtonRef.current.focus();
        pageNextFunction();
      }
    }
  };

  useEffect(() => {
    if (focus && pageChanging) {
      setPendingChangePage(pageChanging);
    }
  }, [focus, pageChanging, setPendingChangePage]);

  const componentToDisplay = (
    <div className={classes.wrapperButton}>
      <Button
        ref={continueButtonRef}
        aria-label={getNextLabel}
        type="button"
        onClick={pageNextFunction}
        onFocus={onfocus(true)}
        onBlur={onfocus(false)}
        disabled={readonly}
        endIcon={!isLastPage && <ArrowRightAlt />}
      >
        {getNextLabel}
      </Button>
      <span className={classes.help}>{` ${D.helpShortCut} `}</span>
      <span className={classes.labelHelp}>{D.ctrlEnter}</span>
      <KeyboardEventHandler
        handleKeys={keysToHandle}
        onKeyEvent={keyboardShortcut}
        handleFocusableElements
      />
    </div>
  );

  return (
    <>
      {readonly && isLastPage && componentToDisplay}
      {!readonly && componentToDisplay}
    </>
  );
}