11<template >
2- <span class =" NavigatorLeafIcon" >
3- {{ kindLetter }}
4- </span >
2+ <div class =" NavigatorLeafIcon" >
3+ < component :is = " icon " v-bind = " iconProps " class = " icon-inline " />
4+ </div >
55</template >
66
77<script >
8+ import SingleLetterSymbolIcon from ' docc-render/components/Icons/SingleLetterSymbolIcon.vue' ;
9+ import CurlyBracketsIcon from ' theme/components/Icons/CurlyBracketsIcon.vue' ;
10+ import TwoLetterSymbolIcon from ' docc-render/components/Icons/TwoLetterSymbolIcon.vue' ;
11+ import CollectionIcon from ' docc-render/components/Icons/CollectionIcon.vue' ;
12+ import { TopicRoleIcons } from ' docc-render/components/DocumentationTopic/TopicLinkBlockIcon.vue' ;
13+ import { TopicKind } from ' docc-render/constants/kinds' ;
14+
15+ const KindAliases = {
16+ [TopicKind .init ]: TopicKind .method ,
17+ [TopicKind .typeMethod ]: TopicKind .method ,
18+ [TopicKind .typeProperty ]: TopicKind .property ,
19+ [TopicKind .enumCase ]: TopicKind .enum ,
20+ };
21+
22+ const TopicKindIcons = {
23+ ... TopicRoleIcons,
24+ [TopicKind .subscript ]: CurlyBracketsIcon,
25+ [TopicKind .struct ]: SingleLetterSymbolIcon,
26+ [TopicKind .method ]: SingleLetterSymbolIcon,
27+ [TopicKind .protocol ]: TwoLetterSymbolIcon,
28+ [TopicKind .property ]: SingleLetterSymbolIcon,
29+ [TopicKind .enum ]: SingleLetterSymbolIcon,
30+ [TopicKind .symbol ]: CollectionIcon,
31+ [TopicKind .class ]: SingleLetterSymbolIcon,
32+ [TopicKind .typealias ]: SingleLetterSymbolIcon,
33+ [TopicKind .var ]: SingleLetterSymbolIcon,
34+ [TopicKind .associatedtype ]: CollectionIcon,
35+ [TopicKind .buildSetting ]: CollectionIcon,
36+ };
37+
38+ const TopicRoleProps = {
39+ [TopicKind .struct ]: { word: ' Struct' },
40+ [TopicKind .method ]: { word: ' Method' , color: ' #272AD8' },
41+ [TopicKind .protocol ]: { word: ' Protocol' },
42+ [TopicKind .property ]: { word: ' Property' , color: ' #509CA3' },
43+ [TopicKind .enum ]: { word: ' Enum' , color: ' #947100' },
44+ [TopicKind .typealias ]: { word: ' Typealias' , color: ' #947100' },
45+ [TopicKind .class ]: { word: ' Class' },
46+ [TopicKind .var ]: { word: ' Var' },
47+ };
48+
849export default {
950 name: ' NavigatorLeafIcon' ,
51+ components: { SingleLetterSymbolIcon },
1052 props: {
11- type : {
53+ kind : {
1254 type: String ,
1355 required: true ,
1456 },
1557 },
1658 computed: {
17- kindLetter ({ type }) {
18- return type . slice ( 0 , 1 );
19- },
59+ normalisedKind : ({ kind }) => KindAliases[kind] || kind,
60+ icon : ({ normalisedKind }) => TopicKindIcons[normalisedKind],
61+ iconProps : ({ normalisedKind }) => TopicRoleProps[normalisedKind] || { },
2062 },
2163};
2264 </script >
@@ -25,15 +67,7 @@ export default {
2567@import ' docc-render/styles/_core.scss' ;
2668
2769.NavigatorLeafIcon {
28- border : 2px solid var (--color-figure-gray-tertiary );
29- padding : 2px ;
30- border-radius : 4px ;
3170 width : 0.8em ;
32- height : 0.8em ;
33- display : inline-flex ;
34- align-items : center ;
35- justify-content : center ;
36- text-transform : uppercase ;
3771 margin-right : 5px ;
3872 flex : 0 0 auto ;
3973}
0 commit comments