Skip to content

Commit 87ac990

Browse files
committed
fix preview height
1 parent 4f7bdc6 commit 87ac990

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

src/components/design-library-list/design-library-list-item.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,13 @@ const DesignLibraryListItem = forwardRef( ( props, ref ) => {
9797
showHideNote={ false }
9898
/>
9999
) }
100-
{ isLoading && <Spinner style={ { display: 'block', margin: '50px auto' } } /> }
100+
{ isLoading && <div className="stk-spinner-container"><Spinner /></div> }
101101
<div
102102
className="stk-block-design__host-container"
103103
style={ {
104104
transform: `scale(${ selectedNum && selectedData ? selectedData.selectedPreviewSize.scale : previewSize?.scale })`,
105105
transformOrigin: 'top left',
106-
height: selectedNum && selectedData ? selectedData.selectedPreviewSize.preview
107-
: ( enableBackground ? previewSize.heightBackground : previewSize.heightNoBackground ),
106+
height: getDesignPreviewSize(),
108107
} }
109108
>
110109
<div className="stk-block-design__host" ref={ hostRef }>

src/components/design-library-list/editor.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,19 @@
223223
cursor: default;
224224
}
225225
}
226+
227+
228+
.ugb-design-library-items {
229+
.stk-spinner-container .components-spinner {
230+
display: block;
231+
margin: 50px auto;
232+
}
233+
234+
&.stk-design-library__item-pages .stk-spinner-container {
235+
height: 400px;
236+
display: flex;
237+
.components-spinner {
238+
margin: auto;
239+
}
240+
}
241+
}

src/components/design-library-list/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ const DesignLibraryItem = props => {
128128

129129
const getCardHeight = () => {
130130
const key = props.enableBackground ? 'background' : 'noBackground'
131-
return cardHeight?.[ key ] || 250
131+
return props.selectedTab === 'pages' ? 472 : cardHeight?.[ key ] || 250
132132
}
133133

134134
if ( ! shouldRender && ! props.selectedNum ) {

src/components/design-library-list/use-preview-renderer.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,15 @@ export const usePreviewRenderer = (
7474
const shadowBody = shadowRoot.querySelector( 'body' )
7575
if ( shadowBody ) {
7676
const cardWidth = cardRect.width // Get width of the card
77-
const scaleFactor = cardWidth > 0 ? cardWidth / shadowBody.offsetWidth : 1 // Divide by 1200, which is the width of preview in the shadow DOM
77+
const scaleFactor = cardWidth > 0 ? cardWidth / 1300 : 1 // Divide by 1200, which is the width of preview in the shadow DOM
7878
newPreviewSize.scale = scaleFactor
7979

80-
const _height = parseFloat( shadowBody.offsetHeight ) * scaleFactor // Also adjust the height
80+
let _bodyHeight = 1200
81+
if ( selectedTab === 'patterns' ) {
82+
_bodyHeight = shadowBody.offsetHeight
83+
}
84+
85+
const _height = parseFloat( _bodyHeight ) * scaleFactor // Also adjust the height
8186

8287
if ( Object.keys( newPreviewSize ).length === 1 ) {
8388
newPreviewSize.heightBackground = _height

0 commit comments

Comments
 (0)