HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/blog.affstore/src/components/author/Author.svelte
<script lang="ts">
  import { locale } from '$lib/translations';
  import { AVATAR_TYPE } from '../../type/global';
  import type { IUser } from '../../type/user';

  export let author: IUser;
  export let type: AVATAR_TYPE = AVATAR_TYPE.DEFAULT;
  export let date: string | undefined = undefined;
  export let className: string | undefined = '';

  let createText = '';

  if (date) {
    const createDate = new Date(date);

    const createMonthName = createDate.toLocaleString($locale, { month: 'long' });

    createText = createMonthName + ' ' + createDate.getDate() + ', ' + createDate.getFullYear();
  }
</script>

{#if author}
  <a href={`/${$locale}/author/${author.slug}`} class="author {type} {className}">
    <img src={author.avatar} alt="" class="author__avatar" />
    <div class="author__content">
      <p class="author__name">{author.name}</p>
      {#if !!date}
        <p class="author__date">{createText}</p>
      {:else}
        <p class="author__post">{author.position[$locale]}</p>
      {/if}
    </div>
  </a>
{/if}

<style lang="scss">
  @import 'src/scss/media';
  @import 'src/scss/mixins';
  @import 'src/scss/variables';

  .author {
    display: flex;
    align-items: center;
    gap: 12px;

    &__avatar {
      width: 48px;
      min-width: 48px;
      height: 48px;
      border-radius: 100px;
      background: $grey100;
    }

    &__name {
      @include headingS;
    }

    &__post {
      @include defaultS;

      color: $grey150;
    }

    &__date {
      font-size: 12px;
      font-weight: 400;
      line-height: 18px;

      color: $grey150;
    }

    &.small {
      gap: 10px;

      .author__avatar {
        width: 32px;
        min-width: 32px;
        height: 32px;
      }
    }

    &.middle {
      gap: 16px;

      @include breakpoint-down('tabM') {
        gap: 12px;
      }

      @include breakpoint-down('tabS') {
        gap: 10px;
      }

      .author__avatar {
        width: 72px;
        min-width: 72px;
        height: 72px;

        @include breakpoint-down('tabM') {
          width: 48px;
          min-width: 48px;
          height: 48px;
        }

        @include breakpoint-down('tabS') {
          width: 32px;
          min-width: 32px;
          height: 32px;
        }
      }

      .author__name {
        @include headingL;

        @include breakpoint-down('tabM') {
          @include headingS;
        }
      }

      .author__post {
        @include defaultM;

        @include breakpoint-down('tabM') {
          @include defaultS;
        }
      }
    }

    &.big {
      gap: 16px;

      @include breakpoint-down('tabS') {
        gap: 12px;
      }

      .author__avatar {
        width: 96px;
        min-width: 96px;
        height: 96px;

        @include breakpoint-down('deskM') {
          width: 72px;
          min-width: 72px;
          height: 72px;
        }

        @include breakpoint-down('tabS') {
          width: 48px;
          min-width: 48px;
          height: 48px;
        }
      }

      .author__name {
        @include headingL;

        @include breakpoint-down('tabS') {
          @include headingS;
        }
      }

      .author__post {
        @include defaultM;

        @include breakpoint-down('tabS') {
          @include defaultS;
        }
      }
    }
  }
</style>