-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nx-dev): improve related docs section (#20796)
- Loading branch information
Showing
4 changed files
with
77 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
nx-dev/feature-doc-viewer/src/lib/related-documents-section.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { RelatedDocumentsCategory } from '@nx/nx-dev/models-document'; | ||
import { | ||
CubeTransparentIcon, | ||
ArrowRightIcon, | ||
ClipboardDocumentIcon, | ||
LightBulbIcon, | ||
MagnifyingGlassIcon, | ||
InformationCircleIcon, | ||
} from '@heroicons/react/24/outline'; | ||
|
||
export function RelatedDocumentsSection({ | ||
relatedCategories, | ||
}: { | ||
relatedCategories: RelatedDocumentsCategory[]; | ||
}) { | ||
return ( | ||
<div className="grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-3 items-stretch"> | ||
{relatedCategories.length > 0 && | ||
relatedCategories.map((category) => ( | ||
<CategoryBox key={category.id} category={category} /> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
const iconMap: { [key: string]: JSX.Element } = { | ||
concepts: <CubeTransparentIcon className="w-6 h-6 mr-2" aria-hidden="true" />, | ||
recipes: ( | ||
<ClipboardDocumentIcon className="w-6 h-6 mr-2" aria-hidden="true" /> | ||
), | ||
reference: <LightBulbIcon className="w-6 h-6 mr-2" aria-hidden="true" />, | ||
'see-also': ( | ||
<MagnifyingGlassIcon className="w-6 h-6 mr-2" aria-hidden="true" /> | ||
), | ||
default: ( | ||
<InformationCircleIcon className="w-6 h-6 mr-2" aria-hidden="true" /> | ||
), | ||
}; | ||
|
||
function CategoryBox({ category }: { category: RelatedDocumentsCategory }) { | ||
return ( | ||
<div className="rounded-lg border border-slate-200 bg-white/60 p-5 dark:border-slate-800/40 dark:bg-slate-800/60"> | ||
<h4 className="flex items-center mt-0 mb-2 text-xl font-bold"> | ||
{iconMap[category.id] ?? iconMap.default} | ||
{category.name} | ||
</h4> | ||
<ul className="divide-y divide-slate-300 dark:divide-slate-700 list-none pl-0"> | ||
{category.relatedDocuments.map((d) => ( | ||
<li | ||
key={d.id} | ||
className="flex justify-between items-center py-1 pl-0 text-sm" | ||
> | ||
<a | ||
href={d.path} | ||
className="no-underline hover:underline hover:text-sky-600 dark:hover:text-sky-400 flex-grow flex justify-between items-center" | ||
> | ||
<span>{d.name}</span> | ||
<ArrowRightIcon className="w-4 h-4 text-slate-500 dark:text-slate-400" /> | ||
</a> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3099547
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nx-dev – ./
nx.dev
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx-dev-nrwl.vercel.app