@@ -3,6 +3,7 @@ import * as React from 'react';
3
3
import { Trans } from '@lingui/macro' ;
4
4
import Text from '../../../../UI/Text' ;
5
5
import {
6
+ ColumnStackLayout ,
6
7
LineStackLayout ,
7
8
ResponsiveLineStackLayout ,
8
9
} from '../../../../UI/Layout' ;
@@ -34,6 +35,9 @@ type FeedbackInfo = {|
34
35
type CreditItem = BadgeInfo | FeedbackInfo ;
35
36
36
37
const styles = {
38
+ widgetContainer : {
39
+ maxWidth : 1800 , // To avoid taking too much space on large screens.
40
+ } ,
37
41
badgeContainer : {
38
42
position : 'relative' ,
39
43
width : 65 ,
@@ -111,7 +115,7 @@ const FeedbackItem = () => {
111
115
const allBadgesInfo : BadgeInfo [ ] = [
112
116
{
113
117
id : 'github-star' ,
114
- label : < Trans > Star GDevelop</ Trans > ,
118
+ label : ' Star GDevelop' , // Do not translate "Star".
115
119
linkUrl : 'https://github.com/4ian/GDevelop' ,
116
120
type : 'badge' ,
117
121
} ,
@@ -127,6 +131,12 @@ const allBadgesInfo: BadgeInfo[] = [
127
131
linkUrl : 'https://x.com/GDevelopApp' ,
128
132
type : 'badge' ,
129
133
} ,
134
+ {
135
+ id : 'youtube-subscription' ,
136
+ label : < Trans > Subscribe</ Trans > ,
137
+ linkUrl : 'https://x.com/GDevelopApp' ,
138
+ type : 'badge' ,
139
+ } ,
130
140
] ;
131
141
132
142
const getAllBadgesWithOwnedStatus = ( badges : ?Array < Badge > ) : BadgeInfo [ ] => {
@@ -235,9 +245,8 @@ export const EarnCredits = ({
235
245
showRandomItem,
236
246
showAllItems,
237
247
} : Props ) => {
238
- const { windowSize, isMobile } = useResponsiveWindowSize ( ) ;
239
- const isMobileOrMediumWidth =
240
- windowSize === 'small' || windowSize === 'medium' ;
248
+ const { isMobile, windowSize } = useResponsiveWindowSize ( ) ;
249
+ const isExtraLargeScreen = windowSize === 'xlarge' ;
241
250
242
251
const allBadgesWithOwnedStatus = React . useMemo (
243
252
( ) => getAllBadgesWithOwnedStatus ( badges ) ,
@@ -318,28 +327,24 @@ export const EarnCredits = ({
318
327
[ badgesToShow , feedbackItemsToShow ]
319
328
) ;
320
329
330
+ const onlyOneItemDisplayed = allItemsToShow . length === 1 ;
331
+ const itemsPerRow = onlyOneItemDisplayed ? 1 : isExtraLargeScreen ? 3 : 2 ;
321
332
// Slice items in arrays of two to display them in a responsive way.
322
- const itemsSlicedInArraysOfTwo : CreditItem [ ] [ ] = React . useMemo (
333
+ const itemsSlicedInArrays : CreditItem [ ] [ ] = React . useMemo (
323
334
( ) => {
324
335
const slicedItems : CreditItem [ ] [ ] = [ ] ;
325
- for ( let i = 0 ; i < allItemsToShow . length ; i += 2 ) {
326
- slicedItems . push ( allItemsToShow . slice ( i , i + 2 ) ) ;
336
+ for ( let i = 0 ; i < allItemsToShow . length ; i += itemsPerRow ) {
337
+ slicedItems . push ( allItemsToShow . slice ( i , i + itemsPerRow ) ) ;
327
338
}
328
339
return slicedItems ;
329
340
} ,
330
- [ allItemsToShow ]
341
+ [ allItemsToShow , itemsPerRow ]
331
342
) ;
332
343
333
- const onlyOneItemDisplayed = allItemsToShow . length === 1 ;
334
-
335
344
return (
336
- < Column noMargin expand >
337
- < ResponsiveLineStackLayout
338
- noMargin
339
- expand
340
- forceMobileLayout = { isMobileOrMediumWidth }
341
- >
342
- { itemsSlicedInArraysOfTwo . map ( ( items , index ) => (
345
+ < div style = { styles . widgetContainer } >
346
+ < ColumnStackLayout noMargin expand >
347
+ { itemsSlicedInArrays . map ( ( items , index ) => (
343
348
< ResponsiveLineStackLayout
344
349
noMargin
345
350
expand = { onlyOneItemDisplayed }
@@ -366,12 +371,17 @@ export const EarnCredits = ({
366
371
return null ;
367
372
} )
368
373
. filter ( Boolean ) }
369
- { items . length === 1 &&
374
+ { items . length < itemsPerRow &&
370
375
! onlyOneItemDisplayed &&
371
- isMobileOrMediumWidth && < div style = { styles . itemPlaceholder } /> }
376
+ Array . from (
377
+ { length : itemsPerRow - items . length } ,
378
+ ( _ , i ) => i
379
+ ) . map ( i => (
380
+ < div key = { `filler-${ i } ` } style = { styles . itemPlaceholder } />
381
+ ) ) }
372
382
</ ResponsiveLineStackLayout >
373
383
) ) }
374
- </ ResponsiveLineStackLayout >
375
- </ Column >
384
+ </ ColumnStackLayout >
385
+ </ div >
376
386
) ;
377
387
} ;
0 commit comments