mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-04 22:08:12 +00:00
Aktualizacja scenerii i wyglądu select boxów
This commit is contained in:
@@ -1,33 +1,50 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="select-box">
|
<div class="select-box">
|
||||||
<div class="select-box_content">
|
<div class="select-box_content">
|
||||||
<label>
|
<button class="selected" @click="toggleBox">
|
||||||
<select
|
{{ selectedItemComp ? selectedItemComp.value : "" }}
|
||||||
v-model="selectedItem"
|
</button>
|
||||||
:style="bgColor ? 'background-color:' + bgColor : ''"
|
|
||||||
>
|
<div class="options" v-if="boxVisible">
|
||||||
<option value disabled selected hidden>
|
<div class="option" v-for="item in itemList" :key="item.id">
|
||||||
{{ title }}
|
<label :for="item.id">
|
||||||
</option>
|
<input
|
||||||
<option v-for="item in itemList" :key="item.id" :value="item.id">
|
type="button"
|
||||||
{{ item.value }}
|
:id="item.id"
|
||||||
</option>
|
name="select-box"
|
||||||
</select>
|
@click="selectOption(item)"
|
||||||
<span class="arrows"></span>
|
/>
|
||||||
</label>
|
|
||||||
|
<span :style="selectedItemComp.id == item.id ? 'color: gold;' : ''">
|
||||||
|
{{ item.value }}
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="arrow">
|
||||||
|
<img :src="boxVisible ? ascIcon : descIcon" alt="arrow-icon" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue, Prop, Watch, Emit } from "vue-property-decorator";
|
import { Component, Vue, Prop, Emit } from "vue-property-decorator";
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default class SelectBox extends Vue {
|
export default class SelectBox extends Vue {
|
||||||
@Prop({ required: true }) title!: string;
|
@Prop({ required: true }) title!: string;
|
||||||
@Prop({ required: true }) itemList!: { id: string | number; value: string }[];
|
@Prop({ required: true }) itemList!: { id: string | number; value: string }[];
|
||||||
|
@Prop({ default: 0 }) defaultItemIndex!: number;
|
||||||
@Prop() bgColor!: string;
|
@Prop() bgColor!: string;
|
||||||
|
|
||||||
|
boxVisible = false;
|
||||||
|
|
||||||
|
test() {
|
||||||
|
console.log("test");
|
||||||
|
}
|
||||||
|
|
||||||
@Emit("selected")
|
@Emit("selected")
|
||||||
onItemSelected() {
|
onItemSelected() {
|
||||||
return this.selectedItem;
|
return this.selectedItem;
|
||||||
@@ -36,10 +53,21 @@ export default class SelectBox extends Vue {
|
|||||||
ascIcon = require("@/assets/icon-arrow-asc.svg");
|
ascIcon = require("@/assets/icon-arrow-asc.svg");
|
||||||
descIcon = require("@/assets/icon-arrow-desc.svg");
|
descIcon = require("@/assets/icon-arrow-desc.svg");
|
||||||
|
|
||||||
selectedItem: string = "";
|
selectedItem: { id: string | number; value: string } | null = null;
|
||||||
|
|
||||||
@Watch("selectedItem")
|
get selectedItemComp() {
|
||||||
watchSelectedItem(item) {
|
if (!this.selectedItem) return this.itemList[this.defaultItemIndex];
|
||||||
|
|
||||||
|
return this.itemList.find((item) => item.id === this.selectedItem?.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleBox() {
|
||||||
|
this.boxVisible = !this.boxVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectOption(item: { id: string | number; value: string }) {
|
||||||
|
this.selectedItem = item;
|
||||||
|
this.boxVisible = false;
|
||||||
this.onItemSelected();
|
this.onItemSelected();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,80 +77,100 @@ export default class SelectBox extends Vue {
|
|||||||
@import "../../styles/variables.scss";
|
@import "../../styles/variables.scss";
|
||||||
|
|
||||||
.select-box {
|
.select-box {
|
||||||
&_content {
|
position: relative;
|
||||||
// display: inline-block;
|
}
|
||||||
|
|
||||||
position: relative;
|
.arrow {
|
||||||
margin: 0.5em auto;
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
right: 0.5em;
|
||||||
|
|
||||||
|
img {
|
||||||
|
vertical-align: middle;
|
||||||
|
width: 1.35em;
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
transform: translateY(-50%);
|
||||||
border: none;
|
|
||||||
outline: none;
|
|
||||||
|
|
||||||
background: #333;
|
pointer-events: none;
|
||||||
padding: 0.35em 0.5em;
|
}
|
||||||
padding-right: 2em;
|
|
||||||
border-radius: 0.5em;
|
|
||||||
|
|
||||||
font-size: 1em;
|
.select-box_content {
|
||||||
color: white;
|
position: relative;
|
||||||
|
margin: 0 auto;
|
||||||
|
|
||||||
appearance: none;
|
min-width: 10em;
|
||||||
-moz-appearance: none;
|
|
||||||
-webkit-appearance: none;
|
|
||||||
|
|
||||||
cursor: pointer;
|
background: #333;
|
||||||
|
|
||||||
transition: all 0.3s;
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
&:focus {
|
.options {
|
||||||
// border: 1px solid red;
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
left: 0;
|
||||||
|
|
||||||
background: #777;
|
z-index: 10;
|
||||||
|
|
||||||
option {
|
width: 100%;
|
||||||
background: #333;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
label {
|
margin-top: 0.25em;
|
||||||
position: relative;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.arrows {
|
button.selected {
|
||||||
$arrowCol: #d8d8d8;
|
background: #333;
|
||||||
$arrowWidth: 0.35em;
|
color: white;
|
||||||
|
|
||||||
position: absolute;
|
font-size: 1em;
|
||||||
top: 20%;
|
|
||||||
// right: 0.25em;
|
|
||||||
|
|
||||||
pointer-events: none;
|
padding: 0.35em 0.5em;
|
||||||
|
padding-right: 2em;
|
||||||
|
|
||||||
&::before,
|
width: 100%;
|
||||||
&::after {
|
cursor: pointer;
|
||||||
content: "";
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
|
|
||||||
position: absolute;
|
border: none;
|
||||||
right: 0.5em;
|
outline: none;
|
||||||
|
|
||||||
border-left: $arrowWidth solid transparent;
|
text-align: left;
|
||||||
border-right: $arrowWidth solid transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
&::before {
|
&:focus {
|
||||||
border-top: $arrowWidth solid $arrowCol;
|
background: #555;
|
||||||
|
|
||||||
transform: translateY(150%);
|
|
||||||
}
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
border-bottom: $arrowWidth solid $arrowCol;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
|
||||||
|
-webkit-appearance: none;
|
||||||
|
-moz-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
border: none;
|
||||||
|
|
||||||
|
&:focus + span {
|
||||||
|
color: $accentCol;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
display: inline-block;
|
||||||
|
background: #333;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus {
|
||||||
|
background: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
padding: 0.25em 0;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -16,18 +16,19 @@
|
|||||||
</a>
|
</a>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<select-box
|
<div class="checkpoints">
|
||||||
v-if="stationInfo && stationInfo.checkpoints"
|
<select-box
|
||||||
:title="selectedOption"
|
v-if="stationInfo && stationInfo.checkpoints"
|
||||||
:itemList="
|
:title="selectedOption"
|
||||||
stationInfo.checkpoints.map((cp, i) => ({
|
:itemList="
|
||||||
id: cp.checkpointName,
|
stationInfo.checkpoints.map((cp, i) => ({
|
||||||
value: cp.checkpointName,
|
id: cp.checkpointName,
|
||||||
}))
|
value: cp.checkpointName,
|
||||||
"
|
}))
|
||||||
bgColor="#444"
|
"
|
||||||
@selected="chooseOption"
|
@selected="chooseOption"
|
||||||
></select-box>
|
></select-box>
|
||||||
|
</div>
|
||||||
|
|
||||||
<span class="timetable-item loading" v-if="dataStatus == 0">{{
|
<span class="timetable-item loading" v-if="dataStatus == 0">{{
|
||||||
$t("app.loading")
|
$t("app.loading")
|
||||||
@@ -162,8 +163,8 @@ export default class SceneryTimetable extends Vue {
|
|||||||
this.loadSelectedOption();
|
this.loadSelectedOption();
|
||||||
}
|
}
|
||||||
|
|
||||||
chooseOption(name: string) {
|
chooseOption(item: { id: number | string; value: string }) {
|
||||||
this.selectedOption = name;
|
this.selectedOption = item.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
get currentURL() {
|
get currentURL() {
|
||||||
@@ -381,6 +382,15 @@ h3 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.checkpoints {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
& > div {
|
||||||
|
border: 1px solid white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.arrow {
|
.arrow {
|
||||||
border: solid white;
|
border: solid white;
|
||||||
border-width: 0 2px 2px 0;
|
border-width: 0 2px 2px 0;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<select-box
|
<select-box
|
||||||
:title="$t('trains.option-distance')"
|
:title="$t('trains.option-distance')"
|
||||||
:itemList="translatedSorterOptions"
|
:itemList="translatedSorterOptions"
|
||||||
|
:defaultItemIndex="3"
|
||||||
@selected="changeSorter"
|
@selected="changeSorter"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -104,8 +105,8 @@ export default class TrainOptions extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Emit()
|
@Emit()
|
||||||
changeSorter(optionID: string) {
|
changeSorter(item: { id: string | number; value: string }) {
|
||||||
return { id: optionID, dir: -1 };
|
return { id: item.id, dir: -1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Watchers for search boxes */
|
/* Watchers for search boxes */
|
||||||
@@ -155,6 +156,10 @@ export default class TrainOptions extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.select-box {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
.search {
|
.search {
|
||||||
&-box {
|
&-box {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
+1
-2252
File diff suppressed because one or more lines are too long
@@ -1,4 +1,67 @@
|
|||||||
[
|
[
|
||||||
|
[
|
||||||
|
"Kszęty",
|
||||||
|
"https://td2.info.pl/scenerie/kszety-7118/",
|
||||||
|
"",
|
||||||
|
null,
|
||||||
|
"0",
|
||||||
|
"NIE",
|
||||||
|
"współczesna",
|
||||||
|
"SPK",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
null,
|
||||||
|
["Kszęty Podlesie"],
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Żerniki",
|
||||||
|
"https://td2.info.pl/scenerie/zerniki/",
|
||||||
|
"",
|
||||||
|
null,
|
||||||
|
"3",
|
||||||
|
"NIE",
|
||||||
|
"współczesna",
|
||||||
|
"SCS",
|
||||||
|
"Ol",
|
||||||
|
"TAK",
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
3,
|
||||||
|
0,
|
||||||
|
null,
|
||||||
|
["Ligota Żernicka"],
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Ligota Grabowska",
|
||||||
|
"https://td2.info.pl/scenerie/ligota-grabowska-projekt-1001/",
|
||||||
|
"",
|
||||||
|
"Projekt 1001",
|
||||||
|
"0",
|
||||||
|
"NIE",
|
||||||
|
"współczesna",
|
||||||
|
"SPK",
|
||||||
|
"",
|
||||||
|
"TAK",
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
["Ligota Grabowska", "Ligota Trzeszcze"],
|
||||||
|
["Ligota Stadion", "Czystobór"],
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"Blaszki",
|
"Blaszki",
|
||||||
"https://td2.info.pl/scenerie/blaszki/",
|
"https://td2.info.pl/scenerie/blaszki/",
|
||||||
@@ -267,7 +330,7 @@
|
|||||||
2,
|
2,
|
||||||
0,
|
0,
|
||||||
["Skrzynki", "Wykno"],
|
["Skrzynki", "Wykno"],
|
||||||
["Skrzynki"],
|
["Skrzynki", "Wykno"],
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ button,
|
|||||||
input,
|
input,
|
||||||
select {
|
select {
|
||||||
// font-family: "Open Sans", sans-serif;
|
// font-family: "Open Sans", sans-serif;
|
||||||
|
border: none;
|
||||||
font-family: "Quicksand", sans-serif;
|
font-family: "Quicksand", sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user