Newer
Older
vmk-ui-kit / src / scss / components / _file-upload.scss
/* =========================
   File Upload & File Attachment
   Figma: Attached File.
   API kept compatible with gnexus-ui-kit.
========================= */

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

$file-attachment-size: 130px;

.file-upload-panel {
  width: 100%;
  max-width: 680px;
}

.file-upload-form {
  display: flex;
  flex-direction: column;
  gap: $space-4;
}

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

.file-upload-heading {
  display: flex;
  flex-direction: column;
  gap: $space-1;
}

.file-upload-title {
  margin: 0;
  color: $neutral-900;
  font-family: $font-family-base;
  font-size: 18px;
  font-weight: $font-weight-bold;
  line-height: 1.3;
}

.file-upload-description {
  margin: 0;
  color: $neutral-600;
  font-family: $font-family-base;
  font-size: 14px;
  line-height: 1.4;
}

.file-upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: $space-3;
  width: 100%;
  padding: $space-8 $space-6;
  border: 2px dashed $border-color-muted;
  border-radius: $radius-lg;
  background: $surface-panel-muted;
  color: $neutral-700;
  text-align: center;
  cursor: pointer;
  transition: border-color $motion-base $motion-ease, background-color $motion-base $motion-ease;

  &:hover,
  &.is-hover {
    border-color: $mint-600;
    background: rgba($mint-300, 0.24);
  }

  input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

.file-upload-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: $radius-full;
  background: $neutral-0;
  color: $mint-700;
  font-size: 24px;
}

.file-upload-body {
  display: flex;
  flex-direction: column;
  gap: $space-1;
}

.file-upload-primary {
  color: $neutral-900;
  font-family: $font-family-base;
  font-size: 15px;
  font-weight: $font-weight-semibold;
}

.file-upload-secondary {
  color: $neutral-600;
  font-family: $font-family-base;
  font-size: 13px;
}

.file-upload-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax($file-attachment-size, 1fr));
  gap: $space-5;
}

.file-attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax($file-attachment-size, 1fr));
  gap: $space-5;
  width: 100%;
  max-width: 640px;
}

.file-upload-preview-item,
.file-attachment {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: $file-attachment-size;
  height: $file-attachment-size;
  padding: 0;
  border: 0;
  border-radius: $radius-xl;
  background: $neutral-0;
  color: $neutral-900;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba($neutral-900, 0.06);
}

.file-upload-preview-remove,
.file-attachment-remove {
  position: absolute;
  top: $space-2;
  right: $space-2;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: $radius-full;
  background: transparent;
  color: $neutral-700;
  font-size: 16px;
  cursor: pointer;
  transition: color $motion-base $motion-ease, background-color $motion-base $motion-ease;

  &:hover,
  &.is-hover {
    color: $neutral-900;
    background: rgba($neutral-900, 0.06);
  }

  &:focus-visible {
    @include focus_ring;
  }
}

.file-upload-preview-visual,
.file-attachment-visual {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;

  img,
  svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  svg {
    width: 40px;
    height: 40px;
  }
}

.file-upload-preview-type,
.file-attachment-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: $radius-md;
  background: $neutral-100;
  color: $neutral-600;
  font-family: $font-family-base;
  font-size: 11px;
  font-weight: $font-weight-bold;
  text-transform: uppercase;
}

.file-upload-preview-name,
.file-attachment-name {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: auto;
  padding: 0 $space-3 $space-2;
  color: $neutral-900;
  font-family: $font-family-base;
  font-size: 12px;
  font-weight: $font-weight-semibold;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-upload-preview-meta,
.file-attachment-meta {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 0;
  padding: 0 $space-3 $space-3;
  color: $neutral-600;
  font-family: $font-family-base;
  font-size: 11px;
  line-height: 1.3;
}

.file-attachment-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: $space-2;
  padding: $space-2 $space-2 0;
}

.file-attachment-format {
  display: inline-flex;
  align-items: center;
  padding: $space-1 $space-2;
  border-radius: $radius-sm;
  background: $neutral-100;
  color: $neutral-700;
  font-family: $font-family-base;
  font-size: 11px;
  font-weight: $font-weight-bold;
  text-transform: uppercase;
  line-height: 1;
}

// State variants
.file-attachment.is-pdf,
.file-upload-preview-item.is-pdf {
  .file-attachment-format {
    background: $yellow-300;
    color: $neutral-900;
  }

  .file-attachment-remove {
    color: $neutral-900;
  }
}

.file-attachment.is-image,
.file-upload-preview-item.is-image,
.file-attachment.is-placeholder,
.file-upload-preview-item.is-placeholder {
  .file-attachment-format {
    background: $mint-300;
    color: $neutral-900;
  }

  .file-attachment-remove {
    color: $neutral-900;
  }
}

.file-attachment.is-placeholder,
.file-upload-preview-item.is-placeholder {
  .file-attachment-visual,
  .file-upload-preview-visual {
    background: repeating-conic-gradient($neutral-100 0% 25%, $neutral-0 0% 50%) 50% / 40px 40px;
  }

  .file-attachment-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
  }
}

.file-attachment.is-error,
.file-upload-preview-item.is-error,
.file-attachment.is-retry,
.file-upload-preview-item.is-retry {
  background: $neutral-100;

  .file-attachment-format {
    background: $neutral-200;
    color: $neutral-700;
  }

  .file-attachment-remove {
    color: $neutral-700;
  }

  .file-attachment-visual,
  .file-upload-preview-visual {
    color: $danger-text;
    font-size: 32px;

    &::before {
      content: "";
      position: absolute;
      width: 56px;
      height: 56px;
      border-radius: $radius-full;
      background: $neutral-0;
      z-index: -1;
    }
  }
}

.file-attachment.is-empty,
.file-upload-preview-item.is-empty {
  .file-attachment-visual,
  .file-upload-preview-visual {
    display: none;
  }
}

.file-upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: $space-2;
}