Lista zestawień: poprawki dostępności i wyglądu

This commit is contained in:
2022-01-09 17:09:47 +01:00
parent 2c9218872e
commit f0f1aef6db
4 changed files with 48 additions and 36 deletions
+2 -3
View File
@@ -1,6 +1,4 @@
<template> <template>
<ready-stock-list />
<section class="inputs"> <section class="inputs">
<div class="input inputs_loco"> <div class="input inputs_loco">
<div class="input_container"> <div class="input_container">
@@ -44,6 +42,7 @@
<div class="input_ready-stock"> <div class="input_ready-stock">
<button class="btn" @click="setReadyStockList(true)"><b>REALNE ZESTAWIENIA</b></button> <button class="btn" @click="setReadyStockList(true)"><b>REALNE ZESTAWIENIA</b></button>
<ready-stock-list />
</div> </div>
<div class="input_checkbox"> <div class="input_checkbox">
@@ -123,7 +122,7 @@
<script lang="ts"> <script lang="ts">
import { ICarWagon, ILocomotive, IStore } from '@/types'; import { ICarWagon, ILocomotive, IStore } from '@/types';
import { defineComponent, inject, provide, ref } from 'vue'; import { defineComponent, inject, provide, Ref, ref } from 'vue';
import ReadyStockList from '@/components/ReadyStockList.vue'; import ReadyStockList from '@/components/ReadyStockList.vue';
+9 -7
View File
@@ -61,14 +61,16 @@
<button class="btn" @click="openRandomizerCard">LOSUJ SKŁAD</button> <button class="btn" @click="openRandomizerCard">LOSUJ SKŁAD</button>
</div> </div>
<!-- <b style="font-size: 1.15em; color: gold">
REALNE ZESTAWIENIE: <b>{{ store.chosenRealStockName?.toLocaleUpperCase() }}</b>
</b> -->
<div class="stock-list_specs"> <div class="stock-list_specs">
Masa: <span class="text--accent">{{ totalMass }}t</span> | Długość: <div>
<span class="text--accent">{{ totalLength }}m</span> Masa: <span class="text--accent">{{ totalMass }}t</span> | Długość:
| Vmax pociągu: <span class="text--accent">{{ maxStockSpeed }} km/h</span> <span class="text--accent">{{ totalLength }}m</span>
| Vmax pociągu: <span class="text--accent">{{ maxStockSpeed }} km/h</span>
</div>
<div v-if="store.chosenRealStockName" style="margin-top: 0.25rem">
<b>{{ store.chosenRealStockName.toLocaleUpperCase() }}</b>
</div>
</div> </div>
<div class="stock-list_string"> <div class="stock-list_string">
+32 -26
View File
@@ -1,6 +1,6 @@
<template> <template>
<div class="ready-stock-list" v-if="isOpen"> <div class="ready-stock-list" v-if="isOpen">
<button class="btn--text exit" @click="exit">POWRÓT</button> <button class="btn btn--text exit" @click="exit">&lt; POWRÓT</button>
<div class="header"> <div class="header">
<h1> <h1>
REALNE ZESTAWIENIA REALNE ZESTAWIENIA
@@ -11,21 +11,24 @@
na stronie <i>vagonweb.cz</i> na stronie <i>vagonweb.cz</i>
</p> </p>
<input type="text" v-model="chosenStock" placeholder="Szukaj zestawienia..." /> <input type="text" tabindex="0" v-model="searchedReadyStockName" placeholder="Szukaj zestawienia..." />
</div> </div>
<ul v-if="responseStatus == 'loaded'"> <ul v-if="responseStatus == 'loaded'">
<li <li
v-for="(v, k) in computedList" v-for="(stock, key) in computedReadyStockList"
:key="k" :key="key"
@contextmenu="openPreview($event, v.type, v.number)" tabindex="0"
@click="choseStock(v.name, v.type, v.number, v.stockString)" @contextmenu="openPreview($event, stock.type, stock.number)"
@click="choseStock(stock.name, stock.type, stock.number, stock.stockString)"
@keydown.space="openPreview($event, stock.type, stock.number)"
@keydown.enter="choseStock(stock.name, stock.type, stock.number, stock.stockString)"
> >
<img v-if="v.type != 'iR' && v.type != 'RE'" :src="icons[v.type]" alt="" /> <img v-if="stock.type != 'iR' && stock.type != 'RE'" :src="icons[stock.type]" alt="" />
<span v-else>{{ v.type }}</span> <span v-else>{{ stock.type }}</span>
<b class="text--accent"> {{ v.name }}</b> <b class="text--accent"> {{ stock.name }}</b>
<div>{{ v.number }}</div> <div>{{ stock.number }}</div>
</li> </li>
</ul> </ul>
</div> </div>
@@ -35,11 +38,11 @@
import { ICarWagon, ILocomotive, IStore } from '@/types'; import { ICarWagon, ILocomotive, IStore } from '@/types';
import { defineComponent, inject } from 'vue'; import { defineComponent, inject } from 'vue';
interface List { interface ReadyStockList {
[key: string]: { stockString: string; type: string; number: string; name: string }; [key: string]: { stockString: string; type: string; number: string; name: string };
} }
interface Response { interface ResponseJSONData {
[key: string]: string; [key: string]: string;
} }
@@ -56,10 +59,10 @@ export default defineComponent({
data: () => ({ data: () => ({
responseStatus: 'loading', responseStatus: 'loading',
chosenStock: '',
isMobile: 'ontouchstart' in document.documentElement && navigator.userAgent.match(/Mobi/) ? true : false, isMobile: 'ontouchstart' in document.documentElement && navigator.userAgent.match(/Mobi/) ? true : false,
readyStockList: {} as List, readyStockList: {} as ReadyStockList,
searchedReadyStockName: '',
icons: { icons: {
EIC: require('@/assets/EIC.png'), EIC: require('@/assets/EIC.png'),
@@ -69,13 +72,13 @@ export default defineComponent({
}), }),
computed: { computed: {
computedList() { computedReadyStockList() {
if (this.chosenStock == '') return this.readyStockList; if (this.searchedReadyStockName == null) return this.readyStockList;
let filtered: List = {}; let filtered: ReadyStockList = {};
for (let key in this.readyStockList) { for (let key in this.readyStockList) {
if (key.toLocaleLowerCase().includes(this.chosenStock.toLocaleLowerCase())) if (key.toLocaleLowerCase().includes(this.searchedReadyStockName.toLocaleLowerCase()))
filtered[key] = this.readyStockList[key]; filtered[key] = this.readyStockList[key];
} }
@@ -95,9 +98,8 @@ export default defineComponent({
const zeme = isRegio ? 'PREG' : 'PKPIC'; const zeme = isRegio ? 'PREG' : 'PKPIC';
const rok = isRegio ? '&rok=2013' : ''; const rok = isRegio ? '&rok=2013' : '';
const cislo = number.replace(/_/g, '/');
const url = `https://www.vagonweb.cz/razeni/vlak.php?zeme=${zeme}&kategorie=${type}&cislo=${cislo}${rok}`; const url = `https://www.vagonweb.cz/razeni/vlak.php?zeme=${zeme}&kategorie=${type}&cislo=${number}${rok}`;
window.open(url); window.open(url);
}, },
@@ -154,26 +156,26 @@ export default defineComponent({
}, },
async mounted() { async mounted() {
const response: Response = await (await fetch('https://spythere.github.io/api/readyStockTest.json')).json(); const readyStockJSONData: ResponseJSONData = await (await fetch('https://spythere.github.io/api/readyStockTest.json')).json();
if (!response) { if (!readyStockJSONData) {
this.responseStatus = 'error'; this.responseStatus = 'error';
return; return;
} }
for (let key in response) { for (let stockKey in readyStockJSONData) {
const splittedKey = key.split(' '); const splittedKey = stockKey.split(' ');
let name = ''; let name = '';
for (let i = 2; i < splittedKey.length; i++) { for (let i = 2; i < splittedKey.length; i++) {
name += ' ' + splittedKey[i]; name += ' ' + splittedKey[i];
} }
this.readyStockList[key] = { this.readyStockList[stockKey] = {
type: splittedKey[0], type: splittedKey[0],
number: splittedKey[1].replace(/_/g, '/'), number: splittedKey[1].replace(/_/g, '/'),
name, name,
stockString: response[key], stockString: readyStockJSONData[stockKey],
}; };
} }
@@ -280,6 +282,10 @@ input {
&:hover { &:hover {
background: #222; background: #222;
} }
&:focus {
outline: 1px solid white;
}
} }
} }
</style> </style>
+5
View File
@@ -82,9 +82,14 @@ button.btn {
border-color: $accentColor; border-color: $accentColor;
} }
&:focus {
color: $accentColor;
}
&--text { &--text {
font-weight: bold; font-weight: bold;
transition: all 250ms; transition: all 250ms;
border: none;
} }
} }