Skip to content

Commit a2e48fd

Browse files
Fix display on desktop
1 parent 7dca48b commit a2e48fd

File tree

1 file changed

+31
-21
lines changed
  • newIDE/app/src/MainFrame/EditorContainers/HomePage/GetStartedSection

1 file changed

+31
-21
lines changed

newIDE/app/src/MainFrame/EditorContainers/HomePage/GetStartedSection/EarnCredits.js

+31-21
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as React from 'react';
33
import { Trans } from '@lingui/macro';
44
import Text from '../../../../UI/Text';
55
import {
6+
ColumnStackLayout,
67
LineStackLayout,
78
ResponsiveLineStackLayout,
89
} from '../../../../UI/Layout';
@@ -34,6 +35,9 @@ type FeedbackInfo = {|
3435
type CreditItem = BadgeInfo | FeedbackInfo;
3536

3637
const styles = {
38+
widgetContainer: {
39+
maxWidth: 1800, // To avoid taking too much space on large screens.
40+
},
3741
badgeContainer: {
3842
position: 'relative',
3943
width: 65,
@@ -111,7 +115,7 @@ const FeedbackItem = () => {
111115
const allBadgesInfo: BadgeInfo[] = [
112116
{
113117
id: 'github-star',
114-
label: <Trans>Star GDevelop</Trans>,
118+
label: 'Star GDevelop', // Do not translate "Star".
115119
linkUrl: 'https://github.com/4ian/GDevelop',
116120
type: 'badge',
117121
},
@@ -127,6 +131,12 @@ const allBadgesInfo: BadgeInfo[] = [
127131
linkUrl: 'https://x.com/GDevelopApp',
128132
type: 'badge',
129133
},
134+
{
135+
id: 'youtube-subscription',
136+
label: <Trans>Subscribe</Trans>,
137+
linkUrl: 'https://x.com/GDevelopApp',
138+
type: 'badge',
139+
},
130140
];
131141

132142
const getAllBadgesWithOwnedStatus = (badges: ?Array<Badge>): BadgeInfo[] => {
@@ -235,9 +245,8 @@ export const EarnCredits = ({
235245
showRandomItem,
236246
showAllItems,
237247
}: Props) => {
238-
const { windowSize, isMobile } = useResponsiveWindowSize();
239-
const isMobileOrMediumWidth =
240-
windowSize === 'small' || windowSize === 'medium';
248+
const { isMobile, windowSize } = useResponsiveWindowSize();
249+
const isExtraLargeScreen = windowSize === 'xlarge';
241250

242251
const allBadgesWithOwnedStatus = React.useMemo(
243252
() => getAllBadgesWithOwnedStatus(badges),
@@ -318,28 +327,24 @@ export const EarnCredits = ({
318327
[badgesToShow, feedbackItemsToShow]
319328
);
320329

330+
const onlyOneItemDisplayed = allItemsToShow.length === 1;
331+
const itemsPerRow = onlyOneItemDisplayed ? 1 : isExtraLargeScreen ? 3 : 2;
321332
// 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(
323334
() => {
324335
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));
327338
}
328339
return slicedItems;
329340
},
330-
[allItemsToShow]
341+
[allItemsToShow, itemsPerRow]
331342
);
332343

333-
const onlyOneItemDisplayed = allItemsToShow.length === 1;
334-
335344
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) => (
343348
<ResponsiveLineStackLayout
344349
noMargin
345350
expand={onlyOneItemDisplayed}
@@ -366,12 +371,17 @@ export const EarnCredits = ({
366371
return null;
367372
})
368373
.filter(Boolean)}
369-
{items.length === 1 &&
374+
{items.length < itemsPerRow &&
370375
!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+
))}
372382
</ResponsiveLineStackLayout>
373383
))}
374-
</ResponsiveLineStackLayout>
375-
</Column>
384+
</ColumnStackLayout>
385+
</div>
376386
);
377387
};

0 commit comments

Comments
 (0)