Skip to content

Commit

Permalink
Reusable card component
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxantron committed Jun 21, 2019
1 parent 288ed6b commit 8188d3b
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 127 deletions.
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { MemberComponent } from './member/member.component';
import { GithubForkComponent } from './github-fork/github-fork.component';
import { HomeComponent } from './home/home.component';
import { SessionsComponent } from './sessions/sessions.component';
import { CardComponent } from './card/card.component';

@NgModule({
declarations: [
Expand All @@ -22,7 +23,8 @@ import { SessionsComponent } from './sessions/sessions.component';
MemberComponent,
GithubForkComponent,
HomeComponent,
SessionsComponent
SessionsComponent,
CardComponent
],
imports: [
BrowserModule,
Expand Down
12 changes: 12 additions & 0 deletions src/app/card.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export class Card {
value: string = '';

active: boolean;
confirmed: boolean;

// Optional name of the card
name: string;

constructor() {
}
}
122 changes: 122 additions & 0 deletions src/app/card/card.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* Cards style
*/
div.card-container {
margin-bottom: 20px;
}

div.card-container h2 {
font-weight: bold;
width: 100px;
min-height: 70px;
text-align: center;
}
@media(min-width: 992px){
div.card-container h2 {
width: 130px;
}
}

div.card {
border: 2px solid #0F1593;
border-radius: 15px;
margin-left: auto;
margin-right: auto;
}
div.card .inner {
margin: 3px 3px 0;
border-radius: 12px;
background-image: linear-gradient(to bottom, #0F1593, #161ec9);
background-image: -webkit-linear-gradient(top, #0F1593, #161ec9);
text-align: center;
}

span.card-label {
display: block;
font-size: 2em;
font-weight: bold;
padding: 50px 0 50px;
color: #FFFFFF;
}
@media (min-width: 992px) {
span.card-label {
padding: 75px 0 75px;
}
}

div.card, div.card-flip {
height: 150px;
width: 100px;
}
@media (min-width: 992px) {
div.card, div.card-flip {
height: 200px;
width: 130px;
}
}


div.card.front, div.card.back {
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
top: 15px;
left: 0;
}
div.deletable-card{
position: relative;
height: 212px;
width: 142px;
}
div.card.back {
transform: rotateY(180deg);
}
div.card-flip{
transition: 1s;
transform-style: preserve-3d;
position: relative;
}
div.card-flip.flipped {
transform: rotateY(180deg);
}

div.card.active {
box-shadow: 0px 0px 20px 5px #c80020;
}
div.card.confirmed {
box-shadow: 0px 0px 20px 5px #7ec500;
}

div.delete-member {
top: 3px;
left: 85px;
height: 25px;
width: 25px;
}
@media (min-width: 992px) {
div.delete-member {
left: 115px;
}
}

div.remove {
display: block;
position: absolute;
color: white;
text-shadow: 0 1px rgba(0, 0, 0, 0.25);
border: 1px solid;
border-radius: 3px;
box-shadow: inset 0 1px rgba(255, 255, 255, 0.3), 0 1px 1px rgba(0, 0, 0, 0.08);
-webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.3), 0 1px 1px rgba(0, 0, 0, 0.08);
background: #fa623f;
border-color: #fa5a35;
background-image: linear-gradient(to bottom, #fc9f8a, #fa623f);
background-image: -webkit-linear-gradient(top, #fc9f8a, #fa623f);
}

div.remove span {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
18 changes: 18 additions & 0 deletions src/app/card/card.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="card-container">
<div class="deletable-card">
<div class="card-flip" [class.flipped]="flipped">
<div class="card front">
<div *ngIf="backfaceVisible" class="inner"><span class="card-label">?</span></div>
</div>
<div class="card back"
[class.selectable]="canSelect" [class.active]="card.active" [class.confirmed]="card.confirmed"
(click)="select()">
<div class="inner"><span class="card-label" [innerHtml]="card.value"></span></div>
</div>
</div>
<div *ngIf="canDelete" class="delete-member remove selectable" (click)="delete()">
<span class="glyphicon glyphicon-remove"></span>
</div>
</div>
<h2 *ngIf="card.name">{{ card.name }}</h2>
</div>
38 changes: 38 additions & 0 deletions src/app/card/card.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Card } from '../card';

@Component({
selector: 'app-card',
templateUrl: './card.component.html',
styleUrls: ['./card.component.css']
})
export class CardComponent implements OnInit {

@Input() card: Card;

@Input() flipped: boolean;

@Input() backfaceVisible: boolean;

@Input() canDelete: boolean;

@Input() canSelect: boolean;

@Output() selected: EventEmitter<Card> = new EventEmitter<Card>();

@Output() delete: EventEmitter<Card> = new EventEmitter<Card>();

constructor() { }

ngOnInit() {
}

select() {
if (this.canSelect)
this.selected.emit(this.card);
}

callDelete() {
this.delete.emit(this.card);
}
}
126 changes: 0 additions & 126 deletions src/css/scrumonline.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,64 +38,6 @@ div.ticketing {
}


/*
* Cards style
*/
div.card-container {
margin-bottom: 20px;
}

div.card-container h2 {
font-weight: bold;
width: 100px;
min-height: 70px;
text-align: center;
}
@media(min-width: 992px){
div.card-container h2 {
width: 130px;
}
}

div.card {
border: 2px solid #0F1593;
border-radius: 15px;
margin-left: auto;
margin-right: auto;
}
div.card .inner {
margin: 3px 3px 0;
border-radius: 12px;
background-image: linear-gradient(to bottom, #0F1593, #161ec9);
background-image: -webkit-linear-gradient(top, #0F1593, #161ec9);
text-align: center;
}

span.card-label {
display: block;
font-size: 2em;
font-weight: bold;
padding: 50px 0 50px;
color: #FFFFFF;
}
@media (min-width: 992px) {
span.card-label {
padding: 75px 0 75px;
}
}

div.card, div.card-flip {
height: 150px;
width: 100px;
}
@media (min-width: 992px) {
div.card, div.card-flip {
height: 200px;
width: 130px;
}
}


/* Card flip */
div.card-overview {
perspective: 1000px;
Expand Down Expand Up @@ -128,86 +70,18 @@ div.card-overview div.card-container {
width: 210px;
}
}
div.card.front, div.card.back {
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
top: 15px;
left: 0;
}
div.deletable-card{
position: relative;
height: 212px;
width: 142px;
}
div.card.back {
transform: rotateY(180deg);
}
div.card-flip{
transition: 1s;
transform-style: preserve-3d;
position: relative;
}
div.card-flip.flipped {
transform: rotateY(180deg);
}

/* Selectable card */
div.card.active {
box-shadow: 0px 0px 20px 5px #c80020;
}
div.card.confirmed {
box-shadow: 0px 0px 20px 5px #7ec500;
}
button.vote {
width: 100%;
}
div.delete-member {
top: 3px;
left: 85px;
height: 25px;
width: 25px;
}

div.leave {
top: 10px;
left: 5px;
height: 40px;
width: 40px;
}

div.remove {
display: block;
position: absolute;
color: white;
text-shadow: 0 1px rgba(0, 0, 0, 0.25);
border: 1px solid;
border-radius: 3px;
box-shadow: inset 0 1px rgba(255, 255, 255, 0.3), 0 1px 1px rgba(0, 0, 0, 0.08);
-webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.3), 0 1px 1px rgba(0, 0, 0, 0.08);
background: #fa623f;
border-color: #fa5a35;
background-image: linear-gradient(to bottom, #fc9f8a, #fa623f);
background-image: -webkit-linear-gradient(top, #fc9f8a, #fa623f);
}

div.remove span {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

div.delete-member:hover {
/* color:??; color is missing here */
}

@media (min-width: 992px) {
div.delete-member {
left: 115px;
}
}

/*
* Removal styling
*/
Expand Down

0 comments on commit 8188d3b

Please sign in to comment.