forked from wagtail/wagtail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a new auto-updating preview panel inside the page editor (w…
…agtail#8671) Co-authored-by: Thibaud Colas <[email protected]>
- Loading branch information
1 parent
1859e64
commit 5ee5acb
Showing
33 changed files
with
850 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.preview-error { | ||
@apply w-bg-white; | ||
position: absolute; | ||
inset-inline-start: 0; | ||
width: 100%; | ||
display: grid; | ||
min-height: 100vh; | ||
align-content: center; | ||
text-align: center; | ||
|
||
&__header { | ||
margin-bottom: 0.5rem; | ||
} | ||
|
||
&__title { | ||
@apply w-h4 w-text-grey-600; | ||
} | ||
|
||
&__details { | ||
@apply w-help-text; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
.preview-panel { | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
|
||
--preview-width-ratio: min( | ||
1, | ||
var(--preview-panel-width, 450) / var(--preview-device-width, 375) | ||
); | ||
--preview-iframe-width: calc(1px * var(--preview-device-width, 375)); | ||
|
||
&__area { | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column-reverse; | ||
justify-content: space-between; | ||
// Needed for the warning message when the data is not valid. | ||
overflow: hidden; | ||
} | ||
|
||
&__wrapper { | ||
width: calc(var(--preview-iframe-width) * var(--preview-width-ratio)); | ||
height: 100%; | ||
margin-inline-start: auto; | ||
margin-inline-end: auto; | ||
} | ||
|
||
&__iframe { | ||
transform-origin: 0 0; | ||
width: var(--preview-iframe-width); | ||
height: calc(100% / var(--preview-width-ratio)); | ||
transform: scale(var(--preview-width-ratio)); | ||
display: block; | ||
} | ||
|
||
&__sizes { | ||
@apply w-border-grey-100 w-border-b; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 0.75rem; | ||
padding-bottom: 1rem; | ||
margin-bottom: 1rem; | ||
} | ||
|
||
&__size-button { | ||
@apply w-text-grey-400 w-transition hover:w-transform hover:w-scale-110 hover:w-text-primary focus:w-text-primary; | ||
|
||
width: 2rem; | ||
height: 2rem; | ||
background: transparent; | ||
box-sizing: border-box; | ||
padding: 0; | ||
border-radius: 5px; | ||
display: grid; | ||
place-items: center; | ||
cursor: pointer; | ||
|
||
&:focus-within { | ||
@include focus-outline; | ||
} | ||
|
||
.icon { | ||
@include svg-icon(1rem); | ||
|
||
&.icon-tablet-alt, | ||
&.icon-desktop { | ||
@include svg-icon(1.25rem); | ||
} | ||
|
||
&.icon-link-external { | ||
@include svg-icon(0.9rem); | ||
} | ||
} | ||
|
||
input[type='radio'] { | ||
position: absolute; | ||
width: 0; | ||
height: 0; | ||
opacity: 0; | ||
} | ||
} | ||
|
||
&__refresh-button.button--icon { | ||
display: flex; | ||
align-items: center; | ||
gap: 0.5rem; | ||
position: absolute; | ||
top: 1.25rem; | ||
inset-inline-end: 1.5rem; | ||
|
||
.icon { | ||
@include svg-icon(0.9rem); | ||
} | ||
} | ||
|
||
&__spinner { | ||
position: absolute; | ||
top: 1.25rem; | ||
inset-inline-end: 1.5rem; | ||
} | ||
|
||
&--mobile &__size-button--mobile, | ||
&--tablet &__size-button--tablet, | ||
&--desktop &__size-button--desktop { | ||
@apply w-bg-primary w-text-white w-transform-none w-border w-border-transparent; | ||
} | ||
|
||
&__controls { | ||
@apply w-border-t w-border-transparent w-duration-500 w-ease-in-out; | ||
transition-property: border-color, margin-top, padding-top; | ||
margin-top: 0; | ||
padding-top: 0; | ||
|
||
// Show the border only if there's an error, | ||
// but always show it if there are multiple preview modes | ||
.preview-panel--has-errors &:not(&--multiple), | ||
&--multiple { | ||
@apply w-border-grey-100 w-border-t; | ||
padding-top: 1rem; | ||
margin-top: 1rem; | ||
} | ||
} | ||
|
||
&__error-banner { | ||
@apply w-text-grey-600 w-duration-1000 w-ease-in-out w-translate-y-20; | ||
transition-property: max-height, transform, visibility; | ||
visibility: hidden; | ||
max-height: 0; | ||
display: flex; | ||
align-items: center; | ||
gap: 1rem; | ||
position: relative; | ||
z-index: -1; | ||
|
||
.icon { | ||
@apply w-text-warning-100; | ||
} | ||
} | ||
|
||
&--has-errors &__error-banner { | ||
@apply w-translate-y-0; | ||
visibility: visible; | ||
max-height: 6rem; | ||
} | ||
|
||
&__error-title { | ||
@apply w-label-2; | ||
color: inherit; | ||
margin-top: 0; | ||
margin-bottom: 0.25rem; | ||
} | ||
|
||
&__error-details { | ||
color: inherit; | ||
} | ||
|
||
&__modes { | ||
@apply w-bg-white; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 1rem; | ||
} | ||
|
||
&__mode-label { | ||
padding: 0; | ||
width: auto; | ||
} | ||
|
||
&__mode-select { | ||
@apply w-bg-white w-outline-offset-inside; | ||
font-size: 1em; | ||
padding: 0.6rem 0.75rem; | ||
padding-inline-end: 2.5rem; | ||
width: auto; | ||
} | ||
|
||
&__modes.choice_field &__mode-select ~ span:after { | ||
@apply w-text-grey-400; | ||
border: 0; | ||
font-size: 1.5em; | ||
line-height: 1.65em; | ||
top: auto; | ||
width: 2.5rem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.