-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(webui): style
imported by
section on module pages
- Loading branch information
Showing
5 changed files
with
80 additions
and
25 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
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,61 @@ | ||
import { Link } from 'expo-router'; | ||
// @ts-expect-error | ||
import PackageIcon from 'lucide-react/dist/esm/icons/box'; | ||
// @ts-expect-error | ||
import FileIcon from 'lucide-react/dist/esm/icons/file'; | ||
import { PropsWithChildren } from 'react'; | ||
|
||
import { relativeBundlePath } from '~/utils/bundle'; | ||
import type { AtlasModule, AtlasModuleRef, PartialAtlasBundle } from '~core/data/types'; | ||
|
||
type ModuleImportedByProps = { | ||
bundle: PartialAtlasBundle; | ||
module: AtlasModule; | ||
}; | ||
|
||
export function ModuleImportedBy(props: ModuleImportedByProps) { | ||
return ( | ||
<> | ||
{props.module.importedBy.map((moduleRef) => ( | ||
<div key={moduleRef.path} className="inline-block m-2"> | ||
<ModuleImportLink bundle={props.bundle} reference={moduleRef} /> | ||
</div> | ||
))} | ||
</> | ||
); | ||
} | ||
|
||
type ModuleImportLinkProps = PropsWithChildren<{ | ||
bundle: PartialAtlasBundle; | ||
reference: AtlasModuleRef; | ||
}>; | ||
|
||
function ModuleImportLink(props: ModuleImportLinkProps) { | ||
const relativePath = relativeBundlePath(props.bundle, props.reference.path); | ||
const Icon = props.reference.package ? PackageIcon : FileIcon; | ||
|
||
return ( | ||
<Link | ||
asChild | ||
href={{ | ||
pathname: '/(atlas)/[bundle]/modules/[path]', | ||
params: { | ||
bundle: props.bundle.id, | ||
path: props.reference.path, | ||
}, | ||
}} | ||
> | ||
<a | ||
className="px-3 py-2 text-2xs border border-secondary rounded-md bg-default text-default inline-flex flex-row items-center group hover:bg-subtle transition-colors" | ||
aria-label={`Open: ${relativePath}`} | ||
title={`Open: ${relativePath}`} | ||
> | ||
<Icon size={14} /> | ||
<span className="mx-2 whitespace-nowrap overflow-hidden text-ellipsis group-hover:underline underline-offset-2"> | ||
{relativePath} | ||
</span> | ||
<span className="ml-2">→</span> | ||
</a> | ||
</Link> | ||
); | ||
} |
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
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