<template>
  <section class="info-header">
    <button class="btn btn-return" :title="$t('scenery.return-btn')" @click="onReturnButtonClick">
      <img src="/images/icon-back.svg" alt="return button" />
    </button>

    <div class="scenery-name">
      <a v-if="station?.generalInfo" :href="station.generalInfo.url" target="_blank">
        {{ stationName.replace(/_/g, ' ') }}
      </a>

      <span v-else> {{ stationName.replace(/_/g, ' ') }}</span>
    </div>

    <div class="scenery-hash" v-if="onlineScenery?.hash">#{{ onlineScenery.hash }}</div>
  </section>
</template>

<script lang="ts" setup>
import { onMounted, PropType, ref } from 'vue';
import { ActiveScenery, Station } from '../../typings/common';
import { useRoute, useRouter } from 'vue-router';

const route = useRoute();
const router = useRouter();

defineProps({
  station: {
    type: Object as PropType<Station>
  },

  stationName: {
    type: String,
    required: true
  },

  onlineScenery: {
    type: Object as PropType<ActiveScenery>
  }
});

function onReturnButtonClick() {
  router.push('/');
}
</script>

<style lang="scss" scoped>
@use '../../styles/responsive';
@use 'sass:color';

.btn-return {
  $bgColor: #2b2b2b;
  background-color: $bgColor;

  &:hover {
    background-color: color.adjust($color: $bgColor, $lightness: 15%);
  }

  img {
    height: 2em;
  }
}

.scenery-name {
  font-weight: bold;
  font-size: 3em;

  text-align: center;

  text-transform: uppercase;
}

.scenery-hash {
  color: #aaa;
  font-size: 1.2em;
}

@include responsive.smallScreen {
  .scenery-name {
    font-size: 2.5em;
  }
}
</style>
