Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/split navigation names #910

Merged
merged 3 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/* SPDX-License-Identifier: Apache-2.0 */
.table-row > *:first-child {
vertical-align: middle;
}

:host ::ng-deep .mdc-evolution-chip-set__chips {
max-width: 100%;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}

.example {
word-break: break-all;
word-break: break-word;
}

.attribute {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
/* SPDX-License-Identifier: Apache-2.0 */
.table-row > *:first-child {
vertical-align: middle;
}
.table-row > *:last-child {
word-break: break-word;
}

.type-badge {
display: inline;
background-color: #e0e0e0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ a {
font-size: smaller;

border-radius: 0.3em;
padding: 0 0.1em;
margin: 0 0 auto 0;
padding: 0 0.2em;
margin: 0.2em 0.3em auto 0.3em;
}
.sidenav .badge.send-badge {
color: var(--springwolf-badge-color-send);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<mat-icon *ngIf="link.icon" fontIcon="{{ link.icon }}" />
<b>
<a [href]="link.href">
{{ link.name }}
@for (linkEl of link.name; track linkEl) {{{linkEl}}&#x200B;}
</a>
</b>
</span>
Expand All @@ -24,7 +24,8 @@
>
<span>
<a [href]="child.href">
{{ child.name }}
@for (linkEl of child.name; track linkEl)
{{{linkEl}}&#x200B;}
</a>
@for (childTag of child.tags; track childTag) {
<span class="badge {{ childTag }}-badge">{{ childTag }}</span>
Expand All @@ -41,7 +42,10 @@
}"
>
<span>
<a [href]="subchild.href"> {{ subchild.name }}</a>
<a [href]="subchild.href">
@for (linkEl of subchild.name; track linkEl)
{{{linkEl}}&#x200B;}
</a>

@for (subChildTag of subchild.tags; track subChildTag) {
<span class="badge {{ subChildTag }}-badge">{{
Expand Down
23 changes: 14 additions & 9 deletions springwolf-ui/src/app/components/new/sidenav/sidenav.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { AsyncApiMapperService } from "../../../service/asyncapi/asyncapi-mapper
import { Location } from "@angular/common";

interface NavigationEntry {
name: string;
name: string[];
icon?: string;
href: string | undefined;
selected?: boolean;
Expand Down Expand Up @@ -47,37 +47,37 @@ export class SidenavComponent implements OnInit, AfterViewInit {
const newNavigation: NavigationEntry[] = [];

newNavigation.push({
name: "Info",
name: ["Info"],
icon: "info",
href: AsyncApiMapperService.BASE_URL + "info",
});

const servers: NavigationEntry[] = Array.from(
asyncapi.servers.keys()
).map((key) => ({
name: key,
name: this.splitForWordBreaking(key),
href:
AsyncApiMapperService.BASE_URL +
asyncapi.servers.get(key)!.anchorIdentifier,
tags: [asyncapi.servers.get(key)!.protocol],
}));
newNavigation.push({
name: "Servers",
name: ["Servers"],
icon: "dns",
href: AsyncApiMapperService.BASE_URL + "servers",
children: servers,
});

const channels = {
name: "Channels & Operations",
name: ["Channels & Operations"],
icon: "swap_vert",
href: AsyncApiMapperService.BASE_URL + "channels",
children: [] as NavigationEntry[],
};
asyncapi.channels.forEach((value) => {
let children = value.operations.map((operation) => {
return {
name: operation.operation.message.title,
name: this.splitForWordBreaking(operation.operation.message.title),
href: AsyncApiMapperService.BASE_URL + operation.anchorIdentifier,
tags: [operation.operation.operationType],
};
Expand All @@ -87,7 +87,7 @@ export class SidenavComponent implements OnInit, AfterViewInit {
.flatMap((tags) => tags);

const channel = {
name: value.name,
name: this.splitForWordBreaking(value.name),
href: AsyncApiMapperService.BASE_URL + value.anchorIdentifier,
tags: Array.from(new Set(tags)).sort(),
children: children,
Expand All @@ -98,14 +98,14 @@ export class SidenavComponent implements OnInit, AfterViewInit {
newNavigation.push(channels);

const schemas = {
name: "Schemas",
name: ["Schemas"],
icon: "schema",
href: AsyncApiMapperService.BASE_URL + "schemas",
children: [] as NavigationEntry[],
};
asyncapi.components.schemas.forEach((value) => {
schemas.children.push({
name: value.title,
name: this.splitForWordBreaking(value.title),
href: AsyncApiMapperService.BASE_URL + "" + value.anchorIdentifier,
});
});
Expand All @@ -117,6 +117,11 @@ export class SidenavComponent implements OnInit, AfterViewInit {
});
}

private splitForWordBreaking = (text: string) => {
// Split by set of characters, but keep separators
return text.split(/(?<=[.,-_/])/);
};

ngAfterViewInit() {
this.scrollableElement.nativeElement.addEventListener(
"scroll",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0 */
.schema {
font-weight: 500;
width: 100%;
}

.key {
Expand All @@ -23,6 +24,7 @@
.example {
color: #6b6b6b;
font-style: italic;
word-break: break-word;
}

.description {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
<app-json [data]="schema().example?.rawValue"></app-json>
</div>
<p>Properties</p>
<!-- Primitive types -->
<ng-container
*ngIf="schema().type !== 'object'"
[ngTemplateOutlet]="valueContent"
[ngTemplateOutletContext]="{ value: schema() }"
>
</ng-container>
<table class="schema">
<tbody>
<!-- Primitive types -->
<tr *ngIf="schema().type !== 'object'">
<ng-container
[ngTemplateOutlet]="valueContent"
[ngTemplateOutletContext]="{ value: schema() }"
>
</ng-container>
</tr>
<!-- Objects -->
<tr *ngFor="let property of schema().properties || {} | keyvalue">
<td class="key">
Expand Down
7 changes: 6 additions & 1 deletion springwolf-ui/src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ body {
}

a {
word-break: break-all;
overflow-wrap: break-word;
word-break: break-word;
max-width: 100%;
}

Expand Down Expand Up @@ -227,6 +228,10 @@ a {
}
}

.mat-icon {
vertical-align: middle;
}

html {
--springwolf-badge-color-send: black;
--springwolf-badge-color-background-send: #ffd580;
Expand Down