<template>
  <div class="language">
    <div class="language-item" @click="setLanguage('zh')" :class="{ active: language === 'zh' }">中</div>
    <div class="language-item" @click="setLanguage('en')" :class="{ active: language === 'en' }">EN</div>
  </div>
</template>

<script setup>
import { useStore } from '@/store/root'
import { storeToRefs } from 'pinia'

const store = useStore()
const { language } = storeToRefs(store)

function setLanguage(lang) {
  store.language !== lang && store.SET_LANGUAGE(lang)
}
</script>

<style lang="scss" scoped>
.language {
  position: absolute;
  left: 24px;
  bottom: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 93px;
  height: 32px;
  border-radius: 12px;
  background-color: var(--color-black-opacity-02);
  padding: 0 3px;
}
.language-item {
  width: 43px;
  height: 26px;
  border-radius: 10px;
  text-align: center;
  line-height: 26px;
  font-size: 14px;
  color: var(--color-black-opacity-4);

  font-weight: bolder;
  &.active {
    background: var(--color-linear-lightgoldenyellow);
    color: var(--color-black-opacity-6);
  }
}
</style>
