_preview-panel.scss 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. .w-preview {
  2. --w-preview-background-color: var(--w-color-white);
  3. --preview-width-ratio: min(
  4. 1,
  5. var(--preview-panel-width, 450) / var(--preview-device-width, 375)
  6. );
  7. --preview-iframe-width: calc(1px * var(--preview-device-width, 375));
  8. height: 100%;
  9. display: flex;
  10. flex-direction: column;
  11. &__area {
  12. height: 100%;
  13. display: flex;
  14. flex-direction: column-reverse;
  15. justify-content: space-between;
  16. // Needed for the warning message when the data is not valid.
  17. overflow: hidden;
  18. }
  19. &__wrapper {
  20. position: relative;
  21. width: calc(var(--preview-iframe-width) * var(--preview-width-ratio));
  22. height: 100%;
  23. margin-inline-start: auto;
  24. margin-inline-end: auto;
  25. }
  26. &__iframe {
  27. transform-origin: top left;
  28. width: var(--preview-iframe-width);
  29. height: calc(100% / var(--preview-width-ratio));
  30. transform: scale(var(--preview-width-ratio));
  31. display: block;
  32. &:empty {
  33. // Ensure that sites without a background show with a fallback, only when iframe has loaded
  34. background-color: var(--w-preview-background-color);
  35. }
  36. [dir='rtl'] & {
  37. // Transform with the top-right physical corner as the origin since the layout is reversed.
  38. transform-origin: top right;
  39. }
  40. // Prevent the iframe from capturing pointer events when resizing the panel, which
  41. // would consume the pointerup event and leaving the panel stuck in a resizing state.
  42. .side-panel-resizing & {
  43. pointer-events: none;
  44. }
  45. }
  46. &__sizes {
  47. @apply w-border-border-furniture w-border-b;
  48. display: flex;
  49. align-items: center;
  50. justify-content: center;
  51. gap: 0.75rem;
  52. padding-bottom: 1rem;
  53. margin-bottom: 1rem;
  54. @include more-contrast() {
  55. border-color: theme('colors.border-furniture-more-contrast');
  56. }
  57. }
  58. &__size-button {
  59. @apply w-text-text-meta w-transition hover:w-transform hover:w-scale-110 hover:w-text-text-label focus:w-text-text-label;
  60. width: 2rem;
  61. height: 2rem;
  62. background: transparent;
  63. padding: 0;
  64. border-radius: 5px;
  65. display: grid;
  66. place-items: center;
  67. cursor: pointer;
  68. &--selected,
  69. &--selected:hover {
  70. @apply w-bg-surface-menus w-text-text-button w-transform-none w-border w-border-transparent;
  71. }
  72. &:focus-within:has(:focus-visible) {
  73. @include focus-outline;
  74. }
  75. .icon {
  76. @include svg-icon(1rem);
  77. &.icon-tablet-alt,
  78. &.icon-desktop {
  79. @include svg-icon(1.25rem);
  80. }
  81. &.icon-link-external {
  82. @include svg-icon(0.9rem);
  83. }
  84. }
  85. }
  86. &__refresh-button.button--icon {
  87. display: flex;
  88. align-items: center;
  89. position: absolute;
  90. top: 1.25rem;
  91. inset-inline-end: 1.5rem;
  92. // Use element and class selectors to beat .button-longrunning specificity
  93. svg.icon,
  94. svg.icon-spinner {
  95. margin-inline-end: 0;
  96. }
  97. }
  98. &__spinner {
  99. position: absolute;
  100. top: 1.25rem;
  101. inset-inline-end: 1.5rem;
  102. }
  103. &__controls {
  104. @apply w-border-t w-border-transparent w-duration-500 w-ease-in-out;
  105. transition-property: border-color, margin-top, padding-top;
  106. margin-top: 0;
  107. padding-top: 0;
  108. // Show the border only if there's an error,
  109. // but always show it if there are multiple preview modes
  110. .w-preview--has-errors &:not(&--multiple),
  111. &--multiple {
  112. @apply w-border-border-furniture w-border-t;
  113. padding-top: 1rem;
  114. margin-top: 1rem;
  115. }
  116. }
  117. &__error-banner {
  118. @apply w-text-text-context w-duration-1000 w-ease-in-out w-translate-y-20;
  119. transition-property: max-height, transform, visibility;
  120. visibility: hidden;
  121. max-height: 0;
  122. display: flex;
  123. align-items: center;
  124. gap: 1rem;
  125. position: relative;
  126. z-index: -1;
  127. .icon {
  128. @apply w-text-warning-100;
  129. }
  130. }
  131. &--has-errors &__error-banner {
  132. @apply w-translate-y-0;
  133. visibility: visible;
  134. max-height: 6rem;
  135. }
  136. &__error-title {
  137. @apply w-label-2;
  138. color: inherit;
  139. margin-top: 0;
  140. margin-bottom: 0.25rem;
  141. }
  142. &__error-details {
  143. color: inherit;
  144. }
  145. &__modes {
  146. margin-bottom: 0;
  147. background-color: theme('colors.surface-page');
  148. .w-field__input {
  149. padding-inline-end: 0;
  150. }
  151. }
  152. &__mode-select {
  153. @apply w-outline-offset-inside;
  154. }
  155. // A hidden element that is only rendered for functionality purposes,
  156. // but is not visible to the user. Used by radio inputs for preview sizes and
  157. // the iframe while it's loading. We nest the selector rather than suffixing
  158. // the parent selector to beat the specificity of input[type="radio"] styles
  159. .w-preview__proxy {
  160. position: absolute;
  161. width: 0;
  162. height: 0;
  163. opacity: 0;
  164. }
  165. }