Newer
Older
vmk-ui-kit / src / scss / components / _option-card.scss
@Eugene Sukhodolskiy Eugene Sukhodolskiy 19 hours ago 7 KB so many changes
/* =========================
   Option Card
   Figma: Option Card / Campaign search card / Contact search card.
   A search-result-style card with media, price, area, badges and actions.
========================= */

@use "../kit-deps" as *;

.option-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 420px;
  background-color: $neutral-0;
  border: 1px solid $neutral-200;
  border-radius: $radius-xl;
  overflow: hidden;
  cursor: pointer;
  transition:
    box-shadow $motion-base $motion-ease,
    border-color $motion-base $motion-ease;

  @include hover_touch {
    border-color: $neutral-300;
    box-shadow: 0 4px 24px rgba($neutral-900, 0.08);
  }

  &__indicator {
    position: absolute;
    top: $space-5;
    right: $space-5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: $radius-full;
    border: 2px solid $neutral-300;
    background-color: transparent;
    color: $neutral-0;
    pointer-events: none;
    transition:
      border-color $motion-base $motion-ease,
      background-color $motion-base $motion-ease;

    &--radio::after {
      content: "";
      width: 10px;
      height: 10px;
      border-radius: $radius-full;
      background-color: currentColor;
      opacity: 0;
      transform: scale(0);
      transition:
        opacity $motion-base $motion-ease,
        transform $motion-base $motion-ease;
    }

    &--check::after {
      content: "";
      width: 12px;
      height: 7px;
      border-left: 2px solid currentColor;
      border-bottom: 2px solid currentColor;
      opacity: 0;
      transform: rotate(-45deg) scale(0.8);
      transition:
        opacity $motion-base $motion-ease,
        transform $motion-base $motion-ease;
    }
  }

  &--selectable {
    cursor: pointer;

    &.is-selected,
    &[aria-selected="true"] {
      border-color: $lavender-600;
      background-color: $neutral-0;
      box-shadow: 0 0 0 1px $lavender-600;

      .option-card__icon {
        background: linear-gradient(135deg, rgba($mint-500, 0.12), rgba($yellow-400, 0.12));
        border-color: $lavender-600;
      }

      .option-card__indicator--radio {
        border-color: $mint-500;
        background-color: $mint-500;

        &::after {
          opacity: 1;
          transform: scale(1);
        }
      }

      .option-card__indicator--check {
        border-color: $success-text;
        background-color: $success-text;

        &::after {
          opacity: 1;
          transform: rotate(-45deg) scale(1);
        }
      }
    }
  }

  &--lg {
    max-width: 320px;

    .option-card-media {
      display: none;
    }

    .option-card__icon {
      width: 56px;
      height: 56px;
      border-radius: $radius-lg;
      border: 1px solid $neutral-200;
      background-color: $neutral-50;
      margin-bottom: $space-2;
    }

    .option-card-title {
      font-size: $font-size-lg;
      font-weight: $font-weight-bold;
      color: $neutral-900;
    }

    .option-card-description {
      color: $neutral-500;
      font-size: $font-size-md;
    }

    .option-card-body {
      gap: $space-3;
      padding: $space-6;
    }
  }

  &__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: $radius-md;
    border: 1px solid $neutral-100;
    background-color: $neutral-50;
    color: $lavender-700;

    .vmk-icon,
    .ph {
      width: 28px;
      height: 28px;
    }
  }

  &.option-card-horizontal {
    flex-direction: row;
    max-width: 720px;

    .option-card-media {
      flex: 0 0 38%;
      min-width: 140px;
      max-width: 280px;
      aspect-ratio: auto;
      height: auto;
    }

    .option-card-body {
      flex: 1 1 auto;
    }
  }

  &.option-card-expanded {
    .option-card-stats {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: $space-4;
      padding: $space-3 $space-4;
      border-top: 1px solid $neutral-100;

      .option-card-stat {
        display: flex;
        align-items: center;
        gap: $space-2;
        color: $neutral-600;
        font-size: $font-size-sm;
        font-weight: $font-weight-semibold;

        .ph {
          color: $neutral-400;
          font-size: $icon-size-md;
        }

        strong {
          color: $neutral-900;
          font-weight: $font-weight-bold;
        }
      }
    }
  }
}

.option-card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background-color: $neutral-100;
  overflow: hidden;

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .option-card-media-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: $neutral-400;
    font-size: $icon-size-xl;
  }

  .option-card-match {
    position: absolute;
    top: $space-3;
    left: $space-3;
    display: inline-flex;
    align-items: center;
    gap: $space-2;
    padding: $space-1 $space-2;
    border-radius: $radius-md;
    background-color: $neutral-0;
    color: $neutral-700;
    font-size: $font-size-xs;
    font-weight: $font-weight-semibold;
    box-shadow: 0 2px 8px rgba($neutral-900, 0.06);

    .ph {
      color: $success-text;
      font-size: $icon-size-sm;
    }
  }

  .option-card-media-count {
    position: absolute;
    bottom: $space-3;
    right: $space-3;
    padding: $space-1 $space-2;
    border-radius: $radius-md;
    background-color: rgba($neutral-900, 0.6);
    color: $neutral-0;
    font-size: $font-size-xs;
    font-weight: $font-weight-semibold;
  }

  .option-card-dots {
    position: absolute;
    bottom: $space-3;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: $space-1;

    span {
      width: 6px;
      height: 6px;
      border-radius: $radius-full;
      background-color: rgba($neutral-0, 0.5);

      &.is-active {
        background-color: $neutral-0;
      }
    }
  }
}

.option-card-body {
  display: flex;
  flex-direction: column;
  gap: $space-2;
  padding: $space-4;
}

.option-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: $space-3;
}

.option-card-price {
  display: flex;
  align-items: baseline;
  gap: $space-2;
  margin: 0;
  color: $neutral-900;
  font-size: $font-size-h4;
  font-weight: $font-weight-bold;
  line-height: 1.2;

  .option-card-area {
    color: $neutral-500;
    font-size: $font-size-sm;
    font-weight: $font-weight-semibold;
  }
}

.option-card-title {
  margin: 0;
  color: $neutral-500;
  font-size: $font-size-sm;
  font-weight: $font-weight-medium;
  line-height: 1.4;
}

.option-card-description {
  margin: 0;
  color: $neutral-500;
  font-size: $font-size-sm;
  line-height: $line-height-normal;
}

.option-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: $space-2;
  padding-top: $space-1;
}

.option-card-actions {
  display: flex;
  align-items: center;
  gap: $space-3;
  padding-top: $space-3;
}

.option-card-details {
  padding: $space-3 $space-4;
  border-top: 1px solid $neutral-100;
  background-color: $neutral-50;
}

.option-card-detail-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: $space-3;
  margin: 0;
  padding: 0;
  list-style: none;

  .option-card-detail-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: $space-3;
    color: $neutral-700;
    font-size: $font-size-sm;

    .ph {
      color: $neutral-500;
      margin-right: $space-2;
    }

    strong {
      color: $neutral-900;
      font-weight: $font-weight-semibold;
    }
  }
}

@media (max-width: 560px) {
  .option-card.option-card-horizontal {
    flex-direction: column;

    .option-card-media {
      max-width: none;
      aspect-ratio: 16 / 10;
    }
  }

  .option-card.option-card-expanded .option-card-stats {
    grid-template-columns: 1fr;
  }
}