_preview-panel.scss 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. .preview-panel {
  2. height: 100%;
  3. display: flex;
  4. flex-direction: column;
  5. --preview-width-ratio: min(
  6. 1,
  7. var(--preview-panel-width, 450) / var(--preview-device-width, 375)
  8. );
  9. --preview-iframe-width: calc(1px * var(--preview-device-width, 375));
  10. &__area {
  11. height: 100%;
  12. display: flex;
  13. flex-direction: column-reverse;
  14. justify-content: space-between;
  15. // Needed for the warning message when the data is not valid.
  16. overflow: hidden;
  17. }
  18. &__wrapper {
  19. width: calc(var(--preview-iframe-width) * var(--preview-width-ratio));
  20. height: 100%;
  21. margin-inline-start: auto;
  22. margin-inline-end: auto;
  23. }
  24. &__iframe {
  25. transform-origin: 0 0;
  26. width: var(--preview-iframe-width);
  27. height: calc(100% / var(--preview-width-ratio));
  28. transform: scale(var(--preview-width-ratio));
  29. display: block;
  30. }
  31. &__sizes {
  32. @apply w-border-grey-100 w-border-b;
  33. display: flex;
  34. align-items: center;
  35. justify-content: center;
  36. gap: 0.75rem;
  37. padding-bottom: 1rem;
  38. margin-bottom: 1rem;
  39. }
  40. &__size-button {
  41. @apply w-text-grey-400 w-transition hover:w-transform hover:w-scale-110 hover:w-text-primary focus:w-text-primary;
  42. width: 2rem;
  43. height: 2rem;
  44. background: transparent;
  45. padding: 0;
  46. border-radius: 5px;
  47. display: grid;
  48. place-items: center;
  49. cursor: pointer;
  50. &:focus-within {
  51. @include focus-outline;
  52. }
  53. .icon {
  54. @include svg-icon(1rem);
  55. &.icon-tablet-alt,
  56. &.icon-desktop {
  57. @include svg-icon(1.25rem);
  58. }
  59. &.icon-link-external {
  60. @include svg-icon(0.9rem);
  61. }
  62. }
  63. input[type='radio'] {
  64. position: absolute;
  65. width: 0;
  66. height: 0;
  67. opacity: 0;
  68. }
  69. }
  70. &__refresh-button.button--icon {
  71. display: flex;
  72. align-items: center;
  73. gap: 0.5rem;
  74. position: absolute;
  75. top: 1.25rem;
  76. inset-inline-end: 1.5rem;
  77. .icon {
  78. @include svg-icon(0.9rem);
  79. }
  80. }
  81. &__spinner {
  82. position: absolute;
  83. top: 1.25rem;
  84. inset-inline-end: 1.5rem;
  85. }
  86. &--mobile &__size-button--mobile,
  87. &--tablet &__size-button--tablet,
  88. &--desktop &__size-button--desktop {
  89. @apply w-bg-primary w-text-white w-transform-none w-border w-border-transparent;
  90. }
  91. &__controls {
  92. @apply w-border-t w-border-transparent w-duration-500 w-ease-in-out;
  93. transition-property: border-color, margin-top, padding-top;
  94. margin-top: 0;
  95. padding-top: 0;
  96. // Show the border only if there's an error,
  97. // but always show it if there are multiple preview modes
  98. .preview-panel--has-errors &:not(&--multiple),
  99. &--multiple {
  100. @apply w-border-grey-100 w-border-t;
  101. padding-top: 1rem;
  102. margin-top: 1rem;
  103. }
  104. }
  105. &__error-banner {
  106. @apply w-text-grey-600 w-duration-1000 w-ease-in-out w-translate-y-20;
  107. transition-property: max-height, transform, visibility;
  108. visibility: hidden;
  109. max-height: 0;
  110. display: flex;
  111. align-items: center;
  112. gap: 1rem;
  113. position: relative;
  114. z-index: -1;
  115. .icon {
  116. @apply w-text-warning-100;
  117. }
  118. }
  119. &--has-errors &__error-banner {
  120. @apply w-translate-y-0;
  121. visibility: visible;
  122. max-height: 6rem;
  123. }
  124. &__error-title {
  125. @apply w-label-2;
  126. color: inherit;
  127. margin-top: 0;
  128. margin-bottom: 0.25rem;
  129. }
  130. &__error-details {
  131. color: inherit;
  132. }
  133. &__modes {
  134. display: flex;
  135. align-items: center;
  136. justify-content: center;
  137. gap: 1rem;
  138. margin-bottom: 0;
  139. background-color: theme('colors.white.DEFAULT');
  140. .w-field__label {
  141. margin-bottom: 0;
  142. }
  143. }
  144. &__mode-select {
  145. @apply w-outline-offset-inside;
  146. }
  147. }