Update MethodName component to receive specific props (#3491)

This commit is contained in:
Charis Kyriakou
2024-03-20 09:03:13 +00:00
committed by GitHub
parent 724370fb40
commit 3519139e68

View File

@@ -1,33 +1,48 @@
import { styled } from "styled-components";
import type { Method } from "../../model-editor/method";
const Name = styled.span`
font-family: var(--vscode-editor-font-family);
word-break: break-all;
`;
const TypeMethodName = (method: Method) => {
if (!method.typeName) {
return <>{method.methodName}</>;
const TypeMethodName = ({
typeName,
methodName,
}: {
typeName?: string;
methodName?: string;
}) => {
if (!typeName) {
return <>{methodName}</>;
}
if (!method.methodName) {
return <>{method.typeName}</>;
if (!methodName) {
return <>{typeName}</>;
}
return (
<>
{method.typeName}.{method.methodName}
{typeName}.{methodName}
</>
);
};
export const MethodName = (method: Method): React.JSX.Element => {
export const MethodName = ({
packageName,
typeName,
methodName,
methodParameters,
}: {
packageName: string;
typeName?: string;
methodName?: string;
methodParameters?: string;
}): React.JSX.Element => {
return (
<Name>
{method.packageName && <>{method.packageName}.</>}
<TypeMethodName {...method} />
{method.methodParameters}
{packageName && <>{packageName}.</>}
<TypeMethodName typeName={typeName} methodName={methodName} />
{methodParameters}
</Name>
);
};