<script lang="ts">
    import { appInfo, translations, translate } from "@/stores"

    $: t = (key: string) => translate($translations, key)

    let repoLink = ""
    let upstreamLink = ""
    let issuesLink = ""

    const currentYear = new Date().getFullYear()

    appInfo.subscribe(info => {
        repoLink = info.repositoryLink
        upstreamLink = info.upstreamLink
        issuesLink = info.issuesLink
    })
</script>

<footer id="footer">
    <p>© {currentYear} J.A.R.V.I.S.</p>
    <p class="links">
        <a href={repoLink} target="_blank" rel="noopener noreferrer">
            <img src="/media/icons/github-logo.png" alt="GitHub" width="18px" />
            &nbsp;<span>{t('footer-github')}</span>
        </a>
        &nbsp;·&nbsp;
        <a href={issuesLink} target="_blank" rel="noopener noreferrer">
            <span>{t('footer-issues')}</span>
        </a>
    </p>
    <p class="links last">
        <small>
            {t('footer-fork-of')}
            <a href={upstreamLink} target="_blank" rel="noopener noreferrer">Priler/jarvis</a>
            · CC BY-NC-SA 4.0
        </small>
    </p>
</footer>

<style lang="scss">
    #footer {
        text-align: center;
        color: #6c6e71;
        font-size: 13px;
        font-weight: normal;
        line-height: 1.7em;
        margin-top: 15px;

        p {
            margin: 0;
            padding: 0;

            &.links {
                margin-top: 5px;
                margin-bottom: 15px;

                &.last {
                    margin-top: -5px;
                    color: #8a8d90;
                    font-size: 11px;
                }
            }
        }

        a {
            color: #555759 !important;
            text-decoration: none;
            transition: 0.3s;

            & > span {
                color: #185876;
                border-bottom: 1px solid #185876;
                transition: 0.3s;
            }

            img {
                opacity: 0.5;
                transition: opacity 0.5s;
                margin-top: -3px;
            }

            &:hover {
                color: #777a7d !important;

                & > span {
                    color: #2A9CD0;
                }

                img {
                    opacity: 1;
                }
            }
        }
    }
</style>
