mirror of
https://github.com/bendtherules/completion-viz.git
synced 2026-08-18 13:42:51 +00:00
feat(completion): CompletionCard - Make source and full record section optional
This commit is contained in:
@@ -11,12 +11,40 @@ import { CompletionCardSummary } from "./CompletionCardSummary";
|
|||||||
export interface ICompletionCardProps {
|
export interface ICompletionCardProps {
|
||||||
completionDetail: ICompletionDetail;
|
completionDetail: ICompletionDetail;
|
||||||
code: string;
|
code: string;
|
||||||
|
showSourceInitial: boolean;
|
||||||
|
showFullRecordInitial: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: have diff version to be shown as tooltip over source code
|
// TODO: have diff version to be shown as tooltip over source code
|
||||||
|
|
||||||
export function CompletionCardFull(props: ICompletionCardProps) {
|
export function CompletionCardFull(props: ICompletionCardProps) {
|
||||||
const { completionDetail, code } = props;
|
const {
|
||||||
|
completionDetail,
|
||||||
|
code,
|
||||||
|
showSourceInitial,
|
||||||
|
showFullRecordInitial,
|
||||||
|
} = props;
|
||||||
|
|
||||||
|
function renderSnippetAndFullRecord() {
|
||||||
|
if (showSourceInitial && !showFullRecordInitial) {
|
||||||
|
return <CompletionCardSourceSnippet />;
|
||||||
|
} else if (showFullRecordInitial && !showSourceInitial) {
|
||||||
|
return <CompletionCardFullRecord />;
|
||||||
|
} else if (showFullRecordInitial && showSourceInitial) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-row gap-x-4">
|
||||||
|
<div className="flex-1 max-w-half">
|
||||||
|
<CompletionCardSourceSnippet />
|
||||||
|
</div>
|
||||||
|
<div className="flex-1 max-w-half">
|
||||||
|
<CompletionCardFullRecord />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CompletionCardContext.Provider value={{ completionDetail, code }}>
|
<CompletionCardContext.Provider value={{ completionDetail, code }}>
|
||||||
@@ -26,9 +54,13 @@ export function CompletionCardFull(props: ICompletionCardProps) {
|
|||||||
)}`}
|
)}`}
|
||||||
>
|
>
|
||||||
<CompletionCardSummary />
|
<CompletionCardSummary />
|
||||||
<CompletionCardSourceSnippet />
|
{renderSnippetAndFullRecord()}
|
||||||
<CompletionCardFullRecord />
|
|
||||||
</div>
|
</div>
|
||||||
</CompletionCardContext.Provider>
|
</CompletionCardContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompletionCardFull.defaultProps = {
|
||||||
|
showSourceInitial: true,
|
||||||
|
showFullRecordInitial: false,
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user