creation of a presentation component to handle accounts listing

This commit is contained in:
Nicolas Constant 2018-09-09 02:38:59 -04:00
parent 0325b5bfbe
commit 4415a9d6be
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
7 changed files with 88 additions and 8 deletions

View File

@ -23,6 +23,7 @@ import { StreamsService } from "./services/streams.service";
import { StreamingService } from "./services/streaming.service";
import { RegisteredAppsState } from "./states/registered-apps.state";
import { AccountsState } from "./states/accounts.state";
import { AccountIconComponent } from './components/left-side-bar/presentation/account-icon/account-icon.component';
const routes: Routes = [
{ path: "", redirectTo: "home", pathMatch: "full" },
@ -39,7 +40,8 @@ const routes: Routes = [
StreamComponent,
StreamsSelectionFooterComponent,
TootComponent,
RegisterNewAccountComponent
RegisterNewAccountComponent,
AccountIconComponent
],
imports: [
BrowserModule,

View File

@ -3,10 +3,14 @@
<a href title="write toot!" (click)="createNewToot()">Toot!</a>
</div>
<div *ngFor="let account of accounts" class="mam-account-selector">
<a href title="{{ account.username }}" (click)="toogleAccount(account.id)"><img src="{{ account.avatar }}" /></a>
<div *ngFor="let account of accounts" >
<app-account-icon [account]="account" ></app-account-icon>
<!-- <a href title="{{ account.username }}" (click)="toogleAccount(account.id)"><img src="{{ account.avatar }}" /></a> -->
</div>
<div id="mam-account-add">
<a href title="add new account" [routerLink]="['/register']">+</a>
</div>

View File

@ -50,10 +50,6 @@ export class LeftSideBarComponent implements OnInit, OnDestroy {
this.sub.unsubscribe();
}
toogleAccount(accountId: number): boolean {
return false;
}
addNewAccount(): boolean {
return false;
}

View File

@ -0,0 +1,3 @@
<a class="account-icon" href title="{{ account.username }}" (click)="toogleAccount()" (contextmenu)="openMenu()">
<img class="account-icon__avatar" src="{{ account.avatar }}" />
</a>

View File

@ -0,0 +1,21 @@
.account-icon {
display: inline-block;
width: 50px;
padding-top: 4px;
// margin-left: 5px;
margin: 0 0 5px 5px;
&__avatar {
border-radius: 50%;
width: 40px;
}
// & a {
// margin-left: 4px;
// /*margin-top: 4px;*/
// }
// & img {
// width: 40px;
// border-radius: 50%;
// }
}

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AccountIconComponent } from './account-icon.component';
describe('AccountIconComponent', () => {
let component: AccountIconComponent;
let fixture: ComponentFixture<AccountIconComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AccountIconComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AccountIconComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,29 @@
import { Component, OnInit, Input } from '@angular/core';
import { AccountInfo } from '../../../../states/accounts.state';
import { AccountsService } from '../../../../services/accounts.service';
import { AccountWrapper } from '../../../../models/account.models';
import { Account } from "../../../../services/models/mastodon.interfaces";
@Component({
selector: 'app-account-icon',
templateUrl: './account-icon.component.html',
styleUrls: ['./account-icon.component.scss']
})
export class AccountIconComponent implements OnInit {
@Input() account: AccountWrapper;
constructor() { }
ngOnInit() {
}
toogleAccount(): boolean {
console.warn(`click`);
return false;
}
openMenu(event): boolean {
console.warn(`openMenu`);
return false;
}
}