Skip to content

Commit

Permalink
Merge pull request #5 from maxkarnold/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
maxkarnold authored Oct 27, 2021
2 parents 218eedf + fdf9ac9 commit ff52c64
Show file tree
Hide file tree
Showing 13 changed files with 660 additions and 248 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
## Tech Stack
* [Angular](https://angular.io/)
* [Angular-Material](https://material.angular.io/)
* [Angular-Material-CDK](https://material.angular.io/cdk/categories)
* [Firebase](https://firebase.google.com/docs)
* [Express](https://expressjs.com/)
* [Nodejs](https://nodejs.org/en/)
Expand Down Expand Up @@ -109,3 +110,14 @@ Then deploy to the website with firebase in the terminal.
```
firebase deploy
```

## CSS Styling Guide

We use BEM methodology for all CSS files. Please refer to this [reference site](https://en.bem.info/methodology/key-concepts/) for help. For this project, we have some specific rules to follow over the BEM standards.

* Blocks can be contained within other blocks.
* Blocks can be modified just like elements using a class like: `block--modifier`.
* The class name of elements within elements should be added on. `element__element__element`.
* Some styles will have to be overwritten with `mat` or `cdk` classes.
* Global styles should only be implemented in `styles.scss`.
* Don't add class names to `ng-container`, `ng-template` and other specialized html tags unless necessary.
6 changes: 3 additions & 3 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
"src/assets/img"
],
"styles": [
"./src/styles.scss",
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"./node_modules/font-awesome/css/font-awesome.css",
"./node_modules/materialize-css/dist/css/materialize.css"
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"./node_modules/materialize-css/dist/css/materialize.css",
"./src/styles.scss"
],
"scripts": [
"./node_modules/jquery/dist/jquery.js",
Expand Down
54 changes: 30 additions & 24 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
<header class="mobile">
<mat-toolbar color="primary">
<a routerLink="/"><span>National Team Generator</span></a>
<span class="nav-spacer"></span>
<button mat-icon-button class="example-icon" aria-label="Example icon-button with menu icon" (click)="navToggle = !navToggle" >
<mat-icon>menu</mat-icon>
<header class="header header--mobile">
<mat-toolbar color="primary" class="nav-bar">
<a routerLink="/" class="logo logo--ripple">
<span class="logo__title">National Team Generator</span>
</a>
<span class="nav-bar__nav-spacer"></span>
<button mat-icon-button class="nav-bar__menu-button nav-bar__menu-button--ripple" aria-label="Example icon-button with menu icon" (click)="navToggle = !navToggle" >
<mat-icon class="nav-bar__menu-button__icon">menu</mat-icon>
</button>
</mat-toolbar>
<mat-nav-list class="primaryColorBG list" role="list" *ngIf="navToggle">
<a mat-list-item routerLink="/leaderboard" class="nav-item full">Leaderboards</a>
<a mat-list-item href="#" class="nav-item full" (click)="loginOverlay()" *ngIf="!isLoggedIn" cdkOverlayOrigin #trigger="cdkOverlayOrigin">Login</a>
<a mat-list-item href="#" class="nav-item full" (click)="logout()" *ngIf="isLoggedIn">Logout</a>
<mat-nav-list class="nav-list" role="list" *ngIf="navToggle">
<a routerLink="/leaderboard" class="nav-list__link nav-list__link--ripple">Leaderboards</a>
<a class="nav-list__link nav-list__link--ripple" (click)="loginOverlay()" *ngIf="!isLoggedIn" cdkOverlayOrigin #trigger="cdkOverlayOrigin">Login</a>
<a class="nav-list__link nav-list__link--ripple" (click)="logout()" *ngIf="isLoggedIn">Logout</a>
</mat-nav-list>
</header>
<header class="desktop">
<mat-toolbar color="primary">
<a routerLink="/"><span>National Team Generator</span></a>
<span class="nav-spacer"></span>
<a mat-list-item routerLink="/leaderboard" class="nav-item">Leaderboards</a>
<button (click)="loginOverlay()" *ngIf="!isLoggedIn"><span>Login</span></button>
<a href="#" (click)="logout()" *ngIf="isLoggedIn"><span>Logout</span></a>
<header class="header header--desktop">
<mat-toolbar color="primary" class="nav-bar">
<a routerLink="/" class="logo logo--ripple">
<span class="logo__title">National Team Generator</span>
</a>
<span class="nav-bar__nav-spacer"></span>
<a routerLink="/leaderboard" class="nav-bar__link nav-bar__link--ripple">Leaderboards</a>
<a (click)="loginOverlay()" *ngIf="!isLoggedIn" class="nav-bar__link nav-bar__link--ripple">Login</a>
<a (click)="logout()" *ngIf="isLoggedIn" class="nav-bar__link nav-bar__link--ripple">Logout</a>
</mat-toolbar>
</header>
<ng-container *ngIf="loginOverlayOpen">
<div class="login-overlay">
<div class="exit-container">
<button mat-button (click)="loginOverlay()" ><mat-icon>close</mat-icon></button>
<ng-container *ngIf="loginOverlayOpen" class="ng-container">
<div class="login-overlay ng-container__login-overlay">
<div class="login-overlay__exit">
<button mat-button (click)="loginOverlay()" class="login-overlay__exit__button">
<mat-icon class="login-overlay__exit__button__icon">close</mat-icon>
</button>
</div>
<input type="text" #email placeholder="email">
<input type="password" #password placeholder="password">
<button mat-raised-button type="submit" (click)="login(email.value, password.value)" class="login-button">Login</button>
<input class="login-overlay__input login-overlay__input--override" type="text" #email placeholder="email">
<input class="login-overlay__input login-overlay__input--override" type="password" #password placeholder="password">
<button mat-raised-button type="submit" (click)="login(email.value, password.value)" class="login-overlay__button login-overlay__button--ripple">Login</button>
</div>
</ng-container>
<router-outlet></router-outlet>
193 changes: 124 additions & 69 deletions src/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -1,93 +1,148 @@
button {
cursor: pointer;
.header {
color: white;
background-color: #3F51B5;
&--desktop{
display: block;
@media screen and (max-width: 800px) { display: none; }
}
&--mobile {
display: none;
@media screen and (max-width: 800px) { display: block; }
}
}
.logo {
color: white;
display: flex;
align-items: center;
min-height: 100%;
padding: 0 1rem;
&--ripple {
background-position: center;
transition: background 0.8s;
&:hover {
background: rgb(70, 90, 183) radial-gradient(circle, transparent 1%, rgb(70, 90, 183) 1%) center/15000%;
}
&:active {
background-color: rgb(75, 100, 200);
background-size: 100%;
transition: background 0s;
}
}
}
.nav-bar {
&__menu-button {
&--ripple {
background-position: center;
transition: background 0.8s;
&:hover {
background: rgb(80, 110, 210) radial-gradient(circle, transparent 1%, rgb(80, 110, 210) 1%) center/15000%;
}
&:focus {
background-color: rgb(80, 110, 210);
background-size: 100%;
transition: background 0s;
}
}
}
&__nav-spacer {
flex: 1 1 auto;
}
&__link {
display: flex;
align-items: center;
min-height: 100%;
color: white;
padding: 0 1rem;
cursor: pointer;
&--ripple {
background-position: center;
transition: background 0.8s;
&:hover {
background: rgb(70, 90, 183) radial-gradient(circle, transparent 1%, rgb(70, 90, 183) 1%) center/15000%;
}
&:active {
background-color: rgb(75, 100, 200);
background-size: 100%;
transition: background 0s;
}
}
}
}
.nav-list {
display: flex;
flex-flow: column;
padding: 0;
&__link {
display: flex;
justify-content: center;
color: white;
border-top: 1px solid rgb(242, 242, 242, 0.25);
padding: 1rem 0;
transition: background-color 400ms;
background-color: rgb(63, 81, 181);
cursor: pointer;
&--ripple {
background-position: center;
transition: background 0.8s;
&:hover {
background: rgb(70, 90, 183) radial-gradient(circle, transparent 1%, rgb(70, 90, 183) 1%) center/15000%;
}
&:active {
background-color: rgb(75, 100, 200);
background-size: 100%;
transition: background 0s;
}
}
}
}

.desktop {
display: none;
.ng-container {
&__login-overlay {
z-index: 2;
border-top: 1px solid whitesmoke;
margin: 0 auto;
position: absolute;
right: 0;
}
}

.login-overlay {
background-color: #3F51B5;
border: 1px solid whitesmoke;
box-shadow: 0px 3px 1px -2px rgb(0 0 0 / 20%), 0px 2px 2px 0px rgb(0 0 0 / 14%), 0px 1px 5px 0px rgb(0 0 0 / 12%);
padding: 1.5rem;
float: right;
margin: 0 auto;
color: white;
display: flex;
flex-flow: column;
justify-content: center;
width: 100%;
@media screen and (min-width: 800px) {
width: 25rem;
}
input {
color: white;
}

.exit-container {
width: 26rem;
@media screen and (max-width: 800px) { width: 100%; }
&__exit {
display: flex;
justify-content: flex-end;
button {
&__button {
display: flex;
justify-content: center;
min-width: 2.5rem;
width: auto;
padding: 0;
}
}
.login-button {
&__button {
background-color: white;
margin: 1rem;
&--ripple {
background-position: center;
transition: background 0.8s;
&:hover {
background: rgb(235,235,235) radial-gradient(circle, transparent 1%, rgb(235,235,235) 1%) center/15000%;
}
&:active {
background-color: rgb(235,235,235);
background-size: 100%;
transition: background 0s;
}
}
}
}

@media screen and (min-width: 800px) {
.mobile {
display: none;
}
header.desktop {
display: block;
}
}

header.desktop a{
padding: 0 1rem;
}

header a {
color: white;
}

header button {
background: none;
border: none;
color: white;
font: 500 20px/32px Roboto, "Helvetica Neue", sans-serif;
}
header {
.nav-spacer {
flex: 1 1 auto;
&__input {
color: white;
}

}

h2, h3 {
text-align: center;
}
h2 {
margin: 2.5rem auto;
}
h3 {
margin: 1.5rem auto;
}

// ** ANGULAR MATERIAL STYLING

.mat-list-base {
background-color: #3F51B5;
}
.mat-list-base.list .mat-list-item {
display: flex;
border-top: 1px solid rgba(242, 242, 242, 0.25);
color: white;
}
24 changes: 19 additions & 5 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,30 @@ export class AppComponent implements OnInit {
}
}

async login(email: string, password: string) {
await this.auth.login(email, password);
this.auth.changeAuthState(true);
this.loginOverlayOpen = false;
console.log('Logged in');
login(email: string, password: string) {
this.auth.login(email, password)
.then(res => {
this.auth.changeAuthState(true);
localStorage.setItem('user', JSON.stringify(res.user));
this.loginOverlayOpen = false;
console.log('Logged in');
})
.catch(err => {
var errorCode = err.code;
var errorMessage = err.message;
if (errorCode === 'auth/wrong-password') {
alert('Wrong password.');
} else {
alert(errorMessage);
}
console.log(err);
});
}

logout() {
this.auth.logout();
console.log('logged out');
this.auth.changeAuthState(false);
}

}
20 changes: 15 additions & 5 deletions src/app/components/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<button mat-button (click)="infoOverlay()" ><mat-icon>close</mat-icon></button>
</div>
<div class="info-paragraph">
Drag and drop players from the bench to the pitch. Players' ratings are adjusted based on their position on the pitch and their familiarity.
Drag and drop players from the bench to the pitch. Players' ratings are adjusted based on their position on the pitch and their familiarity. The overall rating of the first eleven is an average of the player ratings with certain positions weighted more than others. Full backs are weigted the lowest, while central midfielders and strikers are weighted the highest.
<ul>
<li><div class="color-code natural"></div><div>Highlighted in light green is the best position for a player.</div></li>
<li><div class="color-code accomplished"></div><div>Highlighted in dark green is an alternate position (-3 rating).</div></li>
Expand All @@ -88,8 +88,18 @@ <h4 class="rules-heading">Squad Requirements</h4>
<div class="tactics-container" cdkDropListGroup>
<div class="pitch-container">
<div class="formation" *ngIf="this.pitchPlayers.length > 0">Formation: {{formation}}</div>
<div class="starters-total-rating" *ngIf="this.pitchPlayers.length > 0">Avg Rating {{startersTotalRating}}</div>
<div class="squad-total-rating" *ngIf="checkFormation()">Squad Rating {{squadTotalRating}}</div>
<div class="starters-total-rating" *ngIf="this.pitchPlayers.length > 0">
<div>Rating - {{startersTotalRating}}</div>
<div class="stars"></div>
</div>
<div class="squad-total-rating" *ngIf="checkFormation()">
<div>Squad Rating - {{squadTotalRating}}</div>
<div class="stars"></div>
</div>
<!-- <div class="squad-total-rating">
<div *ngIf="chemistry > 0; else chemContainer">Chemistry: <span style="color: lime;">+{{chemistry}}</span></div>
<ng-template #chemContainer>Chemistry: {{chemistry}}</ng-template>
</div> -->
<button mat-raised-button color="primary" type="button" (click)="resetStarters()" class="reset-button">Reset XI</button>
<div class="pitch-borders">
<div class="goal-box-top pitch-divs"></div>
Expand All @@ -102,9 +112,9 @@ <h4 class="rules-heading">Squad Requirements</h4>
<div class="pitch-grid">
<div *ngFor="let box of positionBoxes" [class]="getPositionBoxes(box)" cdkDropList (cdkDropListDropped)="drop($event)" [cdkDropListData]="pitchPlayers">
<div [class]="getPlayerClass(box)" cdkDrag [cdkDragData]="box" (cdkDragStarted)="getPositionOutline($event)" (cdkDragReleased)="removeOutlineRelease($event)" (cdkDragDropped)="removeOutlineDrop($event)">
<div *ngIf="box.pitchPlayer !== undefined">
<div *ngIf="box.pitchPlayer !== undefined" >
<img [src]="box.pitchPlayer.playerFace" alt="" class="player-face">
<span *ngIf="box.pitchPlayer !== undefined" class="pitch-player-info">{{box.pitchPlayer.pitchRating}}</span>
<span *ngIf="box.pitchPlayer !== undefined" class="pitch-player-info" >{{box.pitchPlayer.pitchRating}}</span>
<span *ngIf="box.pitchPlayer !== undefined" class="pitch-player-info">{{box.pitchPlayer.pitchPosition}}</span>
<img *ngIf="box.pitchPlayer !== undefined" class="pitch-player-img" [src]="box.pitchPlayer.nationalityLogo">
<img *ngIf="box.pitchPlayer !== undefined" class="pitch-player-img" [src]="box.pitchPlayer.clubLogo">
Expand Down
Loading

0 comments on commit ff52c64

Please sign in to comment.