MAPG-97 make better split up of JSs, CSSs, SVGs, templates

This commit is contained in:
Bence Pőcze 2020-06-01 20:39:23 +02:00
parent 601598367e
commit b823af1f7d
11 changed files with 293 additions and 275 deletions

190
public/static/css/game.css Normal file
View File

@ -0,0 +1,190 @@
#roundInfo {
line-height: inherit;
text-align: right;
}
#roundInfo p {
font-size: 16px;
line-height: inherit;
}
#panorama {
width: 100%;
height: calc(100% - 40px);
z-index: 1;
}
#cover {
position: absolute;
top: 40px;
left: 0;
bottom: 0;
right: 0;
background-color: #000000;
opacity: 0.5;
z-index: 3;
}
#guess {
position: absolute;
bottom: 30px;
right: 20px;
z-index: 2;
}
#guess.result {
z-index: 4;
}
#guess>#continueButtonContainer {
display: none;
}
#guess.result>#closeGuessButtonContainer, #guess.result>#guessButtonContainer {
display: none;
}
#guess.result>#continueButtonContainer {
display: block;
}
#map {
width: 100%;
border-radius: 3px;
}
#guess.result>#map {
height: calc(100% - 170px);
}
#resultInfo {
margin-top: 5px;
width: 100%;
height: 120px;
padding: 5px 20px;
text-align: center;
box-sizing: border-box;
background-color: #ffffff;
border-radius: 3px;
display: none;
}
#guess.result>#resultInfo {
display: block;
}
#resultInfo>div {
width: 100%;
height: 33.33%;
display: flex;
justify-content: center;
align-items: center;
}
#resultInfo p {
font-size: 24px;
line-height: 1;
}
#distanceInfo>p:nth-child(2), #scoreInfo>p:nth-child(2) {
display: none;
}
#scoreBarBase {
height: 24px;
margin: 0 auto;
background-color: #eeeeee;
border-radius: 3px;
}
#scoreBar {
width: 0;
height: 100%;
border-radius: 3px;
transition-property: width;
transition-duration: 2.0s;
}
#showSummaryButton, #startNewGameButton {
display: none;
}
@media screen and (max-width: 599px) {
#showGuessButtonContainer {
position: absolute;
left: 20px;
bottom: 30px;
right: 20px;
z-index: 2;
}
#guess {
top: 50px;
left: 20px;
opacity: 0.95;
visibility: hidden;
}
#map {
height: calc(100% - 90px);
}
#scoreBarBase {
width: 100%;
}
}
@media screen and (min-width: 600px) {
#showGuessButtonContainer {
display: none;
}
#guess {
width: 500px;
height: 375px;
opacity: 0.95;
}
#guess.adapt {
top: initial;
width: 250px;
height: 200px;
opacity: 0.5;
transition-property: width, height, opacity;
transition-duration: 0.1s;
transition-delay: 0.8s;
}
#guess.adapt:hover {
width: 500px;
height: 375px;
opacity: 0.95;
transition-delay: 0s;
}
#closeGuessButtonContainer {
display: none;
}
#map {
height: calc(100% - 45px);
}
#guess.result {
width: initial;
height: initial;
top: 50px;
left: 50px;
right: 50px;
bottom: 50px;
}
#scoreBarBase {
width: 60%;
}
@media screen and (max-height: 424px) {
#guess {
top: 50px;
height: initial;
}
#guess.adapt:hover {
top: 50px;
height: initial;
}
#guess.result {
left: 20px;
right: 20px;
bottom: 30px;
}
}
}

View File

@ -93,7 +93,10 @@ sub {
margin-bottom: 10px;
}
svg.inline {
svg.inline, img.inline {
display: inline-block;
width: 1em;
height: 1em;
vertical-align: -0.15em;
}
@ -147,6 +150,14 @@ button.gray:hover, button.gray:focus, a.button.gray:hover, a.button.gray:focus {
background-color: #555555;
}
button.red, a.button.red {
background-color: #aa5e5e;
}
button.red:hover, button.red:focus, a.button.red:hover, a.button.red:focus {
background-color: #7f2929;
}
div.header {
background-color: #333333;
height: 50px;
@ -177,51 +188,6 @@ div.buttonContainer>button {
margin: 0 auto;
}
div.mapContainer {
display: grid;
}
div.mapItem {
width: 350px;
background-color: #eeeeee;
border-radius: 3px;
margin: 10px auto;
}
div.mapItem>div.title {
background-color: #28a745;
color: white;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
padding: 4px 8px;
}
div.mapItem>div.title>p.title {
font-weight: 500;
font-size: 18px;
}
div.mapItem>img {
width: 100%;
}
div.mapItem>div.inner {
padding: 8px;
}
div.mapItem>div.inner>div.info {
display: grid;
grid-template-columns: auto auto;
}
div.mapItem>div.inner>div.info>p:nth-child(1) {
text-align: left;
}
div.mapItem>div.inner>div.info>p:nth-child(2) {
text-align: right;
}
#loading {
position: absolute;
width: 64px;
@ -234,147 +200,6 @@ div.mapItem>div.inner>div.info>p:nth-child(2) {
visibility: hidden;
}
#roundInfo {
line-height: inherit;
text-align: right;
}
#roundInfo p {
font-size: 16px;
line-height: inherit;
}
#panorama {
width: 100%;
height: calc(100% - 40px);
z-index: 1;
}
#cover {
position: absolute;
top: 40px;
left: 0;
bottom: 0;
right: 0;
background-color: #000000;
opacity: 0.5;
z-index: 3;
}
#guess {
position: absolute;
bottom: 30px;
right: 20px;
z-index: 2;
}
#guess.result {
z-index: 4;
}
#guess>#continueButtonContainer {
display: none;
}
#guess.result>#closeGuessButtonContainer, #guess.result>#guessButtonContainer {
display: none;
}
#guess.result>#continueButtonContainer {
display: block;
}
#map {
width: 100%;
border-radius: 3px;
}
#guess.result>#map {
height: calc(100% - 170px);
}
#resultInfo {
margin-top: 5px;
width: 100%;
height: 120px;
padding: 5px 20px;
text-align: center;
box-sizing: border-box;
background-color: #ffffff;
border-radius: 3px;
display: none;
}
#guess.result>#resultInfo {
display: block;
}
#resultInfo>div {
width: 100%;
height: 33.33%;
display: flex;
justify-content: center;
align-items: center;
}
#resultInfo p {
font-size: 24px;
line-height: 1;
}
#distanceInfo>p:nth-child(2), #scoreInfo>p:nth-child(2) {
display: none;
}
#scoreBarBase {
height: 24px;
margin: 0 auto;
background-color: #eeeeee;
border-radius: 3px;
}
#scoreBar {
width: 0;
height: 100%;
border-radius: 3px;
transition-property: width;
transition-duration: 2.0s;
}
#showSummaryButton, #startNewGameButton {
display: none;
}
@media screen and (min-width: 1504px) {
div.mapContainer {
grid-template-columns: auto auto auto auto;
}
}
@media screen and (min-width: 1134px) and (max-width: 1503px) {
div.mapContainer {
grid-template-columns: auto auto auto;
}
}
@media screen and (min-width: 764px) and (max-width: 1133px) {
div.mapContainer {
grid-template-columns: auto auto;
}
}
@media screen and (max-width: 763px) {
div.mapContainer {
grid-template-columns: auto;
}
}
@media screen and (max-width: 374px) {
div.mapItem {
width: initial;
}
}
@media screen and (max-width: 599px) {
div.header.small h1 span {
display: none;
@ -383,81 +208,4 @@ div.mapItem>div.inner>div.info>p:nth-child(2) {
padding: 0;
width: 100%;
}
#showGuessButtonContainer {
position: absolute;
left: 20px;
bottom: 30px;
right: 20px;
z-index: 2;
}
#guess {
top: 50px;
left: 20px;
opacity: 0.95;
visibility: hidden;
}
#map {
height: calc(100% - 90px);
}
#scoreBarBase {
width: 100%;
}
}
@media screen and (min-width: 600px) {
#showGuessButtonContainer {
display: none;
}
#guess {
width: 500px;
height: 375px;
opacity: 0.95;
}
#guess.adapt {
top: initial;
width: 250px;
height: 200px;
opacity: 0.5;
transition-property: width, height, opacity;
transition-duration: 0.1s;
transition-delay: 0.8s;
}
#guess.adapt:hover {
width: 500px;
height: 375px;
opacity: 0.95;
transition-delay: 0s;
}
#closeGuessButtonContainer {
display: none;
}
#map {
height: calc(100% - 45px);
}
#guess.result {
width: initial;
height: initial;
top: 50px;
left: 50px;
right: 50px;
bottom: 50px;
}
#scoreBarBase {
width: 60%;
}
@media screen and (max-height: 424px) {
#guess {
top: 50px;
height: initial;
}
#guess.adapt:hover {
top: 50px;
height: initial;
}
#guess.result {
left: 20px;
right: 20px;
bottom: 30px;
}
}
}

View File

@ -0,0 +1,74 @@
#mapContainer {
display: grid;
}
div.mapItem {
width: 350px;
background-color: #eeeeee;
border-radius: 3px;
margin: 10px auto;
}
div.mapItem>div.title {
background-color: #28a745;
color: white;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
padding: 4px 8px;
}
div.mapItem>div.title>p.title {
font-weight: 500;
font-size: 18px;
}
div.mapItem>img {
width: 100%;
}
div.mapItem>div.inner {
padding: 8px;
}
div.mapItem>div.inner>div.info {
display: grid;
grid-template-columns: auto auto;
}
div.mapItem>div.inner>div.info>p:nth-child(1) {
text-align: left;
}
div.mapItem>div.inner>div.info>p:nth-child(2) {
text-align: right;
}
@media screen and (min-width: 1504px) {
#mapContainer {
grid-template-columns: auto auto auto auto;
}
}
@media screen and (min-width: 1134px) and (max-width: 1503px) {
#mapContainer {
grid-template-columns: auto auto auto;
}
}
@media screen and (min-width: 764px) and (max-width: 1133px) {
#mapContainer {
grid-template-columns: auto auto;
}
}
@media screen and (max-width: 763px) {
#mapContainer {
grid-template-columns: auto;
}
}
@media screen and (max-width: 374px) {
div.mapItem {
width: initial;
}
}

View File

@ -0,0 +1,2 @@
The PNGs in this folder are generated from '../icon.svg'.
Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'.

View File

@ -1,4 +1,3 @@
<!-- The PNGs in this folder are generated from this SVG. -->
<!-- Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'. -->
<svg viewBox="0 0 16 16" fill="#28a745" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M15.817.613A.5.5 0 0 1 16 1v13a.5.5 0 0 1-.402.49l-5 1a.502.502 0 0 1-.196 0L5.5 14.51l-4.902.98A.5.5 0 0 1 0 15V2a.5.5 0 0 1 .402-.49l5-1a.5.5 0 0 1 .196 0l4.902.98 4.902-.98a.5.5 0 0 1 .415.103zM10 2.41l-4-.8v11.98l4 .8V2.41zm1 11.98l4-.8V1.61l-4 .8v11.98zm-6-.8V1.61l-4 .8v11.98l4-.8z" />

Before

Width:  |  Height:  |  Size: 591 B

After

Width:  |  Height:  |  Size: 529 B

View File

@ -4,6 +4,8 @@ ROOT_DIR=$(dirname $(readlink -f "$0"))/..
. ${ROOT_DIR}/.env
uglifyjs ${ROOT_DIR}/public/static/js/game.js -c -m -o ${ROOT_DIR}/public/static/js/game.js
cleancss ${ROOT_DIR}/public/static/css/mapguesser.css -o ${ROOT_DIR}/public/static/css/mapguesser.css
svgo ${ROOT_DIR}/public/static/img/loading.svg -o ${ROOT_DIR}/public/static/img/loading.svg
find ${ROOT_DIR}/public/static/js -type f -iname '*.js' -exec uglifyjs {} -c -m -o {} \;
find ${ROOT_DIR}/public/static/css -type f -iname '*.css' -exec cleancss {} -o {} \;
find ${ROOT_DIR}/public/static/img -type f -iname '*.svg' -exec svgo {} -o {} \;

View File

@ -1,9 +1,10 @@
<?php $cssFiles = ['/static/css/game.css']; ?>
<?php require ROOT . '/views/templates/main_header.php'; ?>
<div class="header small">
<div class="grid">
<h1>
<a href="/maps" title="Back to playable maps">
<?php require ROOT . '/views/templates/icon.php'; ?>
<img class="inline" src="/static/img/icon.svg">
<span>MapGuesser</span>
</a>
</h1>

View File

@ -1,8 +1,9 @@
<?php $cssFiles = ['/static/css/maps.css']; ?>
<?php require ROOT . '/views/templates/main_header.php'; ?>
<?php require ROOT . '/views/templates/header.php'; ?>
<div class="main">
<h2>Playable maps</h2>
<div class="mapContainer">
<div id="mapContainer">
<?php foreach ($maps as $map) : ?>
<div class="mapItem">
<div class="title">

View File

@ -1,7 +1,7 @@
<div class="header">
<h1>
<a href="/" title="MapGuesser">
<?php require ROOT . '/views/templates/icon.php'; ?>
<img class="inline" src="/static/img/icon.svg">
MapGuesser
</a>
</h1>

View File

@ -1,4 +0,0 @@
<?php /* Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'. */ ?>
<svg class="inline" width="1em" height="1em" viewBox="0 0 16 16" fill="#28a745" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M15.817.613A.5.5 0 0 1 16 1v13a.5.5 0 0 1-.402.49l-5 1a.502.502 0 0 1-.196 0L5.5 14.51l-4.902.98A.5.5 0 0 1 0 15V2a.5.5 0 0 1 .402-.49l5-1a.5.5 0 0 1 .196 0l4.902.98 4.902-.98a.5.5 0 0 1 .415.103zM10 2.41l-4-.8v11.98l4 .8V2.41zm1 11.98l4-.8V1.61l-4 .8v11.98zm-6-.8V1.61l-4 .8v11.98l4-.8z" />
</svg>

View File

@ -5,6 +5,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MapGuesser</title>
<link href="/static/css/mapguesser.css" rel="stylesheet">
<?php if (isset($cssFiles)) : ?>
<?php foreach ($cssFiles as $cssFile) : ?>
<link href="<?= $cssFile ?>" rel="stylesheet">
<?php endforeach; ?>
<?php endif; ?>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;500&family=Roboto+Mono:wght@300;500&display=swap" rel="stylesheet">
<link rel="icon" type="image/png" sizes="192x192" href="/static/img/favicon/192x192.png">
<link rel="icon" type="image/png" sizes="96x96" href="/static/img/favicon/96x96.png">