Refactor my-button component
This commit is contained in:
parent
275ba643eb
commit
bfdf82c490
|
@ -32,7 +32,7 @@
|
||||||
<ng-template pTemplate="caption">
|
<ng-template pTemplate="caption">
|
||||||
<div class="caption">
|
<div class="caption">
|
||||||
<div class="left-buttons">
|
<div class="left-buttons">
|
||||||
<my-button className="orange-button" i18n-label label="Generate token" icon="add" (click)="generateToken()"></my-button>
|
<my-button theme="orange" i18n-label label="Generate token" icon="add" (click)="generateToken()"></my-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
<ng-container *ngIf="!twoFactorEnabled">
|
<ng-container *ngIf="!twoFactorEnabled">
|
||||||
<p i18n>Two factor authentication adds an additional layer of security to your account by requiring a numeric code from another device (most commonly mobile phones) when you log in.</p>
|
<p i18n>Two factor authentication adds an additional layer of security to your account by requiring a numeric code from another device (most commonly mobile phones) when you log in.</p>
|
||||||
|
|
||||||
<my-button [ptRouterLink]="[ '/my-account/two-factor-auth' ]" className="orange-button-link" i18n>Enable two-factor authentication</my-button>
|
<my-button [ptRouterLink]="[ '/my-account/two-factor-auth' ]" theme="orange" i18n>Enable two-factor authentication</my-button>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngIf="twoFactorEnabled">
|
<ng-container *ngIf="twoFactorEnabled">
|
||||||
<my-button className="orange-button" (click)="disableTwoFactor()" i18n>Disable two-factor authentication</my-button>
|
<my-button theme="orange" (click)="disableTwoFactor()" i18n>Disable two-factor authentication</my-button>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<my-button
|
<my-button
|
||||||
className="orange-button" i18n-label label="Run video edition" icon="circle-tick"
|
theme="orange" i18n-label label="Run video edition" icon="circle-tick"
|
||||||
(click)="runEdition()" (keydown.enter)="runEdition()"
|
(click)="runEdition()" (keydown.enter)="runEdition()"
|
||||||
[disabled]="!form.valid || isRunningEdition || noEdition()"
|
[disabled]="!form.valid || isRunningEdition || noEdition()"
|
||||||
></my-button>
|
></my-button>
|
||||||
|
|
|
@ -59,9 +59,9 @@
|
||||||
></my-video-edit>
|
></my-video-edit>
|
||||||
|
|
||||||
<div class="submit-container">
|
<div class="submit-container">
|
||||||
<my-button className="orange-button" i18n-label label="Update" icon="circle-tick"
|
<my-button
|
||||||
(click)="updateSecondStep()"
|
theme="orange" i18n-label label="Update" icon="circle-tick"
|
||||||
[disabled]="!form.valid || isUpdatingVideo === true"
|
(click)="updateSecondStep()" [disabled]="!form.valid || isUpdatingVideo === true"
|
||||||
></my-button>
|
></my-button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -65,8 +65,8 @@
|
||||||
></my-video-edit>
|
></my-video-edit>
|
||||||
|
|
||||||
<div class="submit-container">
|
<div class="submit-container">
|
||||||
<my-button className="orange-button" i18n-label label="Update" icon="circle-tick"
|
<my-button
|
||||||
(click)="updateSecondStep()"
|
theme="orange" i18n-label label="Update" icon="circle-tick" (click)="updateSecondStep()"
|
||||||
[disabled]="!form.valid || isUpdatingVideo === true"
|
[disabled]="!form.valid || isUpdatingVideo === true"
|
||||||
></my-button>
|
></my-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -63,8 +63,8 @@
|
||||||
></my-video-edit>
|
></my-video-edit>
|
||||||
|
|
||||||
<div class="submit-container">
|
<div class="submit-container">
|
||||||
<my-button className="orange-button" i18n-label label="Update" icon="circle-tick"
|
<my-button
|
||||||
(click)="updateSecondStep()"
|
theme="orange" i18n-label label="Update" icon="circle-tick" (click)="updateSecondStep()"
|
||||||
[disabled]="!form.valid || isUpdatingVideo === true"
|
[disabled]="!form.valid || isUpdatingVideo === true"
|
||||||
></my-button>
|
></my-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -46,13 +46,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group upload-audio-button">
|
<div class="form-group upload-audio-button">
|
||||||
<my-button
|
<my-button theme="orange" [label]="getAudioUploadLabel()" icon="upload" (click)="uploadAudio()"></my-button>
|
||||||
className="orange-button"
|
|
||||||
[label]="getAudioUploadLabel()"
|
|
||||||
icon="upload"
|
|
||||||
(click)="uploadAudio()"
|
|
||||||
>
|
|
||||||
</my-button>
|
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
|
@ -80,9 +74,9 @@
|
||||||
<div class="submit-container">
|
<div class="submit-container">
|
||||||
<div i18n *ngIf="videoUploaded === false" class="message-submit">Publish will be available when upload is finished</div>
|
<div i18n *ngIf="videoUploaded === false" class="message-submit">Publish will be available when upload is finished</div>
|
||||||
|
|
||||||
<my-button className="orange-button" i18n-label label="Publish" icon="circle-tick"
|
<my-button
|
||||||
(click)="updateSecondStep()" (keydown.enter)="updateSecondStep()"
|
theme="orange" i18n-label label="Publish" icon="circle-tick"
|
||||||
[disabled]="isPublishingButtonDisabled()"
|
(click)="updateSecondStep()" (keydown.enter)="updateSecondStep()" [disabled]="isPublishingButtonDisabled()"
|
||||||
></my-button>
|
></my-button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -42,9 +42,9 @@
|
||||||
</my-video-edit>
|
</my-video-edit>
|
||||||
|
|
||||||
<div class="submit-container">
|
<div class="submit-container">
|
||||||
<my-button className="orange-button" i18n-label label="Update" icon="circle-tick"
|
<my-button
|
||||||
(click)="update()" (keydown.enter)="update()"
|
theme="orange" i18n-label label="Update" icon="circle-tick" (click)="update()" (keydown.enter)="update()"
|
||||||
[disabled]="!form.valid || isUpdatingVideo === true"
|
[disabled]="!form.valid || isUpdatingVideo === true"
|
||||||
></my-button>
|
></my-button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -46,26 +46,6 @@ span[class$=-button] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.orange-button,
|
|
||||||
.grey-button {
|
|
||||||
@include peertube-button;
|
|
||||||
}
|
|
||||||
|
|
||||||
.orange-button-link,
|
|
||||||
.grey-button-link {
|
|
||||||
@include peertube-button-link;
|
|
||||||
}
|
|
||||||
|
|
||||||
.orange-button,
|
|
||||||
.orange-button-link {
|
|
||||||
@include orange-button;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grey-button,
|
|
||||||
.grey-button-link {
|
|
||||||
@include grey-button;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button-label {
|
.button-label {
|
||||||
@include ellipsis;
|
@include ellipsis;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit } from '@angular/core'
|
import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit, booleanAttribute } from '@angular/core'
|
||||||
import { GlobalIconName } from '@app/shared/shared-icons'
|
import { GlobalIconName } from '@app/shared/shared-icons'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -10,13 +10,13 @@ import { GlobalIconName } from '@app/shared/shared-icons'
|
||||||
|
|
||||||
export class ButtonComponent implements OnInit, OnChanges {
|
export class ButtonComponent implements OnInit, OnChanges {
|
||||||
@Input() label = ''
|
@Input() label = ''
|
||||||
@Input() className = 'grey-button'
|
@Input() theme: 'orange' | 'grey' = 'grey'
|
||||||
@Input() icon: GlobalIconName = undefined
|
@Input() icon: GlobalIconName
|
||||||
@Input() ptRouterLink: string[] | string
|
@Input() ptRouterLink: string[] | string
|
||||||
@Input() title: string = undefined
|
@Input() title: string
|
||||||
@Input() loading = false
|
@Input({ transform: booleanAttribute }) loading = false
|
||||||
@Input() disabled = false
|
@Input({ transform: booleanAttribute }) disabled = false
|
||||||
@Input() responsiveLabel = false
|
@Input({ transform: booleanAttribute }) responsiveLabel = false
|
||||||
|
|
||||||
classes: { [id: string]: boolean } = {}
|
classes: { [id: string]: boolean } = {}
|
||||||
|
|
||||||
|
@ -30,7 +30,10 @@ export class ButtonComponent implements OnInit, OnChanges {
|
||||||
|
|
||||||
private buildClasses () {
|
private buildClasses () {
|
||||||
this.classes = {
|
this.classes = {
|
||||||
[this.className]: true,
|
'peertube-button': !this.ptRouterLink,
|
||||||
|
'peertube-button-link': !!this.ptRouterLink,
|
||||||
|
'orange-button': this.theme === 'orange',
|
||||||
|
'grey-button': this.theme === 'grey',
|
||||||
'disabled': this.disabled,
|
'disabled': this.disabled,
|
||||||
'icon-only': !this.label,
|
'icon-only': !this.label,
|
||||||
'has-icon': !!this.icon,
|
'has-icon': !!this.icon,
|
||||||
|
|
|
@ -4,8 +4,7 @@ import { Component, Input, OnInit } from '@angular/core'
|
||||||
selector: 'my-edit-button',
|
selector: 'my-edit-button',
|
||||||
template: `
|
template: `
|
||||||
<my-button
|
<my-button
|
||||||
icon="edit" className="grey-button-link"
|
icon="edit" [label]="label" [title]="title" [responsiveLabel]="responsiveLabel"
|
||||||
[label]="label" [title]="title" [responsiveLabel]="responsiveLabel"
|
|
||||||
[ptRouterLink]="ptRouterLink"
|
[ptRouterLink]="ptRouterLink"
|
||||||
></my-button>
|
></my-button>
|
||||||
`
|
`
|
||||||
|
|
Loading…
Reference in New Issue