components#Type TypeScript Examples

The following examples show how to use components#Type. 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: Move.tsx    From nuzlocke with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
function Move({ moveDetail, showStatus }: MoveProps): JSX.Element {
  return (
    <div className={styles.move} style={{ backgroundColor: `${TYPE_COLOR[moveDetail.type]}90` }}>
      <Type hideName type={moveDetail.type} />
      <span>{moveDetail.name}</span>
      {showStatus && (
        <img
          alt="move status"
          src={CATEGORY_COLOR[moveDetail.category]}
          title={moveDetail.category}
        />
      )}
    </div>
  );
}
Example #2
Source File: PokemonType.tsx    From nuzlocke with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
function PokemonType({ pokemon }: PokemonTypeProps): JSX.Element {
  const selectedGame = useStore(
    useCallback((state) => state.selectedGame, []),
    shallow
  );

  return (
    <div className={styles.container}>
      {pokemon.previousType && Number(selectedGame?.value) < FAIRY_GEN ? (
        <>
          <Type type={pokemon?.previousType} />
          {!!pokemon?.previousDualType && <Type type={pokemon?.previousDualType} />}
        </>
      ) : (
        <>
          <Type type={pokemon?.type} />
          {!!pokemon?.dualtype && <Type type={pokemon?.dualtype} />}
        </>
      )}
    </div>
  );
}
Example #3
Source File: Effectiveness.tsx    From nuzlocke with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
Effectiveness = React.memo(function Effectiveness() {
  const { t } = useTranslation('common');
  const typeModal = useStore((state) => state.typeModal);
  const closeTypeModal = useStore((state) => state.closeTypeModal);

  const panes = Object.entries(EFFECTIVENESS)?.reduce((newPanes, effectEntry) => {
    if (!!typeModal && !!effectEntry[1][typeModal]) {
      newPanes.push({
        menuItem: effectEntry[0],
        render: () => (
          <Tab.Pane>
            <div className={styles.container}>
              {!!typeModal &&
                Object.entries(effectEntry[1][typeModal])?.reduce((effects, entry) => {
                  if (entry[1]?.length > 0) {
                    effects.push(
                      <div key={`${effectEntry[0]}-${entry[0]}`}>
                        <h4>{t(entry[0])}:</h4>
                        <div className={styles.list}>
                          {entry[1]?.map((value) => {
                            return (
                              <Type key={`${effectEntry[0]}-${entry[0]}-${value}`} type={value} />
                            );
                          })}
                        </div>
                      </div>
                    );
                  }
                  return effects;
                }, [])}
            </div>
          </Tab.Pane>
        ),
      });
    }
    return newPanes;
  }, []);

  return (
    <Modal open={!!typeModal}>
      <Modal.Content className={styles.content}>
        <h3>
          <Type type={typeModal} />
        </h3>
        <Tab panes={panes} />
      </Modal.Content>
      <Modal.Actions>
        <Button data-testid="effect-close" onClick={closeTypeModal}>
          {t('cancel')}
        </Button>
      </Modal.Actions>
    </Modal>
  );
})