@@ -14,6 +14,7 @@ import Preview from "../preview/preview";
1414import idFromUrl from "../util/helpers/id-from-url" ;
1515import StickyFooter from "../util/sticky-footer" ;
1616import localStorageKeys from "../util/local-storage-keys" ;
17+ import Select from "../util/forms/select.jsx" ;
1718
1819/**
1920 * The shared form component.
@@ -31,7 +32,7 @@ import localStorageKeys from "../util/local-storage-keys";
3132 * @param {Array } props.children The children being passed from parent
3233 * @param {Function } props.handleSaveNoClose Handles form submit with close.
3334 * @returns {object } The form shared by campaigns and playlists.
34- */
35+ */ 4
3536function PlaylistCampaignForm ( {
3637 handleInput,
3738 handleSubmit,
@@ -48,6 +49,22 @@ function PlaylistCampaignForm({
4849 const { t } = useTranslation ( "common" , {
4950 keyPrefix : "playlist-campaign-form" ,
5051 } ) ;
52+
53+ const previewOrientationOptions = [
54+ {
55+ value : "horizontal" ,
56+ title : t ( "preview-orientation-landscape" ) ,
57+ key : "horizontal" ,
58+ } ,
59+ {
60+ value : "vertical" ,
61+ title : t ( "preview-orientation-portrait" ) ,
62+ key : "vertical" ,
63+ } ,
64+ ] ;
65+ const [ previewOrientation , setPreviewOrientation ] = useState (
66+ previewOrientationOptions [ 0 ] . value
67+ ) ;
5168 const navigate = useNavigate ( ) ;
5269 const [ publishedFromError , setPublishedFromError ] = useState ( false ) ;
5370 const [ publishedToError , setPublishedToError ] = useState ( false ) ;
@@ -159,7 +176,7 @@ function PlaylistCampaignForm({
159176 { displayPreview && (
160177 < Col
161178 className = "responsive-side shadow-sm p-3 mb-3 bg-body rounded me-3 sticky-top"
162- style = { { top : "20px" } }
179+ style = { { top : "20px" , maxWidth : "520px" } }
163180 >
164181 < h2 className = "h4" > { t ( "playlist-preview" ) } </ h2 >
165182 < div >
@@ -168,27 +185,46 @@ function PlaylistCampaignForm({
168185 variant = "info"
169186 className = "mt-3"
170187 >
171- { t ( "playlist-preview-about" ) }
188+ { t ( "playlist-preview-small- about" ) }
172189 </ Alert >
190+ < div className = "preview-actions mb-3" >
191+ < Select
192+ isRequired
193+ allowNull = { false }
194+ onChange = { ( { target } ) =>
195+ setPreviewOrientation ( target . value )
196+ }
197+ required
198+ name = "preview-orientation"
199+ options = { previewOrientationOptions }
200+ className = "m-0"
201+ value = { previewOrientation }
202+ />
203+
204+ < Button
205+ variant = "outline-secondary"
206+ type = "button"
207+ id = "preview_slide"
208+ onClick = { ( ) =>
209+ setPreviewOverlayVisible ( ! previewOverlayVisible )
210+ }
211+ >
212+ < FontAwesomeIcon icon = { faExpand } className = "me-3" />
213+ { t ( "preview-in-full-screen" ) }
214+ </ Button >
215+ </ div >
173216 < Preview
174217 id = { idFromUrl ( playlist [ "@id" ] ) }
175218 mode = "playlist"
176- width = { 480 }
177- height = { 270 }
178- />
179- < Button
180- variant = "secondary"
181- type = "button"
182- id = "preview_slide"
183- onClick = { ( ) =>
184- setPreviewOverlayVisible ( ! previewOverlayVisible )
219+ height = { previewOrientation === "horizontal" ? 270 : 480 }
220+ width = { previewOrientation === "horizontal" ? 480 : 270 }
221+ simulatedHeight = {
222+ previewOrientation === "horizontal" ? 1080 : 1920
185223 }
186- size = "lg"
187- className = "me-3 mt-3"
188- >
189- < FontAwesomeIcon icon = { faExpand } className = "me-3" /> { " " }
190- { t ( "preview-in-full-screen" ) }
191- </ Button >
224+ simulatedWidth = {
225+ previewOrientation === "horizontal" ? 1920 : 1080
226+ }
227+ />
192228 </ div >
193229 { previewOverlayVisible && (
194230 < div
@@ -198,14 +234,25 @@ function PlaylistCampaignForm({
198234 role = "presentation"
199235 className = "preview-overlay d-flex justify-content-center align-items-center flex-column"
200236 >
237+ < Preview
238+ id = { idFromUrl ( playlist [ "@id" ] ) }
239+ mode = "playlist"
240+ height = { previewOrientation === "horizontal" ? 540 : 960 }
241+ width = { previewOrientation === "horizontal" ? 960 : 540 }
242+ simulatedHeight = {
243+ previewOrientation === "horizontal" ? 1080 : 1920
244+ }
245+ simulatedWidth = {
246+ previewOrientation === "horizontal" ? 1920 : 1080
247+ }
248+ />
201249 < Alert
202250 key = "playlist-preview-about"
203251 variant = "info"
204252 className = "mt-3"
205253 >
206254 { t ( "playlist-preview-about" ) }
207255 </ Alert >
208- < Preview id = { idFromUrl ( playlist [ "@id" ] ) } mode = "playlist" />
209256 </ div >
210257 ) }
211258 </ Col >
0 commit comments