office-ui-fabric-react#IButtonProps TypeScript Examples

The following examples show how to use office-ui-fabric-react#IButtonProps. 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 azure-serverless-workshop with MIT License 6 votes vote down vote up
export class LoginActionButton extends React.Component<IButtonProps> {
  public render(): JSX.Element {
    const { disabled, checked } = this.props;

    return (
      <div className={css(classNames.loginActionButton)}>
          {auth.isLoggedIn() ? (
            <ActionButton
            data-automation-id="test"
            iconProps={{ iconName: 'AddFriend' }}
            allowDisabledFocus={true}
            disabled={disabled}
            checked={checked}
            onClick={event => {
              event.preventDefault()
              auth.logout()
              }}>
              Sign out ({auth.getUserName()})
            </ActionButton>
          ) : (
            <ActionButton
            data-automation-id="test"
            iconProps={{ iconName: 'AddFriend' }}
            allowDisabledFocus={true}
            disabled={disabled}
            checked={checked}
            onClick={event => {
              event.preventDefault()
              auth.login()
              }}>
              Sign in
            </ActionButton>
          )}
      </div>
    );
  }
}
Example #2
Source File: TeachingBubbleWrapper.tsx    From hypertrons-crx with Apache License 2.0 5 votes vote down vote up
TeachingBubbleWrapper: React.FC<TeachingBubbleProps> = ({ target }) => {
  const [metaData, setMetaData] = useState(new MetaData());
  const [inited, setInited] = useState(false);
  const [settings, setSettings] = useState(new Settings());
  const [teachingBubbleVisible, { toggle: toggleTeachingBubbleVisible }] =
    useBoolean(true);

  useEffect(() => {
    const initSettings = async () => {
      const temp = await loadSettings();
      setSettings(temp);
      setInited(true);
    };
    if (!inited) {
      initSettings();
    }
  }, [settings]);

  useEffect(() => {
    const initMetaData = async () => {
      const temp = await loadMetaData();
      setMetaData(temp);
    };
    initMetaData();
  }, []);

  const disableButtonProps: IButtonProps = React.useMemo(
    () => ({
      children: getMessageByLocale('global_btn_disable', settings.locale),
      onClick: async () => {
        metaData.showTeachingBubble = false;
        await chromeSet('meta_data', metaData.toJson());
        toggleTeachingBubbleVisible();
      },
    }),
    [metaData, settings.locale, toggleTeachingBubbleVisible]
  );

  const confirmButtonProps: IButtonProps = React.useMemo(
    () => ({
      children: getMessageByLocale('global_btn_ok', settings.locale),
      onClick: toggleTeachingBubbleVisible,
    }),
    [settings.locale, toggleTeachingBubbleVisible]
  );

  return (
    <div>
      {teachingBubbleVisible && inited && metaData.showTeachingBubble && (
        <TeachingBubble
          target={target}
          primaryButtonProps={disableButtonProps}
          secondaryButtonProps={confirmButtonProps}
          onDismiss={toggleTeachingBubbleVisible}
          headline={getMessageByLocale(
            'teachingBubble_text_headline',
            settings.locale
          )}
        >
          {getMessageByLocale('teachingBubble_text_content', settings.locale)}
        </TeachingBubble>
      )}
    </div>
  );
}