anyone-oslo/pages

View on GitHub
app/assets/stylesheets/pages_core/admin/components/image_editor.css

Summary

Maintainability
Test Coverage
.editable-image {
  cursor: pointer;
  display: block;
  transition:
    transform 200ms,
    box-shadow 200ms,
    border-color 200ms ease-out;
  box-shadow: 0px 2px 5px rgba(0, 0, 0, 0);
  border: 1px solid #fff;
  position: relative;
  -webkit-perspective: 1000;

  .alt-warning {
    position: absolute;
    bottom: 5px;
    right: 6px;
    font-size: 1rem;
    color: var(--background-warning-color);
    text-shadow: 0px 0px 5px rgba(0, 0, 0, 1);
    z-index: 100;
  }

  img {
    display: block;
  }

  &:hover {
    border-color: rgba(20, 20, 20, 0.5);
    transform: scale(1.01) translate(0px, -1px);
    box-shadow: 0px 5px 20px rgba(0, 0, 0, 0.2);
  }
}

.image-editor {
  width: 80vw;
  height: 80vh;
  display: flex;

  @media (--mobile) {
    width: 100%;
    height: 100%;
    flex-direction: column;
  }

  .toolbars {
    .aspect-ratios {
      border-top: 0px;
    }
  }

  .visual {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
  }

  .image-container {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    background: #e5e5e5;
    background-image: linear-gradient(45deg, #fff 25%, transparent 25%),
      linear-gradient(135deg, #fff 25%, transparent 25%),
      linear-gradient(45deg, transparent 75%, #fff 75%),
      linear-gradient(135deg, transparent 75%, #fff 75%);
    background-size: 12px 12px;
    background-position:
      0 0,
      6px 0,
      6px -6px,
      0px 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--border-color);
    border-top: 0px;

    .image-wrapper {
      position: absolute;
      flex-grow: 0;

      @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
        position: relative;
      }

      img {
        display: block;
        width: 100%;
        height: auto;
      }

      .ReactCrop {
        width: 100%;
        background-color: transparent;
      }

      .ReactCrop__crop-selection {
        &:before,
        &:after {
          content: "";
          position: absolute;
          border: 0px solid rgb(200, 200, 200);
          opacity: 0.25;
          transition: opacity 200ms ease-out;
        }

        &:before {
          border-left-width: 1px;
          border-right-width: 1px;
          width: 33.33%;
          height: 100%;
          left: 33.33%;
        }

        &:after {
          border-top-width: 1px;
          border-bottom-width: 1px;
          width: 100%;
          height: 33.33%;
          top: 33.33%;
        }
      }

      .ReactCrop--active .ReactCrop__crop-selection {
        &:before,
        &:after {
          opacity: 0.75;
        }
      }
    }

    .loading {
      color: var(--text-light-color);
    }
  }

  form {
    width: 300px;
    display: block;
    margin-left: 20px;

    textarea {
      max-width: 100%;

      &.caption {
        height: 100px;
      }
    }

    .embed-code {
      input {
        width: 50%;
        margin-right: 8px;
      }
    }

    @media (--mobile) {
      width: 100%;
      margin-left: 0px;
      padding-bottom: 20px;

      textarea.caption {
        height: inherit;
      }
    }
  }

  .focal-editor {
    position: absolute;
    width: 100%;
    height: 100%;
    touch-action: none;
    overflow: hidden;

    .focal-point {
      &:after {
        content: "";
        display: block;
        width: 32px;
        height: 32px;
        border-radius: 16px;
        border: 1px solid rgba(0, 0, 0, 0.3);
        margin-left: -4px;
        margin-top: -4px;
        transition: all 200ms ease-out;
      }
      position: absolute;
      width: 30px;
      height: 30px;
      border: 3px solid rgba(222, 255, 255, 0.5);
      border-radius: 15px;
      margin-left: -15px;
      margin-top: -15px;
      top: 0px;
      left: 0px;
      touch-action: none;
      user-select: none;
      cursor: pointer;
      transition:
        border-radius 200ms,
        margin 200ms,
        width 200ms,
        height 200ms,
        border-color 200ms ease-out;

      &:hover {
        &:after {
          width: 42px;
          height: 42px;
          border-radius: 21px;
        }
        border-color: rgba(222, 255, 255, 0.9);
        width: 40px;
        height: 40px;
        border-radius: 20px;
        margin-left: -20px;
        margin-top: -20px;
      }
    }
  }
}