jsx-readme
Version:
Generate Readme files with a React-like syntax and package.json-aware helpers.
58 lines • 2.75 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContributorsTable = void 0;
const jsx_md_1 = __importStar(require("jsx-md"));
/** Displays a contributors table with avatar. This component returns raw HTML for a more complex layout structure. */
const ContributorsTable = ({ contributors, itemsPerRow = 6, avatarSize = 100, }) => {
if (!contributors || contributors.length <= 0) {
return null;
}
const rows = [
...Array(Math.ceil(contributors.length / itemsPerRow)),
].map((_, i) => contributors.slice(i * itemsPerRow, i * itemsPerRow + itemsPerRow));
return ((0, jsx_md_1.default)(jsx_md_1.Fragment, null,
"<table>",
rows.map((contributors, idx) => ((0, jsx_md_1.default)(jsx_md_1.Fragment, { key: idx },
"<tr>",
contributors.map((contributor) => ((0, jsx_md_1.default)(jsx_md_1.Fragment, { key: contributor.id },
'<td align="center">',
`<a title="${contributor.name}'s GitHub profile" href="https://github.com/${contributor.name}">`,
`<img alt="${contributor.name}" src="https://avatars.githubusercontent.com/u/${contributor.id}?s=${avatarSize}" width="${avatarSize}px">`,
"</a>",
"<br />",
`<a title="${contributor.name}'s GitHub profile" href="https://github.com/${contributor.name}">`,
"<sub>",
"<b>",
contributor.name,
"</b>",
"</sub>",
"</a>",
"</td>"))),
"</tr>"))),
"</table>"));
};
exports.ContributorsTable = ContributorsTable;
//# sourceMappingURL=ContributorsTable.js.map