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 | 9x 901x 2703x 2703x 2703x 3x 3604x | import React from "react";
import {
CATEGORY_KEYS,
KNOWLEDGE_CATEGORIES,
KnowledgeCategoryKey,
OWNED_ELSEWHERE,
} from "./categories";
/**
* What kind of knowledge a repository holds: one card per category, saying
* what it holds, what an agent does with it and what a person might make one
* of. Used to create or edit a repository and to start generating one.
*
* Beneath it, the kinds that are not repositories and where they belong, so
* nobody files a procedure or a policy as knowledge.
*/
const CategoryPicker: React.FC<{
value: KnowledgeCategoryKey;
onChange: (category: KnowledgeCategoryKey) => void;
/** Leave out the examples (a narrow dialog). */
compact?: boolean;
disabled?: boolean;
/** The group's accessible name. */
label?: string;
}> = ({ value, onChange, compact = false, disabled = false, label = "Kind of knowledge" }) => (
<div className="space-y-2">
<div
role="radiogroup"
aria-label={label}
className="grid grid-cols-1 sm:grid-cols-3 gap-2"
>
{CATEGORY_KEYS.map((key) => {
const meta = KNOWLEDGE_CATEGORIES[key];
const selected = key === value;
return (
<button
key={key}
type="button"
role="radio"
aria-checked={selected}
disabled={disabled}
onClick={() => onChange(key)}
className={`flex min-w-0 flex-col items-stretch text-left rounded-lg border p-3 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-gray-400 disabled:opacity-60 ${
selected
? "border-gray-900 dark:border-gray-100 bg-gray-50 dark:bg-gray-700/60"
: "border-gray-200 dark:border-gray-600 hover:border-gray-300 dark:hover:border-gray-500"
}`}
>
<span className="flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100">
<meta.Icon className="size-4 shrink-0 text-gray-500 dark:text-gray-400" aria-hidden="true" />
{meta.label}
</span>
<span className="mt-1 block text-xs text-gray-600 dark:text-gray-300">
{meta.purpose}
</span>
<span className="mt-1 block text-xs text-gray-500 dark:text-gray-400">
{meta.use}
</span>
{!compact && (
<span className="mt-2 block text-[11px] text-gray-400 dark:text-gray-500">
e.g. {meta.examples.join(" ยท ")}
</span>
)}
</button>
);
})}
</div>
<p className="text-[11px] text-gray-400 dark:text-gray-500">
Not a repository:{" "}
{OWNED_ELSEWHERE.map(({ kind, owner }) => `${kind} (${owner})`).join(", ")}.
</p>
</div>
);
export default CategoryPicker;
|