Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | 1x 7x 1x 1x 1x 7x 1x 1x 1x 1x | import React from "react";
import ReactGA from "react-ga4";
import * as style from "./index.module.scss";
const GotoTopButton = () => (
<button
type="button"
className={style.shareButton + " " + style.top}
title="トップに戻る"
data-testid="GotoTopButton"
onClick={() => {
window.scrollTo({ top: 0, behavior: "smooth" });
ReactGA.event({
category: "User",
action: "Scroll to Top",
});
}}
>
<span className="icon-chevron-up" aria-hidden="true" />
<span className="visually-hidden">トップに戻る</span>
</button>
);
const ShareBox = ({ url }: { url: string }) => (
<div className={style.mShareBox} role="application" data-testid="share-box">
<a
href={`https://www.facebook.com/sharer/sharer.php?u=${encodeURI(url)}`}
title="FacebookでShareする"
target="_blank"
rel="noopener noreferrer"
className={style.shareButton}
data-testid="facebook-link"
onClick={() =>
ReactGA.event({
category: "Share",
action: "Facebook Share",
})
}
>
<span className="icon-facebook" />
</a>
<a
href={`https://twitter.com/intent/tweet?text=LikeThis:&url=${encodeURI(
url,
)}`}
title="TwitterでShareする"
target="_blank"
rel="noopener noreferrer"
className={style.shareButton}
data-testid="twitter-link"
onClick={() =>
ReactGA.event({
category: "Share",
action: "Twitter Share",
})
}
>
<span className="icon-twitter" />
</a>
<a
href={`http://getpocket.com/edit?url=${encodeURI(url)}`}
title="Pocketに追加する"
target="_blank"
rel="noopener noreferrer"
className={style.shareButton}
data-testid="pocket-link"
onClick={() =>
ReactGA.event({
category: "Share",
action: "Pocket Share",
})
}
>
<span className="icon-get-pocket" />
</a>
<a
href={`http://b.hatena.ne.jp/add?mode=confirm&url=${encodeURI(url)}`}
className={style.shareButtonNoBorder}
data-hatena-bookmark-layout="vertical-normal"
data-hatena-bookmark-lang="ja"
title="このエントリーをはてなブックマークに追加"
data-testid="hatebu-link"
target="_blank"
rel="noopener noreferrer"
onClick={() =>
ReactGA.event({
category: "Share",
action: "Hatebu Share",
})
}
>
<img
src="/assets/button-only@2x.png"
alt="hatena bookmark"
width="30"
height="30"
/>
</a>
<GotoTopButton />
</div>
);
export default ShareBox;
|