Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Responsive button label font size

Chocobozzzc18c51ce1454
diff --git a/client/src/app/menu/menu.component.html b/client/src/app/menu/menu.component.html
index 65c096b78e..5fdc6b438b 100644
--- a/client/src/app/menu/menu.component.html
+++ b/client/src/app/menu/menu.component.html
@@ -1,13 +1,13 @@
<ng-template #moreInfoButton>
<div class="more-info-btn-container">
<a
- class="more-info-btn peertube-button-link peertube-button-icon mt-2 d-block ellipsis" [ngClass]="{ 'icon-only': collapsed }"
+ class="more-info-btn peertube-button-link peertube-button-icon mt-2 d-block ellipsis" [ngClass]="{ 'icon-only': collapsed, 'label-xl': moreInfoLabel.length > 10 }"
routerLink="/about" i18n-title title="More info" routerLinkActive="active"
>
<my-global-icon iconName="help"></my-global-icon>
@if (!collapsed) {
- <ng-container i18n>More info</ng-container>
+ {{ moreInfoLabel }}
}
</a>
</div>
diff --git a/client/src/app/menu/menu.component.scss b/client/src/app/menu/menu.component.scss
index 1943e28f50..b95285603a 100644
--- a/client/src/app/menu/menu.component.scss
+++ b/client/src/app/menu/menu.component.scss
@@ -166,7 +166,12 @@
$active-bg: pvar(--menu-bg-600),
$hover-bg: pvar(--menu-bg-550),
$border-color: pvar(--menu-bg-600)
- )
+ );
+
+ &.label-xl {
+ font-size: 90%;
+ padding: pvar(--input-y-padding) calc(#{pvar(--input-x-padding)} / 2) !important;
+ }
}
.more-info-btn,
diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts
index 20b9754d75..0b8748f75e 100644
--- a/client/src/app/menu/menu.component.ts
+++ b/client/src/app/menu/menu.component.ts
@@ -65,6 +65,7 @@ export class MenuComponent implements OnInit, OnDestroy {
menuSections: MenuSection[] = []
loggedIn: boolean
+ moreInfoLabel = $localize`More info`
private user: AuthUser
private canSeeVideoMakerBlock: boolean
diff --git a/client/src/app/shared/shared-main/buttons/button.component.scss b/client/src/app/shared/shared-main/buttons/button.component.scss
index d448eec171..b2b325b3de 100644
--- a/client/src/app/shared/shared-main/buttons/button.component.scss
+++ b/client/src/app/shared/shared-main/buttons/button.component.scss
@@ -2,6 +2,16 @@
@use '_mixins' as *;
@use '_button-mixins' as *;
+@mixin reduced-padding {
+ padding: pvar(--input-y-padding) calc(#{pvar(--input-x-padding)} / 2) !important;
+}
+
+@mixin hide-label {
+ .button-label {
+ display: none;
+ }
+}
+
:host {
display: inline-block;
}
@@ -23,27 +33,17 @@
@include button-with-icon(24px, 0);
}
}
-}
-
-@mixin responsive-label {
- .action-button {
- padding: pvar(--input-y-padding) 8px !important;
- }
- .button-label {
- display: none;
- }
-}
+ &.label-xl {
+ font-size: 90%;
-// In a table, try to minimize the space taken by this button
-@media screen and (max-width: 1400px) {
- :host-context(td) {
- @include responsive-label;
+ @include reduced-padding();
}
}
@media screen and (max-width: $small-view) {
.responsive-label {
- @include responsive-label;
+ @include hide-label();
+ @include reduced-padding();
}
}
diff --git a/client/src/app/shared/shared-main/buttons/button.component.ts b/client/src/app/shared/shared-main/buttons/button.component.ts
index cdabbc1e59..6bd9c50320 100644
--- a/client/src/app/shared/shared-main/buttons/button.component.ts
+++ b/client/src/app/shared/shared-main/buttons/button.component.ts
@@ -58,6 +58,7 @@ export class ButtonComponent implements OnChanges, AfterViewInit {
readonly loading = input(false, { transform: booleanAttribute })
readonly disabled = input(false, { transform: booleanAttribute })
readonly responsiveLabel = input(false, { transform: booleanAttribute })
+ readonly autoFontSize = input(false, { transform: booleanAttribute })
readonly rounded = input(false, { transform: booleanAttribute })
readonly labelContent = viewChild<ElementRef>('labelContent')
@@ -74,6 +75,7 @@ export class ButtonComponent implements OnChanges, AfterViewInit {
private buildClasses () {
const isButtonLink = !!this.ptRouterLink() || !!this.href()
+ const label = this.getLabel() || ''
this.classes = {
'active': this.active(),
@@ -84,12 +86,17 @@ export class ButtonComponent implements OnChanges, AfterViewInit {
'tertiary-button': this.theme() === 'tertiary',
'has-icon': !!this.icon(),
'rounded-icon-button': !!this.rounded(),
- 'icon-only': !this.label() && !(this.labelContent()?.nativeElement as HTMLElement)?.innerText,
+ 'icon-only': !label,
+ 'label-xl': this.autoFontSize() && label.length > 10,
'responsive-label': this.responsiveLabel()
}
- debugLogger('Built button classes', { classes: this.classes, labelContent: this.labelContent() })
+ debugLogger('Built button classes', { classes: this.classes, label, labelContent: this.labelContent() })
this.cd.markForCheck()
}
+
+ private getLabel () {
+ return this.label() || (this.labelContent()?.nativeElement as HTMLElement)?.innerText
+ }
}