Skip to content

Commit 702c0a9

Browse files
authored
Fix login page background
1 parent a4eb039 commit 702c0a9

File tree

2 files changed

+237
-0
lines changed

2 files changed

+237
-0
lines changed

login.css

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/* Bootstrap reset */
2+
3+
.form-control:focus, .btn.focus, .btn:focus {
4+
5+
box-shadow: unset;
6+
7+
}
8+
9+
.input-group-text {
10+
11+
border: unset;
12+
13+
}
14+
15+
/**
16+
* Shake effect.
17+
*
18+
* @see https://teamtreehouse.com/community/shake-effect-with-javascript-only
19+
*/
20+
21+
@keyframes shake {
22+
23+
10%, 90% {
24+
transform: translate3d(-1px, 0, 0);
25+
}
26+
27+
20%, 80% {
28+
transform: translate3d(2px, 0, 0);
29+
}
30+
31+
30%, 50%, 70% {
32+
transform: translate3d(-4px, 0, 0);
33+
}
34+
35+
40%, 60% {
36+
transform: translate3d(4px, 0, 0);
37+
}
38+
39+
}
40+
41+
.shake {
42+
43+
animation: shake 0.82s cubic-bezier(.36, .07, .19, .97) both;
44+
45+
}
46+
47+
/**
48+
* Template based on a snippet created by Mutiullah Samim.
49+
*
50+
* @see https://bootsnipp.com/snippets/vl4R7
51+
*/
52+
53+
#mpg-background {
54+
55+
background-image: url("../../assets/images/login-background.jpg");
56+
background-repeat: no-repeat;
57+
background-size: cover;
58+
height: 100%;
59+
left: 0;
60+
position: absolute;
61+
top: 0;
62+
width: 100%;
63+
64+
}
65+
66+
#mpg-background .credit-link {
67+
68+
bottom: 10px;
69+
color: rgba(255, 255, 255, 0.7);
70+
position: absolute;
71+
right: 10px;
72+
73+
}
74+
75+
html, body {
76+
77+
height: 100%;
78+
79+
}
80+
81+
body {
82+
83+
font-family: Arial, sans-serif;
84+
85+
}
86+
87+
.alert {
88+
89+
max-width: 290px;
90+
margin: 15px auto;
91+
92+
}
93+
94+
#mpg-cards {
95+
96+
min-height: 191px;
97+
perspective: 1000px;
98+
transform-style: preserve-3d;
99+
width: 322px;
100+
101+
}
102+
103+
.card {
104+
105+
background-color: rgba(255, 255, 255, 0.7);
106+
107+
}
108+
109+
.mpg-card-front, .mpg-card-back {
110+
111+
-webkit-backface-visibility: hidden; /* For Safari */
112+
backface-visibility: hidden;
113+
position: absolute;
114+
transition: transform 0.6s;
115+
116+
}
117+
118+
.mpg-card-front {
119+
120+
transform: rotateY(0deg);
121+
122+
}
123+
124+
#mpg-cards.flipped .mpg-card-front {
125+
126+
transform: rotateY(-180deg);
127+
128+
}
129+
130+
.mpg-card-back {
131+
132+
transform: rotateY(180deg);
133+
134+
}
135+
136+
#mpg-cards.flipped .mpg-card-back {
137+
138+
transform: rotateY(0deg);
139+
140+
}
141+
142+
.mpg-card-header-title {
143+
144+
font-family: Ubuntu, ubuntu-medium;
145+
146+
}
147+
148+
.input-group-text {
149+
150+
width: 40px;
151+
152+
background-color: #5dad1d;
153+
color: white;
154+
155+
}
156+
157+
.mpg-flip-card-button {
158+
159+
padding-left: 0;
160+
161+
}

login.esm.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* MongoDB PHP GUI login.
3+
*/
4+
class Login {
5+
6+
constructor() {
7+
8+
this.cardsContainer = document.getElementById('mpg-cards')
9+
this.flipCardButtons = document.querySelectorAll('.mpg-flip-card-button')
10+
this.requiredInputs = document.querySelectorAll('input[required]')
11+
this.forms = document.querySelectorAll('form')
12+
13+
}
14+
15+
/**
16+
* Adds an event listener on each "Flip card" button.
17+
*/
18+
listenFlipCardButtons() {
19+
20+
this.flipCardButtons.forEach(flipCardButton => {
21+
flipCardButton.addEventListener('click', event => {
22+
event.preventDefault()
23+
this.cardsContainer.classList.toggle('flipped')
24+
})
25+
})
26+
27+
}
28+
29+
/**
30+
* Adds an event listener on each required input field.
31+
*/
32+
listenRequiredInputs() {
33+
34+
this.cardsContainer.addEventListener('animationend', _event => {
35+
this.cardsContainer.classList.remove('shake')
36+
})
37+
38+
this.requiredInputs.forEach(requiredInput => {
39+
requiredInput.addEventListener('invalid', _event => {
40+
this.cardsContainer.classList.add('shake')
41+
})
42+
})
43+
44+
}
45+
46+
/**
47+
* Adds an event listener on each form.
48+
*/
49+
listenForms() {
50+
51+
this.forms.forEach(form => {
52+
form.addEventListener('submit', event => {
53+
event.preventDefault()
54+
55+
/**
56+
* TODO: Submit form if credentials are good.
57+
*
58+
* @see https://github.com/SamuelTallet/MongoDB-PHP-GUI/issues/21
59+
*/
60+
form.submit()
61+
})
62+
})
63+
64+
}
65+
66+
}
67+
68+
(function onDocumentReady() {
69+
70+
const login = new Login()
71+
72+
login.listenFlipCardButtons()
73+
login.listenRequiredInputs()
74+
login.listenForms()
75+
76+
})()

0 commit comments

Comments
 (0)