@fortawesome/react-fontawesome#FontAwesomeIconProps TypeScript Examples

The following examples show how to use @fortawesome/react-fontawesome#FontAwesomeIconProps. 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 gatsby-markdown-typescript-personal-website with MIT License 5 votes vote down vote up
Icon: React.FC<FontAwesomeIconProps> = ({ ...props }) => <FontAwesomeIcon {...props} />
Example #2
Source File: icon.tsx    From example with MIT License 5 votes vote down vote up
export function Icon(props: FontAwesomeIconProps) {
	return <FontAwesomeIcon style={{fontSize: 14}} fixedWidth {...props} />
}
Example #3
Source File: HandlerItem.tsx    From next-basics with GNU General Public License v3.0 4 votes vote down vote up
export function HandlerItem(props: HandlerItemProps): React.ReactElement {
  const { t } = useTranslation(NS_NEXT_BUILDER);
  const { type, handler, uniqKey, name } = props;
  const context = useContext(EditorContext);
  const actionBtnRef = createRef<HTMLDivElement>();
  const contentWrapperRef = createRef<HTMLDivElement>();
  const [lineHeight, setLineHight] = useState(0);

  useEffect(() => {
    const height =
      actionBtnRef.current && contentWrapperRef.current
        ? actionBtnRef.current.getBoundingClientRect()?.top -
          contentWrapperRef.current.getBoundingClientRect()?.top +
          15
        : 0;
    setLineHight(height);
  }, [contentWrapperRef, actionBtnRef]);

  const handlerClick = (handler: BrickEventHandler): void => {
    if (getHandlerType(handler) !== HandlerType.Unknown) {
      context?.onEdit(handler, uniqKey, name);
    }
  };

  const showCallback = useMemo(() => {
    return (
      name !== LifeCycle.UseResolves &&
      (type === HandlerType.UseProvider ||
        (handler as UseProviderEventHandler).callback ||
        hasCallbackActions.includes(
          (handler as BuiltinBrickEventHandler).action
        ))
    );
  }, [handler, name, type]);

  const handlerCallback = (
    <>
      <div
        className={classNames(sharedStyle.eventWrapper, styles.callback)}
        ref={contentWrapperRef}
      >
        <div
          className={sharedStyle.strikeLine}
          style={{ height: lineHeight }}
        ></div>
        {getProcessedEvents(
          (handler as UseProviderEventHandler).callback as BrickEventsMap
        )?.map((item) => (
          <div key={item.name}>
            <div className={sharedStyle.eventName}>
              <FontAwesomeIcon
                icon="bolt"
                style={{ marginRight: 12 }}
                className={sharedStyle.eventIcon}
              />
              {`callback.${item.name}`}

              <div className={sharedStyle.iconWrapper}>
                <FontAwesomeIcon
                  className={sharedStyle.plusIcon}
                  icon="plus-square"
                  onClick={() =>
                    context?.onCreate(
                      `${uniqKey}-callback-${item.name}`,
                      `callback.${item.name}`
                    )
                  }
                />

                <FontAwesomeIcon
                  className={sharedStyle.removeIcon}
                  icon="minus-square"
                  onClick={() =>
                    context.removeCallback?.(`${uniqKey}-callback-${item.name}`)
                  }
                />
              </div>
            </div>

            <div className={sharedStyle.eventHandler}>
              {item.events.map((row, rowIndex) => (
                <HandlerItem
                  key={rowIndex}
                  name={`callback.${item.name}`}
                  type={getHandlerType(row)}
                  handler={row}
                  uniqKey={`${uniqKey}-callback-${item.name}-${rowIndex}`}
                ></HandlerItem>
              ))}
            </div>
          </div>
        ))}
      </div>
      <div className={sharedStyle.actionArea} ref={actionBtnRef}>
        <AddEventBtn
          eventDocInfo={callbackEvents}
          eventList={getProcessedEvents(
            (handler as UseProviderEventHandler).callback as BrickEventsMap
          )}
          onClick={(name) =>
            context.addCallback?.(`${uniqKey}-callback-${name}`)
          }
        />
      </div>
    </>
  );

  return (
    <div className={styles[type]}>
      <div
        className={classNames(styles.handleContainer, {
          [styles.unknown]: type === HandlerType.Unknown,
        })}
        onClick={() => handlerClick(handler)}
      >
        <FontAwesomeIcon
          icon={handlerIconMap[type] as FontAwesomeIconProps["icon"]}
          className={styles.icon}
        />
        <div className={styles.handler}>
          <Tooltip
            title={
              getHandlerType(handler) === HandlerType.Unknown &&
              t(K.DO_NOT_SUPPORT_VISUAL_CONFIG)
            }
          >
            {getHandlerName(handler)}
          </Tooltip>
        </div>
        {!isNil(handler.if) && <span className={styles.ifTag}>if</span>}
      </div>
      {showCallback && handlerCallback}
    </div>
  );
}