import { useState } from "react"; import { Button } from "../../../ui/atoms/button"; import { OnGitHubLink } from "../../on-github"; import { ReactComponent as ArticleFooterSVG } from "../../../assets/article-footer/article-footer.svg"; import "./index.scss"; import { useGleanClick } from "../../../telemetry/glean-context"; import { ARTICLE_FOOTER, THUMBS } from "../../../telemetry/constants"; import { DEFAULT_LOCALE } from "../../../../../libs/constants"; export function LastModified({ value, locale }) { if (!value) { return Last modified date not known; } const date = new Date(value); // Justification for these is to match historically const dateStringOptions: Intl.DateTimeFormatOptions = { year: "numeric", month: "short", day: "numeric", }; return ( <> This page was last modified on{" "} ); } export function Authors({ url }) { return ( MDN contributors ); } enum ArticleFooterView { Vote, Feedback, Thanks, } type FeedbackReason = | "outdated" | "incomplete" | "code_examples" | "technical" | "consistency" | "incomprehensible" | "linguistic" | "other"; const FEEDBACK_REASONS: Partial> = { outdated: "Content is out of date", incomplete: "Missing information", code_examples: "Code examples not working as expected", other: "Other", }; const FEEDBACK_REASONS_DE: Partial> = { technical: "Übersetzung enthält fachliche Fehler", consistency: "Begriffe sind inkonsistent übersetzt", incomprehensible: "Übersetzung ist nicht verständlich", linguistic: "Übersetzung enthält sprachliche Fehler", code_examples: "Code-Beispiele funktionieren nicht", other: "Sonstige", }; export function ArticleFooter({ doc }) { const [view, setView] = useState(ArticleFooterView.Vote); const [reason, setReason] = useState(); const gleanClick = useGleanClick(); function handleVote(value: boolean) { setView(value ? ArticleFooterView.Thanks : ArticleFooterView.Feedback); // Reusing Thumbs' key to be able to reuse queries. gleanClick(`${THUMBS}: ${ARTICLE_FOOTER} -> ${Number(value)}`); } function handleFeedback() { setView(ArticleFooterView.Thanks); gleanClick(`${ARTICLE_FOOTER}: feedback -> ${reason}`); } return ( ); } function Contribute({ locale }) { const repo = locale === DEFAULT_LOCALE ? "content" : "translated-content"; return ( <> Learn how to contribute . ); }