Центр финансов

Сайт по управлению капиталом, а также сбора информации.

Проект объединяет в одной системе направления: управление, статистику и информацию.

imageAlt

Управление

Ведение доходов, расходов. Выбор мест сохранения денег. Работа со списками. Контроль бюджетов (в первую очередь - личный).

imageAlt

Статистика

Показ Графиков на основе данных контроля. Главная цель блока - автоматизация преобразований.

imageAlt

Информация

Сбор источников информации (автоматизация их). Постройка экономических моделей. Предположения.

Пример кода

<template>
    <div
        class="btn-box"
        :class="[typeIntoComp]"
    >
        <button
            :class="[
                'btn',
                colorIntoComp,
                'btn-type-$/{typeIntoComp}',
                { 'btn-hover': isHover },
                { 'btn-skeleton': isSkeleton },
                { 'btn-loading': isLoading },
                { 'btn-disabled': isDisabled },
            ]"
        >
            <slot name="text"></slot>
        </button>
        <div
            ref="svgBox"
            class="absolute inset-0"
            :class="[{ '-z-1': !isLoading }]"
        ></div>
        <div
            class="skeleton-bar"
            v-if="isSkeleton"
        ></div>
    </div>
</template>

<script setup>
    import { SVG } from '@svgdotjs/svg.js';
    import { animate, linear } from 'animejs';
    import { ref } from 'vue';

    const typesOfColors = [
        'primary',
        'secondary',
        'success',
        'error',
        'warning',
        'cancel',
    ];
    const typesOftypes = ['filled', 'bordered'];

    const props = defineProps({
        color: {
            type: String,
            default: 'primary',
        },
        type: {
            type: String,
            default: 'filled',
        },
        isHover: {
            type: Boolean,
            default: false,
        },
        isLoading: {
            type: Boolean,
            default: false,
        },
        isSkeleton: {
            type: Boolean,
            default: false,
        },
        isDisabled: {
            type: Boolean,
            default: false,
        },
    });

    const colorIntoComp = ref(
        typesOfColors.includes(props.color) ? props.color : typesOfColors[0]
    );
    const typeIntoComp = ref(
        typesOftypes.includes(props.type) ? props.type : typesOftypes[0]
    );

    const svgBox = ref();
    const skeletonAnimation = ref(null);
    const svg = ref(null);

    async function animationRun() {
        const boxWidth = svgBox.value.clientWidth;
        const boxHeight = svgBox.value.clientHeight;

        svg.value = SVG()
            .addTo(svgBox.value)
            .size('100%', '100%')
            .viewbox('0 0 $/{boxWidth} $/{boxHeight}');

        const radius = 6;
        const startcCircle = 'A $/{radius} $/{radius} 0 0';
        const startCircleRight = '$/{startcCircle} 1';

        const path = '
    M $/{boxWidth / 2} 0 
    H $/{boxWidth - radius}
    $/{startCircleRight} $/{boxWidth} $/{radius}
    V $/{boxHeight - radius}
    $/{startCircleRight} $/{boxWidth - radius} $/{boxHeight}
    H $/{radius}
    $/{startCircleRight} 0 $/{boxHeight - radius}
    V $/{radius}
    $/{startCircleRight} $/{radius} 0
    H $/{boxWidth / 2}
  ';

        svg.value
            .path(path)
            .stroke({
                width: 2,
                color: '#ffffff',
                dasharray: '48 $/{2 * (boxHeight + boxWidth - 27)}',
                dashoffset: 0,
                linecap: 'round',
            })
            .fill('none');

        skeletonAnimation.value = animate(svgBox.value.querySelector('path'), {
            strokeDashoffset: -4 * (boxHeight + boxWidth),
            duration: 3000,
            loop: true,
            autoplay: true,
            ease: linear(0, 1),
        });
    }
    watch(
        () => props.isLoading,
        async () => {
            if (props.isLoading) {
                animationRun();
            } else {
                skeletonAnimation.value.cancel();
                svg.value.remove();
                skeletonAnimation.value = null;
            }
        }
    );

    onMounted(() => {
        if (props.isLoading) {
            animationRun();
        }
    });
</script>

<style lang="scss" scoped>
    .btn-box {
        position: relative;
        z-index: 10;
        width: fit-content;
    }

    .btn {
        min-width: 150px;
        width: fit-content;
        max-width: 450px;
        min-height: 40px;
        height: fit-content;
        max-height: 100px;

        padding: 10px;

        border-radius: 6px;
        border-width: 2px;
        border-style: solid;

        font-weight: 600;
        font-size: 16px;

        user-select: none;
        transition: all 0.2s ease-out;

        &-type {
            &-filled {
                background-color: var(--main-03);
                border-color: var(--main-0);
            }

            &-bordered {
                background-color: var(--fon-1);
                border-color: var(--main-03);
            }
        }

        &-hover,
        &:not(.btn-loading):not(.btn-skeleton):not(.btn-disabled):hover {
            &.btn-type-bordered {
                border-color: var(--main-1);
            }

            &.btn-type-filled {
                background-color: var(--main-1);
            }
        }

        &-loading {
            color: var(--main-0);
        }

        &-skeleton {
            color: var(--main-0);
        }

        &-disabled {
            opacity: 0.3;
        }
    }

    .btn:not(.btn-loading):not(.btn-skeleton):not(.btn-disabled) {
        cursor: pointer;
    }

    .filled {
        .btn:not(.btn-loading):not(.btn-skeleton):not(.btn-disabled):not(
                .btn-type-bordered
            ):hover {
            background-color: var(--main-1);
        }

        .btn-loading {
            background-color: var(--main-03);
        }

        .skeleton-bar {
            background: var(--skeleton-bar-black);
        }
    }

    .bordered {
        .skeleton-bar {
            background: var(--skeleton-bar-white);
        }
    }

    .skeleton-bar {
        position: absolute;
        z-index: 11;
        top: 0;
        left: 0;

        transform: translateX(0%) scale(100%, 100%);
        width: 100%;
        height: 100%;

        border-radius: 6px;

        animation-duration: 3s;
        animation-name: skeletonBar;
        animation-iteration-count: infinite;
    }

    @keyframes skeletonBar {
        0% {
            transform: translateX(-50%) scale(0%, 100%);
            opacity: 0;
        }

        50% {
            transform: translateX(0%) scale(100%, 100%);
            opacity: 1;
        }

        100% {
            transform: translateX(50%) scale(0%, 100%);
            opacity: 0;
        }
    }
</style>