11import { useIntl } from '@edx/frontend-platform/i18n' ;
2- import { Tab , Tabs } from '@openedx/paragon' ;
2+ import { Card , Stack , Tab , Tabs } from '@openedx/paragon' ;
3+ import classNames from 'classnames' ;
34import { IframeProvider } from '@src/generic/hooks/context/iFrameContext' ;
45
56import { LibraryBlock , type VersionSpec } from '../LibraryBlock' ;
@@ -14,6 +15,8 @@ interface Props {
1415 showNewTitle ?: boolean ;
1516 hasLocalChanges ?: boolean ;
1617 oldUsageKey ?: string ;
18+ sideBySide ?: boolean ;
19+ showTitle ?: boolean ;
1720}
1821
1922/**
@@ -32,6 +35,8 @@ const CompareChangesWidget = ({
3235 showNewTitle = false ,
3336 oldUsageKey,
3437 hasLocalChanges = false ,
38+ sideBySide = false ,
39+ showTitle = false ,
3540} : Props ) => {
3641 const intl = useIntl ( ) ;
3742
@@ -42,42 +47,66 @@ const CompareChangesWidget = ({
4247 ? intl . formatMessage ( messages . publishedLibraryContentTitle )
4348 : intl . formatMessage ( messages . newVersionTitle ) ;
4449
50+ const oldBlock = oldVersion !== 0 && (
51+ < Card className = { classNames ( 'flex-1 min-w-0' , { 'border-0' : ! sideBySide } ) } >
52+ < Card . Body className = "p-4 bg-white" >
53+ { sideBySide && (
54+ < h3 className = "w-100 text-center mb-4" >
55+ { oldTabMessage }
56+ </ h3 >
57+ ) }
58+ { oldTitle && hasLocalChanges && (
59+ < div className = "h3 mt-3.5" >
60+ { oldTitle }
61+ </ div >
62+ ) }
63+ < div style = { hasLocalChanges ? { marginLeft : '-35px' , marginTop : '-8px' } : { } } >
64+ < IframeProvider >
65+ < LibraryBlock
66+ usageKey = { oldUsageKey || usageKey }
67+ version = { oldVersion }
68+ minHeight = "50vh"
69+ showTitle = { showTitle }
70+ />
71+ </ IframeProvider >
72+ </ div >
73+ </ Card . Body >
74+ </ Card >
75+ ) ;
76+
77+ const newBlock = (
78+ < Card className = { classNames ( 'flex-1 min-w-0' , { 'border-0' : ! sideBySide } ) } >
79+ < Card . Body className = "p-4 bg-white" >
80+ { sideBySide && (
81+ < h3 className = "w-100 text-center mb-4" >
82+ { newTabMessage }
83+ </ h3 >
84+ ) }
85+ < IframeProvider >
86+ < LibraryBlock
87+ usageKey = { usageKey }
88+ version = { newVersion }
89+ showTitle = { showNewTitle || showTitle }
90+ minHeight = "50vh"
91+ />
92+ </ IframeProvider >
93+ </ Card . Body >
94+ </ Card >
95+ ) ;
96+
4597 return (
4698 < div className = "bg-white p-2" >
47- < Tabs variant = "tabs" defaultActiveKey = "new" id = "preview-version-toggle" mountOnEnter >
48- { oldVersion !== 0 &&
49- < Tab eventKey = "old" title = { oldTabMessage } >
50- < div className = "p-2 bg-white" >
51- { oldTitle && hasLocalChanges && (
52- < div className = "h3 mt-3.5" >
53- { oldTitle }
54- </ div >
55- ) }
56- < div style = { hasLocalChanges ? { marginLeft : '-35px' , marginTop : '-8px' } : { } } >
57- < IframeProvider >
58- < LibraryBlock
59- usageKey = { oldUsageKey || usageKey }
60- version = { oldVersion }
61- minHeight = "50vh"
62- />
63- </ IframeProvider >
64- </ div >
65- </ div >
66- </ Tab >
67- }
68- < Tab eventKey = "new" title = { newTabMessage } >
69- < div className = "p-2 bg-white" >
70- < IframeProvider >
71- < LibraryBlock
72- usageKey = { usageKey }
73- version = { newVersion }
74- showTitle = { showNewTitle }
75- minHeight = "50vh"
76- />
77- </ IframeProvider >
78- </ div >
79- </ Tab >
80- </ Tabs >
99+ { sideBySide ? (
100+ < Stack direction = 'horizontal' gap = { 2 } >
101+ { oldBlock }
102+ { newBlock }
103+ </ Stack >
104+ ) : (
105+ < Tabs variant = "tabs" defaultActiveKey = "new" id = "preview-version-toggle" mountOnEnter >
106+ { oldBlock && < Tab eventKey = "old" title = { oldTabMessage } > { oldBlock } </ Tab > }
107+ < Tab eventKey = "new" title = { newTabMessage } > { newBlock } </ Tab >
108+ </ Tabs >
109+ ) }
81110 </ div >
82111 ) ;
83112} ;
0 commit comments