Projekt

Obecné

Profil

« Předchozí | Další » 

Revize a12a4e99

Přidáno uživatelem plundrichov před více než 4 roky(ů)

re #58 mostly css edited, also login/logout

Zobrazit rozdíly:

client/src/App.css
15 15

  
16 16
/* --------------APP------------------*/
17 17

  
18
.App {
19
    display: flex;
20
    flex-direction: column;
21
    height: 100vh;
22
}
23

  
18 24
.permissionText {
19 25
    text-align: center;
20 26
    justify-content: center;
......
35 41
/* ------------- Navbar --------------- */
36 42

  
37 43
.top-nav {
38
    width: 100vw;
39 44
    height: 60px;
40 45
    background-color: #393d3f;
41 46
    display: flex;
42 47
    justify-content: space-between;
43 48
    align-items: center;
44 49
    color: white;
50
    padding: 10px 0;
45 51
}
46 52

  
47 53
.img-avatar {
......
86 92
    color: rgb(57, 184, 177);
87 93
}
88 94

  
95
.btn-logout {
96
    background-color: none;
97
    background: none;
98
    padding: 0;
99
    border: none;
100
    cursor: pointer;
101
}
102
.btn-logout:focus {
103
    outline: none;
104
}
105

  
106
.profile-comp svg:focus {
107
    outline: none;
108
}
109

  
89 110
/* --------- MAIN CONTAINER ------------ */
90 111

  
91 112
.container {
92 113
    width: 100%;
93
    min-height: 100vh;
94 114
    display: flex;
115
    flex-grow: 1;
95 116
    background-color: rgb(129, 168, 162);
96 117
    /* background: linear-gradient(#689c94, #0f546b); */
97 118
    position: relative;
......
227 248
    padding: 10px;
228 249
}
229 250

  
230
/* table td {
231
    width: 50px;
232
} */
233

  
234 251
.side-content table td {
235 252
    height: 50px;
236 253
}
......
279 296
    position: absolute;
280 297
    justify-content: center;
281 298
    align-items: center;
282
    width: 480px;
283
    height: 480px;
299
    width: 430px;
300
    height: 430px;
284 301
    background-color: rgba(255, 255, 255, 0.075);
285 302
    /* border: 2px solid white; */
286 303
    border-radius: 50%;
......
384 401
/* -------------------LogOut------------------- */
385 402

  
386 403
.logout p {
387
    font-size: 48px;
404
    font-size: 38px;
388 405
    text-align: center;
389 406
    padding: 40px;
390 407
    color: #ffffff;
......
421 438

  
422 439
@media only screen and (max-width: 792px) {
423 440
    .container {
424
    height: 100vh;
425 441
    flex-direction: column;
426 442
    }
427 443

  
......
502 518
}
503 519

  
504 520
@media only screen and (max-width: 480px) {
505
    .top-nav h3 {
506
        margin-right: 30px;
521
    .top-nav h1 {
522
        margin-right: 20px;
523
        margin-left: 30px;
507 524
    }
508 525

  
509 526
    .login-container {
510 527
        width: 300px;
511 528
        height: 300px;
512 529
    }
513
    .login-container h1 {
530
    .login-container p {
514 531
        color: white;
515 532
        font-size: 60px;
516 533
    }
517 534

  
518
    .logout h1 {
519
        font-size: 22px;
535
    .logout p {
536
        font-size: 24px;
520 537
        text-align: center;
521 538
        padding: 20px;
522 539
    }
523
    .logout h4 {
524
        font-size: 14px;
525
    }
526 540

  
527 541
    .profile-comp {
528 542
        margin-right: 20px;
......
604 618
        width: 250px;
605 619
        height: 250px;
606 620
    }
607
    .login-container h1 {
621
    .login-container p {
608 622
        color: white;
609 623
        font-size: 50px;
610 624
    }
611 625

  
612
    .logout h1 {
626
    .logout p {
613 627
        font-size: 22px;
614 628
        text-align: center;
615 629
        padding: 20px;
616 630
    }
617
    .logout h4 {
618
        font-size: 12px;
619
    }
620 631

  
621 632
    .offs-item {
622 633
        flex-direction: column;
client/src/App.js
15 15
function App() {
16 16

  
17 17
  useEffect(() => {
18
    if (window.location.pathname === '/login') return;
18
    if (window.location.pathname === '/login' || window.location.pathname === '/logout') return;
19 19

  
20 20
    api_fetch.getCurrentProfile().then(currentProfile => {
21 21
      setCurrentUser(currentProfile);
client/src/Nav.js
1 1
import React from 'react';
2 2
import './App.css';
3 3
import { Link } from 'react-router-dom';
4
import * as api_fetch from './api'
4 5

  
5 6
function Nav(props) {
6 7

  
......
8 9
    props.currentUser === undefined
9 10
  ?
10 11
      <nav className="top-nav">
11
        <Link className="link-nav" to="/"><h1>YOSO</h1></Link>
12
        <Link className="link-nav" to="/login"><h1>YOSO</h1></Link>
12 13
      </nav>
13 14
  :
14 15
      <nav className="top-nav">
......
28 29
              </li>
29 30
              :  null }
30 31
              <li>
31
                <Link to="/logout">
32
                <button className="btn-logout" onClick={() => api_fetch.logOut()}>
32 33
                  <svg className="bi bi-power navIcon" width="20px" height="20px" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
33 34
                    <path fillRule="evenodd" d="M5.578 4.437a5 5 0 1 0 4.922.044l.5-.866a6 6 0 1 1-5.908-.053l.486.875z"/>
34 35
                    <path fillRule="evenodd" d="M7.5 8V1h1v7h-1z"/>
35 36
                  </svg>
36
                </Link>
37
                </button>
37 38
              </li>
38 39
          </ul>
39 40
        </div>
client/src/api.js
1 1
// ******************** GET DATA APP getCurrentProfile ********************
2 2

  
3
export const logOut = async () => {
4

  
5
  let response;
6

  
7
  try {
8
    response = await fetch(
9
      `${window.config.baseUrl}/logout`, {
10
        credentials: 'include'
11
      }
12
    );    
13
  } catch (e) {
14
    throw 'Server is not available'
15
    }
16

  
17
  if (response.ok) {
18
        window.location.replace(`/logout`)
19
  } else {
20
      switch (response.status) {
21
        case 500:
22
          throw new Error('Internal server error.')
23
        default:
24
          throw new Error(response.statusText)
25
      }
26
    }
27
}
28

  
3 29
export const getCurrentProfile = async () => {
4 30

  
5 31
  let response;
......
7 33
  try {
8 34
    response = await fetch(
9 35
      `${window.config.baseUrl}/users/current/profile`, {
10
        headers: {},
36

  
11 37
        credentials: 'include'
12 38
      }
13 39
    );    

Také k dispozici: Unified diff