-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(nxdev): add empty state for schema lists (nrwl#11268)
- Loading branch information
Showing
2 changed files
with
140 additions
and
84 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
133 changes: 133 additions & 0 deletions
133
nx-dev/feature-package-schema-viewer/src/lib/ui/package-reference.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,133 @@ | ||
import { | ||
ChipIcon, | ||
CogIcon, | ||
InformationCircleIcon, | ||
} from '@heroicons/react/solid'; | ||
import { SchemaMetadata } from '@nrwl/nx-dev/models-package'; | ||
import { renderMarkdown } from '@nrwl/nx-dev/ui-markdoc'; | ||
import Link from 'next/link'; | ||
import React from 'react'; | ||
import { Heading2 } from './headings'; | ||
|
||
export function PackageReference({ | ||
executors, | ||
generators, | ||
name, | ||
}: { | ||
executors: SchemaMetadata[]; | ||
generators: SchemaMetadata[]; | ||
name: string; | ||
}): JSX.Element { | ||
return ( | ||
<> | ||
<Heading2 title="Package reference" /> | ||
|
||
<p className="mb-16"> | ||
Here is a list of all the executors and generators available from this | ||
package. | ||
</p> | ||
|
||
<Heading2 title={'Executors'} /> | ||
<ul className="divide-y divide-gray-200"> | ||
{executors.map((executor) => ( | ||
<SchemaListItem | ||
schema={executor} | ||
packageName={name} | ||
type="generator" | ||
/> | ||
))} | ||
{executors.length === 0 && <EmptyList type="executor" />} | ||
</ul> | ||
|
||
<div className="h-12">{/* SPACER */}</div> | ||
<Heading2 title={'Generators'} /> | ||
<ul className="divide-y divide-gray-200"> | ||
{generators.map((generator) => ( | ||
<SchemaListItem | ||
schema={generator} | ||
packageName={name} | ||
type="generator" | ||
/> | ||
))} | ||
{generators.length === 0 && <EmptyList type="generator" />} | ||
</ul> | ||
</> | ||
); | ||
} | ||
|
||
function SchemaListItem({ | ||
schema, | ||
type, | ||
packageName, | ||
}: { | ||
schema: SchemaMetadata; | ||
type: 'executor' | 'generator'; | ||
packageName: string; | ||
}): JSX.Element { | ||
return ( | ||
<li | ||
key={schema.name} | ||
className="focus-within:ring-blue-nx-base relative flex px-2 py-4 transition focus-within:ring-2 focus-within:ring-offset-2 hover:bg-gray-50" | ||
> | ||
{type === 'executor' ? ( | ||
<ChipIcon | ||
className="h-8 w-8 flex-shrink-0 rounded-full text-gray-300" | ||
role="img" | ||
/> | ||
) : ( | ||
<CogIcon | ||
className="h-8 w-8 flex-shrink-0 rounded-full text-gray-300" | ||
role="img" | ||
/> | ||
)} | ||
<div className="ml-3"> | ||
<p className="text-sm font-medium text-gray-900"> | ||
<Link href={`/packages/${packageName}/${type}/${schema.name}`}> | ||
<a className="focus:outline-none"> | ||
<span className="absolute inset-0" aria-hidden="true"></span> | ||
{schema.name} | ||
</a> | ||
</Link> | ||
</p> | ||
<div className="prose-sm"> | ||
{renderMarkdown({ | ||
content: schema.description, | ||
data: {}, | ||
filePath: '', | ||
})} | ||
</div> | ||
</div> | ||
</li> | ||
); | ||
} | ||
|
||
function EmptyList({ type }: { type: 'executor' | 'generator' }): JSX.Element { | ||
return ( | ||
<li className="focus-within:ring-blue-nx-base relative flex px-2 py-4 transition focus-within:ring-2 focus-within:ring-offset-2 hover:bg-gray-50"> | ||
<InformationCircleIcon | ||
className="h-8 w-8 flex-shrink-0 rounded-full text-gray-300" | ||
role="img" | ||
/> | ||
<div className="ml-3"> | ||
<p className="text-sm font-medium text-gray-900"> | ||
<Link href="https://github.com/nrwl/nx/discussions"> | ||
<a className="focus:outline-none" rel="noreferrer" target="_blank"> | ||
<span className="absolute inset-0" aria-hidden="true"></span> | ||
No {type} available for this package yet! | ||
</a> | ||
</Link> | ||
</p> | ||
<div className="prose-sm"> | ||
<a | ||
href="https://github.com/nrwl/nx/discussions" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Please be sure to check the Nx roadmap on Github, we are probably | ||
working on what you are looking for. | ||
</a> | ||
</div> | ||
</div> | ||
</li> | ||
); | ||
} |