Skip to content

Commit 5f93db7

Browse files
committed
refactor: augmenting native element :)
1 parent fd40093 commit 5f93db7

File tree

7 files changed

+32
-55
lines changed

7 files changed

+32
-55
lines changed

src/app/components/github/github.component.html

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,35 @@
33
<div class="hint">
44
Scan QR code to play with a mobile phone
55
</div>
6-
<img atl="QR Code to play on mobile"
7-
src="https://res.cloudinary.com/dvujyxh7e/image/upload/v1595380432/angular-tetris-qr-code-no-text.png" />
6+
<img atl="QR Code to play on mobile" src="https://res.cloudinary.com/dvujyxh7e/image/upload/v1595380432/angular-tetris-qr-code-no-text.png" />
87
</div>
9-
<div class="tweet-button top"
10-
*ngIf="max$ | async as maxPoint">
11-
<t-twitter-button [url]="getTweetMaxScoreShareUrl(maxPoint)"
12-
(click)="sendTwitterShareMaxScoreEvent()">
8+
<div class="tweet-button top" *ngIf="max$ | async as maxPoint">
9+
<a t-shared-button [href]="getTweetMaxScoreShareUrl(maxPoint)" (click)="sendTwitterShareMaxScoreEvent()">
1310
Share Your Score - {{ maxPoint }}
14-
</t-twitter-button>
11+
</a>
1512
</div>
1613
<div class="tweet-button" title="This is one of my favorite project!">
17-
<t-twitter-button [showIcon]="false"
18-
[url]="'https://github.com/trungk18/angular-spotify'">
14+
<a t-shared-button [showIcon]="false" [href]="'https://github.com/trungk18/angular-spotify'">
1915
🎧 Angular Spotify
20-
</t-twitter-button>
16+
</a>
2117
</div>
2218
<div class="tweet-button" title="This is one of my favorite project!">
23-
<t-twitter-button [showIcon]="false"
24-
[url]="'https://jira.trungk18.com/'">
19+
<a t-shared-button [showIcon]="false" [href]="'https://jira.trungk18.com/'">
2520
🔨 Angular Jira Clone
26-
</t-twitter-button>
21+
</a>
2722
</div>
2823
<div class="tweet-button" title="Thanks for your support!">
29-
<t-twitter-button [showIcon]="false"
30-
[url]="'https://www.buymeacoffee.com/tuantrungvo'">
24+
<a t-shared-button [showIcon]="false" [href]="'https://www.buymeacoffee.com/tuantrungvo'">
3125
🍺 Buy me a beer
32-
</t-twitter-button>
26+
</a>
3327
</div>
3428
<div class="tweet-button" style="margin-top: 2px;">
35-
<t-twitter-button [url]="tweetAngularTetrisUrl"
36-
(click)="sendTwitterShareEvent()">
29+
<a t-shared-button [href]="tweetAngularTetrisUrl" (click)="sendTwitterShareEvent()">
3730
Tweet
38-
</t-twitter-button>
31+
</a>
3932
</div>
4033
<div class="star-button">
41-
<iframe src="https://ghbtns.com/github-btn.html?user=trungk18&repo=angular-tetris&type=star&count=true&size=large"
42-
frameborder="0"
43-
scrolling="0"
44-
width="170"
45-
height="30"
46-
title="Angular Tetris Star">
34+
<iframe src="https://ghbtns.com/github-btn.html?user=trungk18&repo=angular-tetris&type=star&count=true&size=large" frameborder="0" scrolling="0" width="170" height="30" title="Angular Tetris Star">
4735
</iframe>
4836
</div>
4937
</div>

src/app/components/github/github.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { AsyncPipe, NgIf } from '@angular/common';
22
import { Component } from '@angular/core';
33
import { GoogleAnalyticsService } from '@trungk18/services/google-analytics.service';
44
import { TetrisQuery } from '@trungk18/state/tetris/tetris.query';
5-
import { TwitterButtonComponent } from '../twitter-button/twitter-button.component';
5+
import { SharedButtonComponent } from '../shared-button/shared-button.component';
66
const HASHTAG = 'angular,angulartetris,akita,typescript';
77

88
@Component({
99
selector: 't-github',
1010
standalone: true,
11-
imports: [TwitterButtonComponent, AsyncPipe, NgIf],
11+
imports: [SharedButtonComponent, AsyncPipe, NgIf],
1212
templateUrl: './github.component.html',
1313
styleUrls: ['./github.component.scss']
1414
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<svg *ngIf="showIcon" class="icon" style="enable-background:new 0 0 512 512;" version="1.1" viewBox="0 0 512 512" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2+
<path d="M196.9,462C317.2,462,383,362.3,383,275.9c0-2.8,0-5.6-0.2-8.5c12.8-9.3,23.8-20.7,32.6-33.9 c-11.9,5.3-24.6,8.8-37.6,10.3c13.7-8.2,23.9-21,28.8-36.2c-12.8,7.6-26.9,13-41.5,15.9c-24.8-26.3-66.2-27.6-92.5-2.8 c-17,16-24.2,39.8-18.9,62.5c-52.6-2.6-101.6-27.5-134.8-68.3c-17.4,29.9-8.5,68.1,20.2,87.3c-10.4-0.3-20.6-3.1-29.7-8.2 c0,0.3,0,0.5,0,0.8c0,31.1,22,57.9,52.5,64.1c-9.6,2.6-19.7,3-29.5,1.1c8.6,26.6,33.1,44.9,61.1,45.4 c-23.2,18.2-51.8,28.1-81.2,28.1c-5.2,0-10.4-0.3-15.6-0.9C126.5,451.8,161.3,462,196.9,462" id="XMLID_22_" />
3+
</svg>
4+
<ng-content></ng-content>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Component, HostBinding, Input, ViewEncapsulation } from '@angular/core';
2+
3+
@Component({
4+
selector: '[t-shared-button]',//eslint-disable-line
5+
standalone: true,
6+
templateUrl: './shared-button.component.html',
7+
styleUrls: ['./shared-button.component.scss'],
8+
encapsulation: ViewEncapsulation.None
9+
})
10+
export class SharedButtonComponent {
11+
@HostBinding('class') className = 'twitter-button';
12+
@Input() showIcon = true;
13+
}

src/app/components/twitter-button/twitter-button.component.html

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/app/components/twitter-button/twitter-button.component.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)