import * as React from "react"; import * as d from "../../localData"; import { CSSObject, css } from "@emotion/css"; import { locationAndLanguageToUrl } from "../../common/url"; export const Link: React.FC<{ locationAndLanguage: d.LocationAndLanguage; style?: CSSObject; onJump: (urlData: d.LocationAndLanguage) => void; isActive?: boolean; }> = React.memo((props) => { return ( { /* * リンクを * Ctrlなどを押しながらクリックか, * マウスの中ボタンでクリックした場合などは, ブラウザで新しいタブが開くので, ブラウザでページ推移をしない. */ if ( mouseEvent.ctrlKey || mouseEvent.metaKey || mouseEvent.shiftKey || mouseEvent.button !== 0 ) { return; } mouseEvent.preventDefault(); props.onJump(props.locationAndLanguage); }} href={locationAndLanguageToUrl(props.locationAndLanguage).toString()} > {props.children} ); }); Link.displayName = "Link";