-
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: style
imported by
section with link-cards on module pages (#…
…40) * feature: add `AtlasModuleRef` type for `module.imports` and `module.importedBy` * chore(webui): upgrade fixture with new `AtlasModuleRef` objects * feature(webui): style `imported by` section on module pages
- Loading branch information
Showing
8 changed files
with
97 additions
and
37 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
Large diffs are not rendered by default.
Oops, something went wrong.
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