diff --git a/src/App.vue b/src/App.vue index 9721da6..37dc043 100644 --- a/src/App.vue +++ b/src/App.vue @@ -150,7 +150,7 @@ main { min-height: 75vh; grid-template-columns: 1fr 2fr; - grid-template-rows: 350px auto; + grid-template-rows: 330px minmax(400px, 1fr); padding: 0.5em; } diff --git a/src/components/InputsSection.vue b/src/components/InputsSection.vue index 0e856c7..e89ff0c 100644 --- a/src/components/InputsSection.vue +++ b/src/components/InputsSection.vue @@ -4,7 +4,17 @@

WYBIERZ POJAZDY / WAGONY

- +
+ +
+ ({ - chosenLocomotiveType: '', - chosenCarWagonType: '', + locomotiveTypeList: [ + { + id: 'loco-e', + value: 'ELEKTR', + desc: 'ELEKTRYCZNE', + }, + { + id: 'loco-s', + value: 'SPAL', + desc: 'SPALINOWE', + }, + { + id: 'loco-ezt', + value: 'EZT', + desc: 'ELEKTR. ZESPOŁY TRAKCYJNE', + }, + { + id: 'loco-szt', + value: 'SZT', + desc: 'SPAL. ZESPOŁY TRAKCYJNE', + }, + ] as ILocoType[], + + carTypeList: [ + { + id: 'car-passenger', + value: 'PAS', + desc: 'PASAŻERSKIE', + }, + { + id: 'car-cargo', + value: 'TOW', + desc: 'TOWAROWE', + }, + ], }), setup() { @@ -115,36 +173,34 @@ export default defineComponent({ }; }, - // mounted() { - // document.addEventListener('keydown', (ev) => { - // const keyName = ev.key.toLowerCase(); - // if (keyName == 'enter') { - // ev.preventDefault(); - // this.addVehicle(); - // } - - // if (keyName == 'backspace') { - // if (this.store.stockList.length == 0) return; - - // const lastStock = this.store.stockList.slice(-1)[0]; - - // if (lastStock.count > 1) lastStock.count--; - // else this.store.stockList.splice(-1); - // } - // }); - // }, - computed: { locoOptions() { - return this.store.locoDataList.sort((a, b) => (a.type > b.type ? 1 : -1)); + return this.store.locoDataList + .sort((a, b) => (a.type > b.type ? 1 : -1)) + .filter((loco) => loco.power == this.store.chosenLocoPower); }, carOptions() { - return this.store.carDataList.sort((a, b) => (a.type > b.type ? 1 : -1)); + return this.store.carDataList + .sort((a, b) => (a.type > b.type ? 1 : -1)) + .filter((car) => car.useType == this.store.chosenCarUseType); }, }, methods: { + selectLocoType(locoTypeId: string) { + this.store.chosenLocoPower = locoTypeId; + this.store.chosenVehicle = this.locoOptions[0]; + this.store.chosenLoco = this.locoOptions[0]; + }, + + selectCarWagonType(carWagonTypeId: string) { + this.store.chosenCarUseType = carWagonTypeId; + this.store.chosenVehicle = this.carOptions[0]; + this.store.chosenCar = this.carOptions[0]; + this.store.chosenCargo = null; + }, + prepareSwapVehicles() { this.store.swapVehicles = true; }, @@ -256,66 +312,53 @@ export default defineComponent({ grid-row: 1; grid-column: 1; +} - &_car { - &.disabled { - opacity: 0.75; - pointer-events: none; - } +.input_header { + margin-bottom: 1em; +} + +.btn--choice { + margin-right: 0.5em; + font-weight: bold; + + background-color: #444; + + &[data-selected='true'] { + background-color: $accentColor; + color: black; + } + + transition: all 120ms ease; +} + +.input_list { + margin: 0.5em 0; + + label { + display: block; + + font-weight: bold; + color: $accentColor; + margin-bottom: 0.3em; + } + + select:focus { + border-color: $accentColor; } } -.input { - &_header { - margin-bottom: 1em; +.input_actions { + display: flex; + flex-wrap: wrap; + + button { + margin: 0.5em 0.5em 0 0; } +} - &_list { - margin: 0.5em 0; - - label { - display: block; - - font-weight: bold; - color: $accentColor; - margin-bottom: 0.3em; - } - - select:focus { - border-color: $accentColor; - } - } - - &_list button { - margin-left: 0.5em; - font-weight: bold; - - &:hover img { - border-color: $accentColor; - } - - &:focus img { - border-color: $accentColor; - } - - img { - border: 2px solid white; - padding: 0.25em; - - height: 2.35em; - - vertical-align: middle; - } - } - - &_actions { - display: flex; - flex-wrap: wrap; - - button { - margin: 0.5em 0.5em 0 0; - } - } +.vehicle-types { + margin-bottom: 0.5em; } @media screen and (max-width: $breakpointMd) { diff --git a/src/components/ListSection.vue b/src/components/ListSection.vue index 896be7f..b7ea7b4 100644 --- a/src/components/ListSection.vue +++ b/src/components/ListSection.vue @@ -8,43 +8,70 @@
-
+
POJAZD NR {{ store.chosenStockListIndex + 1 }}  
- - + -
- - -
-
Wybierz pojazd z listy poniżej, aby pokazać opcje
-
Masa: {{ store.totalMass }}t | Długość: @@ -234,14 +261,15 @@ export default defineComponent({ const chosenLoco = this.store.locoDataList.find((v) => v.type == vehicle.type) || null; this.store.chosenVehicle = chosenLoco; this.store.chosenLoco = chosenLoco; - // this.store.chosenCargo = null; + this.store.chosenLocoPower = vehicle.useType; } else { const chosenCar = this.store.carDataList.find((v) => v.type == vehicle.type) || null; this.store.chosenVehicle = chosenCar; this.store.chosenCar = chosenCar; this.store.chosenCargo = vehicle.cargo || null; + this.store.chosenCarUseType = vehicle.useType; } if (this.store.swapVehicles) { @@ -436,6 +464,16 @@ export default defineComponent({ margin: 1em 0; outline: 1px solid white; + &[data-disabled='true'] { + opacity: 0.8; + + user-select: none; + -moz-user-select: none; + -webkit-user-select: none; + + pointer-events: none; + } + &.no-chosen-vehicle { font-size: 1.05em; padding: 0.5em; @@ -454,16 +492,13 @@ export default defineComponent({ margin: 0.25em; padding: 0.25em; - border: 2px solid gray; - border-radius: 0.25em; - &:focus-visible { outline: 1px solid white; } img { vertical-align: text-bottom; - margin-right: 0.5em; + margin-right: 0.25em; width: 1.1em; height: 1.1em; @@ -479,13 +514,11 @@ export default defineComponent({ ul { position: relative; - overflow-y: auto; - overflow-x: hidden; + overflow: auto; height: 50vh; min-height: 500px; margin-top: 1em; - padding: 0.25em; } ul > li { @@ -503,7 +536,7 @@ ul > li { } &.list-empty { - outline: 1px solid white; + border: 1px solid white; padding: 0.5em; } } diff --git a/src/components/TrainImageSection.vue b/src/components/TrainImageSection.vue index b302d1e..7c6c204 100644 --- a/src/components/TrainImageSection.vue +++ b/src/components/TrainImageSection.vue @@ -14,15 +14,14 @@
- {{ store.chosenVehicle.type }} + {{ store.chosenVehicle.type }} • + {{ + vehicleTypes[ + isLocomotive(store.chosenVehicle) ? store.chosenVehicle.power : store.chosenVehicle.useType || 'loco-e' + ] + }}
- {{ - vehicleTypes[ - isLocomotive(store.chosenVehicle) ? store.chosenVehicle.power : store.chosenVehicle.useType || 'loco-e' - ] - }} -
{{ store.chosenVehicle.length }}m | {{ store.chosenVehicle.mass }}t | {{ store.chosenVehicle.maxSpeed }} km/h @@ -103,13 +102,12 @@ export default defineComponent({ grid-row: 2; grid-column: 1; - display: flex; + margin-top: 2em; } .train-image { &__wrapper { text-align: center; - } &__content { @@ -156,6 +154,7 @@ export default defineComponent({ .train-image__info { margin: 1em 0; font-size: 1.1em; + padding: 0 1em; b { font-size: 1.1em; diff --git a/src/styles/global.scss b/src/styles/global.scss index b581da2..70e3cc4 100644 --- a/src/styles/global.scss +++ b/src/styles/global.scss @@ -113,6 +113,18 @@ button.btn { font-weight: bold; transition: all 250ms; border: none; + + &:focus-visible { + outline: 1px solid white; + } + } + + &--choice { + padding: 0.25em 0.3em; + + &:focus-visible { + outline: 1px solid white; + } } }