Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit b5c74db

Browse files
Merge pull request #276 from deckgo/nav-deck-name
feat(#248): display deck name in title while editing a presentation
2 parents 5d1e211 + 153befc commit b5c74db

File tree

2 files changed

+176
-100
lines changed

2 files changed

+176
-100
lines changed

studio/src/app/components/core/app-navigation/app-navigation.scss

Lines changed: 71 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,71 @@ app-navigation {
66
}
77
}
88

9-
ion-router-link {
10-
color: black;
9+
div.title {
10+
display: flex;
11+
justify-content: flex-start;
12+
align-items: center;
1113

12-
&:hover, &:active {
13-
color: black;
14+
ion-label {
15+
font-weight: 400;
1416
}
1517

16-
div mark {
17-
color: black;
18+
ion-label.deck-name {
19+
transition: opacity 1s;
20+
21+
visibility: hidden;
22+
opacity: 0;
23+
24+
text-overflow: ellipsis;
25+
white-space: nowrap;
26+
overflow: hidden;
27+
width: 100%;
28+
29+
user-select: none;
1830
}
1931

20-
div {
21-
display: flex;
22-
align-items: center;
32+
&.deck-name-visible {
33+
ion-label.deck-name {
34+
visibility: initial;
35+
opacity: 1;
36+
}
2337

24-
margin-left: 8px;
38+
ion-router-link.home ion-label {
39+
display: none;
40+
}
41+
}
42+
43+
ion-router-link {
44+
color: black;
2545

26-
app-logo {
27-
margin-right: 4px;
28-
padding: 4px;
46+
&:hover, &:active {
47+
color: black;
48+
border-bottom-color: transparent;
2949
}
3050

31-
mark {
32-
background-color: transparent;
33-
font-style: italic;
34-
color: inherit;
35-
font-size: calc(var(--font-size-small) * 0.9);
51+
> div {
52+
display: flex;
53+
align-items: center;
54+
55+
margin-left: 8px;
56+
57+
app-logo {
58+
margin-right: 4px;
59+
padding: 4px;
60+
}
61+
62+
ion-label {
63+
display: flex;
64+
align-items: baseline;
65+
66+
mark {
67+
background-color: transparent;
68+
font-style: italic;
69+
color: inherit;
70+
font-size: calc(var(--font-size-small) * 0.9);
71+
margin-left: 2px;
72+
}
73+
}
3674
}
3775
}
3876
}
@@ -44,30 +82,34 @@ app-navigation {
4482

4583
@media (prefers-color-scheme: dark) {
4684
app-navigation {
47-
ion-router-link {
85+
div.title {
4886
color: white;
4987

50-
&:hover, &:active {
51-
color: white;
52-
}
53-
54-
div mark {
88+
ion-router-link {
5589
color: white;
56-
}
5790

58-
&:hover, &:active {
59-
border-bottom: 1px solid transparent;
91+
&:hover, &:active {
92+
color: white;
93+
}
6094
}
6195
}
6296
}
6397
}
6498

6599
@media screen and (max-width: 720px) {
66100
ion-nav {
67-
app-navigation {
68-
ion-router-link.logo {
101+
div.title {
102+
ion-label.deck-name, ion-router-link.home ion-label {
69103
display: none;
70104
}
71105
}
72106
}
73107
}
108+
109+
@media screen and (max-width: 540px) {
110+
ion-nav {
111+
div.title {
112+
display: none;
113+
}
114+
}
115+
}
Lines changed: 105 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,113 @@
1-
import {Component, Prop, h} from '@stencil/core';
1+
import {Component, Prop, h, State} from '@stencil/core';
2+
3+
import {Subscription} from 'rxjs';
4+
5+
import {DeckEditorService} from '../../../services/editor/deck/deck-editor.service';
6+
import {Deck} from '../../../models/data/deck';
27

38
@Component({
4-
tag: 'app-navigation',
5-
styleUrl: 'app-navigation.scss',
6-
shadow: false
9+
tag: 'app-navigation',
10+
styleUrl: 'app-navigation.scss',
11+
shadow: false
712
})
813
export class AppNavigation {
9-
@Prop() menuToggle: boolean = true;
10-
11-
@Prop() user: boolean = true;
12-
13-
@Prop() presentation: boolean = false;
14-
@Prop() publish: boolean = false;
15-
16-
render() {
17-
return (<ion-header>
18-
<ion-toolbar>
19-
{this.renderLogo()}
20-
{this.renderMenuToggle()}
21-
{this.renderUser()}
22-
</ion-toolbar>
23-
</ion-header>
24-
);
25-
}
26-
27-
private renderLogo() {
28-
return <ion-router-link onClick={() => this.closeMenu()} href="/" routerDirection="forward" class="logo">
29-
<div>
30-
<app-logo></app-logo>
31-
<span class="ion-text-uppercase">DeckDeckGo <mark>BETA</mark></span>
32-
</div>
33-
</ion-router-link>;
34-
}
35-
36-
private closeMenu(): Promise<void> {
37-
return new Promise<void>(async (resolve) => {
38-
if (!document) {
39-
return;
40-
}
41-
42-
const element: HTMLIonMenuElement = document.querySelector('ion-menu');
43-
44-
if (!element) {
45-
resolve();
46-
return;
47-
}
48-
49-
await element.close();
50-
51-
resolve();
52-
});
53-
}
54-
55-
private renderMenuToggle() {
56-
if (this.menuToggle) {
57-
return <ion-buttons slot="start">
58-
<ion-menu-toggle>
59-
<ion-button>
60-
<ion-icon slot="icon-only" name="menu"></ion-icon>
61-
</ion-button>
62-
</ion-menu-toggle>
63-
</ion-buttons>;
64-
} else {
65-
return null;
14+
@Prop() menuToggle: boolean = true;
15+
16+
@Prop() user: boolean = true;
17+
18+
@Prop() presentation: boolean = false;
19+
@Prop() publish: boolean = false;
20+
21+
private subscription: Subscription;
22+
private deckEditorService: DeckEditorService;
23+
24+
@State()
25+
private deckName: string = null;
26+
27+
constructor() {
28+
this.deckEditorService = DeckEditorService.getInstance();
29+
}
30+
31+
componentWillLoad() {
32+
this.subscription = this.deckEditorService.watch().subscribe((deck: Deck) => {
33+
this.deckName = deck && deck.data && deck.data.name && deck.data.name !== '' ? deck.data.name : null;
34+
});
35+
}
36+
37+
componentDidUnload() {
38+
if (this.subscription) {
39+
this.subscription.unsubscribe();
40+
}
41+
}
42+
43+
render() {
44+
return (<ion-header>
45+
<ion-toolbar>
46+
{this.renderTitle()}
47+
{this.renderMenuToggle()}
48+
{this.renderUser()}
49+
</ion-toolbar>
50+
</ion-header>
51+
);
6652
}
67-
}
68-
69-
private renderUser() {
70-
if (this.user) {
71-
return <div slot="end">
72-
<app-navigation-actions presentation={this.presentation} publish={this.publish}></app-navigation-actions>
73-
</div>;
74-
} else {
75-
return null;
53+
54+
private renderTitle() {
55+
const titleClass = this.deckName && this.deckName !== '' ? 'title deck-name-visible' : 'title';
56+
57+
return <div class={titleClass}>
58+
<ion-router-link onClick={() => this.closeMenu()} href="/" routerDirection="forward" class="home">
59+
<div>
60+
<app-logo></app-logo>
61+
<ion-label class="ion-text-uppercase">DeckDeckGo <mark>BETA</mark></ion-label>
62+
</div>
63+
</ion-router-link>
64+
65+
<ion-label class="ion-text-uppercase deck-name">{this.deckName}</ion-label>
66+
</div>
67+
}
68+
69+
private closeMenu(): Promise<void> {
70+
return new Promise<void>(async (resolve) => {
71+
if (!document) {
72+
return;
73+
}
74+
75+
const element: HTMLIonMenuElement = document.querySelector('ion-menu');
76+
77+
if (!element) {
78+
resolve();
79+
return;
80+
}
81+
82+
await element.close();
83+
84+
resolve();
85+
});
86+
}
87+
88+
private renderMenuToggle() {
89+
if (this.menuToggle) {
90+
return <ion-buttons slot="start">
91+
<ion-menu-toggle>
92+
<ion-button>
93+
<ion-icon slot="icon-only" name="menu"></ion-icon>
94+
</ion-button>
95+
</ion-menu-toggle>
96+
</ion-buttons>;
97+
} else {
98+
return null;
99+
}
100+
}
101+
102+
private renderUser() {
103+
if (this.user) {
104+
return <div slot="end">
105+
<app-navigation-actions presentation={this.presentation}
106+
publish={this.publish}></app-navigation-actions>
107+
</div>;
108+
} else {
109+
return null;
110+
}
76111
}
77-
}
78112

79113
}

0 commit comments

Comments
 (0)