react#DetailedHTMLProps TypeScript Examples

The following examples show how to use react#DetailedHTMLProps. 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: Link.tsx    From portfolio with MIT License 6 votes vote down vote up
CustomLink = ({
  href,
  ...rest
}: DetailedHTMLProps<
  AnchorHTMLAttributes<HTMLAnchorElement>,
  HTMLAnchorElement
>) => {
  const isInternalLink = href && href.startsWith('/');
  const isAnchorLink = href && href.startsWith('#');

  if (isInternalLink) {
    return (
      <Link href={href}>
        <a {...rest} />
      </Link>
    );
  }

  if (isAnchorLink) {
    return <a href={href} {...rest} />;
  }

  return <a target='_blank' rel='noopener noreferrer' href={href} {...rest} />;
}
Example #2
Source File: ExternalLink.tsx    From kfp-tekton-backend with Apache License 2.0 6 votes vote down vote up
AutoLink: React.FC<DetailedHTMLProps<
  AnchorHTMLAttributes<HTMLAnchorElement>,
  HTMLAnchorElement
>> = props =>
  props.href && props.href.startsWith('#') ? (
    // eslint-disable-next-line jsx-a11y/anchor-has-content
    <a {...props} className={css.link} />
  ) : (
    <ExternalLink {...props} />
  )
Example #3
Source File: Inputs.tsx    From crosshare with GNU Affero General Public License v3.0 6 votes vote down vote up
LengthLimitedInput = ({
  maxLength,
  updateValue,
  ...props
}: LengthLimitedProps &
  DetailedHTMLProps<
    InputHTMLAttributes<HTMLInputElement>,
    HTMLInputElement
  >) => {
  return (
    <input
      {...props}
      onChange={(e) => updateValue(e.target.value.substring(0, maxLength))}
    />
  );
}
Example #4
Source File: Inputs.tsx    From crosshare with GNU Affero General Public License v3.0 6 votes vote down vote up
LengthLimitedTextarea = ({
  maxLength,
  updateValue,
  ...props
}: LengthLimitedProps &
  DetailedHTMLProps<
    TextareaHTMLAttributes<HTMLTextAreaElement>,
    HTMLTextAreaElement
  >) => {
  return (
    <textarea
      {...props}
      onChange={(e) => updateValue(e.target.value.substring(0, maxLength))}
    />
  );
}
Example #5
Source File: ExternalLink.tsx    From kfp-tekton-backend with Apache License 2.0 5 votes vote down vote up
ExternalLink: React.FC<DetailedHTMLProps<
  AnchorHTMLAttributes<HTMLAnchorElement>,
  HTMLAnchorElement
>> = props => (
  // eslint-disable-next-line jsx-a11y/anchor-has-content
  <a {...props} className={css.link} target='_blank' rel='noopener' />
)