summaryrefslogtreecommitdiff
path: root/docs/src/components/codes/TableRow.jsx
blob: a560911f46ca3a110509d9207a3e183a92d3c1a6 (plain)
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
/*
 * Copyright (c) 2020 The ZMK Contributors
 *
 * SPDX-License-Identifier: CC-BY-NC-SA-4.0
 */

import React from "react";
import PropTypes from "prop-types";
import Name from "./Name";
import Description from "./Description";
import Context from "./Context";
import LinkIcon from "./LinkIcon";
import OsSupport from "./OsSupport";
import operatingSystems from "@site/src/data/operating-systems";

export default function TableRow({
  names,
  description,
  context = "",
  clarify = false,
  documentation,
  os,
  footnotes,
  tableFootnotes,
}) {
  return (
    <tr>
      <td className="names">
        {names.map((name) => (
          <Name key={name} name={name}>
            {name}
          </Name>
        ))}
      </td>
      <td className="description">
        <Description description={description} />
        {clarify && context ? <Context>{context}</Context> : undefined}
      </td>
      <td className="documentation" title="Documentation">
        <a href={documentation} target="_blank" rel="noreferrer">
          <LinkIcon />
        </a>
      </td>
      {operatingSystems.map(({ key, className, title }) => (
        <td key={key} className={`os ${className}`} title={title}>
          <OsSupport
            value={os[key]}
            footnotes={tableFootnotes.filter(
              ({ id }) =>
                (Array.isArray(footnotes[key]) &&
                  footnotes[key].includes(id)) ||
                footnotes[key] == id
            )}
          />
        </td>
      ))}
    </tr>
  );
}

TableRow.propTypes = {
  names: PropTypes.array.isRequired,
  description: PropTypes.string.isRequired,
  context: PropTypes.string.isRequired,
  clarify: PropTypes.bool,
  documentation: PropTypes.string.isRequired,
  os: PropTypes.object.isRequired,
  footnotes: PropTypes.object.isRequired,
  tableFootnotes: PropTypes.array.isRequired,
};