Skip to content

Commit

Permalink
Display flags next to class name
Browse files Browse the repository at this point in the history
Reflections in TypeDoc can be assigned flags, describing certain
properties of the reflection, e.g. abstract, private, readonly etc.
These flags were rendered using badges for most type of reflections, but
not for reflections which are displayed on their own page (like classes,
interfaces etc.). This made it difficult to establish e.g. whether a
class is abstract (see TypeStrong#1874).

This PR fixes the issue by rendering flags in the page titles next to
the name of the documented entity.

Styling of the badges has been amended, to account for them now showing
next to much bigger headings. The styling was inspired by [Bootstrap
badges](https://getbootstrap.com/docs/4.0/components/badge/).

Partially resolves TypeStrong#1874.
  • Loading branch information
ejuda committed Apr 7, 2022
1 parent 1c7b69a commit e0306ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/lib/output/themes/default/partials/header.tsx
@@ -1,7 +1,7 @@
import type { Reflection } from "../../../../models";
import { JSX } from "../../../../utils";
import type { PageEvent } from "../../../events";
import { hasTypeParameters, join } from "../../lib";
import { hasTypeParameters, join, renderFlags } from "../../lib";
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";

export const header = (context: DefaultThemeRenderContext, props: PageEvent<Reflection>) => (
Expand Down Expand Up @@ -77,7 +77,8 @@ export const header = (context: DefaultThemeRenderContext, props: PageEvent<Refl
{join(", ", props.model.typeParameters, (item) => item.name)}
{">"}
</>
)}
)}{" "}
{renderFlags(props.model.flags)}
</h1>
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions static/style.css
Expand Up @@ -766,12 +766,13 @@ footer .tsd-legend {

.tsd-flag {
display: inline-block;
padding: 1px 5px;
padding: 0.25em 0.4em;
border-radius: 4px;
color: var(--color-comment-tag-text);
background-color: var(--color-comment-tag);
text-indent: 0;
font-size: 14px;
font-size: 75%;
line-height: 1;
font-weight: normal;
}

Expand Down

0 comments on commit e0306ec

Please sign in to comment.