types#Tuple TypeScript Examples

The following examples show how to use types#Tuple. 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: useRandomColorPair.ts    From portfolio with MIT License 6 votes vote down vote up
export function useRandomColorPair(): Tuple<string> {
  const colors: Tuple<string>[] = [
    ['#F5E1FF', '#CAF0F8'],
    ['#EAF4F4', '#FFEDD8'],
    ['#F9E5D8', '#EDE9F6'],
    ['#EEEBFF', '#FFFAD4'],
  ];

  const random = Math.round(Math.random() * (colors.length - 1));

  return useMemo(() => colors[random], []);
}
Example #2
Source File: SocialIcons.tsx    From portfolio with MIT License 5 votes vote down vote up
function resolveIcon(entry: Tuple<string>): React.ReactNode {
  const [type, url] = entry;

  const props: IconBaseProps = {
    className: 'icon cursor-pointer text-2xl mr-6',
    color: Colors[type],
  };

  let icon: Maybe<React.ReactNode> = null;

  switch (type) {
    case ContactType.linkedin:
      icon = <LinkedinIcon {...props} />;
      break;

    case ContactType.twitter:
      icon = <TwitterIcon {...props} />;
      break;

    case ContactType.github:
      icon = <GithubIcon {...props} />;
      break;

    case ContactType.youtube:
      icon = <YoutubeIcon {...props} />;
      break;

    case ContactType.email:
      icon = <MailIcon {...props} />;
      break;

    case ContactType.buymeacoffee:
      icon = <BuymeacoffeeIcon {...props} />;
      break;
    default:
      break;
  }

  return (
    <a
      className='social-icons'
      href={url}
      aria-label={type}
      target='_blank'
      rel='noopener noreferrer'
    >
      {icon}
    </a>
  );
}