Skip to content

Commit 77150a6

Browse files
author
Jacob Logan
committed
update api legend and link colors
1 parent 6eb27d7 commit 77150a6

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

src/components/ApiDocs/ReferencePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const ReferencePage = ({ category }) => {
2929
</Flex>
3030
<Flex>
3131
<View as="span" className="api-legend union" />
32-
Union/Intersection
32+
Other
3333
</Flex>
3434
</Flex>
3535
</View>

src/components/ApiDocs/display/ApiModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const ApiModal = ({
2626
if (data.type === 'reference') {
2727
data = references[data.target];
2828
}
29+
console.log(data);
2930
const description = data?.comment?.summary;
3031
const ref = useRef<HTMLDivElement>(null);
3132

src/components/ApiDocs/display/TypeLink.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { useContext } from 'react';
22
import { TypeContext } from '@/components/ApiDocs/ApiModalProvider';
33
import { View } from '@aws-amplify/ui-react';
4+
import references from '@/directory/apiReferences.json';
45

56
export interface LinkDataType {
67
name: string;
78
kind: number;
89
type: string | LinkDataType;
9-
target: number;
10+
target: number | LinkDataType;
1011
value: string;
1112
typeArguments: LinkDataType[];
1213
elementType: LinkDataType;
@@ -21,7 +22,6 @@ export const TypeLink = ({ linkData, breadCrumbs }: TypeLinkInterface) => {
2122
const { setModalData, modalOpen, addBreadCrumb, setBC } =
2223
useContext(TypeContext);
2324
const name = linkData.name;
24-
const className = `type-link kind-${linkData.kind}`;
2525

2626
const onClickHandler = () => {
2727
setModalData(linkData);
@@ -39,6 +39,11 @@ export const TypeLink = ({ linkData, breadCrumbs }: TypeLinkInterface) => {
3939
return <View as="span">{linkData.name}</View>;
4040
} else if (linkData.type === 'literal') {
4141
return <View as="span">{linkData.value}</View>;
42+
} else if (
43+
linkData.type === 'typeOperator' &&
44+
typeof linkData.target !== 'number'
45+
) {
46+
return <View as="span">{linkData.target.name}</View>;
4247
} else if (linkData.type === 'array') {
4348
return [
4449
<TypeLink
@@ -49,6 +54,21 @@ export const TypeLink = ({ linkData, breadCrumbs }: TypeLinkInterface) => {
4954
'[]'
5055
];
5156
} else {
57+
let type = 'unknown';
58+
if (!linkData.type) {
59+
type = 'interface';
60+
} else if (typeof linkData.type === 'string') {
61+
type = linkData.type;
62+
} else if (linkData?.type?.type && typeof linkData.type.type === 'string') {
63+
type = linkData.type.type;
64+
}
65+
if (type === 'reference' && typeof linkData.target === 'number') {
66+
const referencedObject = references[linkData.target];
67+
type = referencedObject.type?.type
68+
? referencedObject.type.type
69+
: 'interface';
70+
}
71+
const className = `type-link type-${type}`;
5272
return (
5373
<button className={className} onClick={onClickHandler}>
5474
{name}

src/styles/reference.scss

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,15 @@
133133
outline-offset: 2px;
134134
}
135135

136-
&.kind-2097152 {
136+
color: var(--amplify-colors-blue-80);
137+
138+
&.type-reference {
137139
color: var(--amplify-colors-red-80);
138140
}
139141

140-
&.kind-256 {
142+
&.type-interface {
141143
color: var(--amplify-colors-green-80);
142144
}
143-
144-
&.kind-undefined {
145-
color: var(--amplify-colors-blue-80);
146-
}
147145
}
148146

149147
.api-legend {

0 commit comments

Comments
 (0)