Skip to content

Commit 00d7404

Browse files
authored
feat(lynxtron-go): hide internal gallery entries by default (#87)
1 parent 7d8e276 commit 00d7404

6 files changed

Lines changed: 71 additions & 5 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"lynxtron-go": patch
3+
---
4+
5+
Keep the Electron Fiddles collection, its collection cases, and the built-in Hello Lynxtron starter hidden from the Lynxtron Go Gallery by default behind the `LYNXTRON_GALLERY_INTERNAL_SHOWCASES=1` build switch.

lynxtron-go/lynx.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ const isPreviewMode = showcaseSourceMode === 'local-registry' || showcaseSourceM
5151
const isLocalRegistry = showcaseSourceMode === 'local-registry';
5252
const isLocalWorkspace = showcaseSourceMode === 'local-workspace';
5353
const isReleaseArtifacts = showcaseSourceMode === 'release-artifacts';
54+
// Internal Gallery entries stay compiled and can be enabled for development
55+
// builds without changing the renderer source. Product builds leave them off.
56+
const galleryInternalShowcases = process.env.LYNXTRON_GALLERY_INTERNAL_SHOWCASES === '1';
5457
const registryPath = path.resolve(monorepoRoot, 'showcase-registry.json');
5558

5659
// Thumbnails are staged into the app's own bundle rather than linked at their
@@ -239,6 +242,7 @@ export default defineConfig({
239242
__FIDDLE_CATALOG__: JSON.stringify(bakedFiddles),
240243
__SHOWCASE_PREVIEW__: JSON.stringify(isPreviewMode),
241244
__SHOWCASE_LOCAL_WORKSPACE__: JSON.stringify(isLocalWorkspace),
245+
__GALLERY_INTERNAL_SHOWCASES__: JSON.stringify(galleryInternalShowcases),
242246
__BRAND_MARK_URL__: JSON.stringify(BRAND_MARK_URL),
243247
__BRAND_MARK_ON_DARK_URL__: JSON.stringify(BRAND_MARK_ON_DARK_URL),
244248
},

lynxtron-go/src/app/components/Gallery/GalleryHome.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import { Button } from '../../fiddle/bp';
33
import { Tooltip } from '../../fiddle/bp/Tooltip';
44
import {
55
FIDDLE_CATALOG,
6-
FIDDLE_SHOWCASE_NAME,
6+
GALLERY_INTERNAL_SHOWCASES,
77
SHOWCASE_LOCAL_WORKSPACE,
88
SHOWCASE_PREVIEW,
99
SHOWCASE_REGISTRY,
1010
type FiddleEntry,
1111
type ShowcaseEntry,
1212
} from '../../store';
13+
import { resolveGalleryShowcases } from './gallery-visibility';
1314

1415
interface GalleryHomeProps {
1516
onBack: () => void;
@@ -185,10 +186,10 @@ export function GalleryHome({
185186
}: GalleryHomeProps) {
186187
// The Electron-fiddles showcase gets its own section below, so it does not
187188
// also take a slot in the featured grid.
188-
const fiddleShowcase = SHOWCASE_REGISTRY.find(e => e.name === FIDDLE_SHOWCASE_NAME);
189-
const featured = fiddleShowcase
190-
? SHOWCASE_REGISTRY.filter(e => e.name !== FIDDLE_SHOWCASE_NAME)
191-
: SHOWCASE_REGISTRY;
189+
const { featured, fiddleShowcase } = resolveGalleryShowcases(
190+
SHOWCASE_REGISTRY,
191+
GALLERY_INTERNAL_SHOWCASES,
192+
);
192193
// The collection card is one of the cards under this rule, so the count has
193194
// to include it — a header that disagrees with what is under it is worse
194195
// than no header.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { describe, expect, it } from 'vitest';
2+
import {
3+
FIDDLE_SHOWCASE_NAME,
4+
HELLO_SHOWCASE_NAME,
5+
type ShowcaseEntry,
6+
} from '../../store';
7+
import { resolveGalleryShowcases } from './gallery-visibility';
8+
9+
function entry(name: string): ShowcaseEntry {
10+
return { name, description: '', tags: [], url: '' };
11+
}
12+
13+
describe('Gallery showcase visibility', () => {
14+
const fiddle = entry(FIDDLE_SHOWCASE_NAME);
15+
const hello = entry(HELLO_SHOWCASE_NAME);
16+
const regular = entry('@lynxtron-examples/native-texture-canvas');
17+
18+
it('hides internal Gallery entries when the build switch is off', () => {
19+
expect(resolveGalleryShowcases([fiddle, hello, regular], false)).toEqual({
20+
featured: [regular],
21+
fiddleShowcase: undefined,
22+
});
23+
});
24+
25+
it('restores the collection and Hello card when the build switch is on', () => {
26+
expect(resolveGalleryShowcases([fiddle, hello, regular], true)).toEqual({
27+
featured: [hello, regular],
28+
fiddleShowcase: fiddle,
29+
});
30+
});
31+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import {
2+
FIDDLE_SHOWCASE_NAME,
3+
HELLO_SHOWCASE_NAME,
4+
type ShowcaseEntry,
5+
} from '../../store';
6+
7+
/** Resolve only the Gallery surface; the full registry remains available elsewhere. */
8+
export function resolveGalleryShowcases(
9+
entries: ShowcaseEntry[],
10+
internalShowcasesEnabled: boolean,
11+
): { featured: ShowcaseEntry[]; fiddleShowcase?: ShowcaseEntry } {
12+
const fiddleShowcase = internalShowcasesEnabled
13+
? entries.find(entry => entry.name === FIDDLE_SHOWCASE_NAME)
14+
: undefined;
15+
const featured = entries.filter(entry => (
16+
entry.name !== FIDDLE_SHOWCASE_NAME
17+
&& (internalShowcasesEnabled || entry.name !== HELLO_SHOWCASE_NAME)
18+
));
19+
20+
return { featured, fiddleShowcase };
21+
}

lynxtron-go/src/app/store.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export const HELLO_SHOWCASE_NAME = '@lynxtron-examples/hello-lynxtron';
125125
declare const __SHOWCASE_REGISTRY__: ShowcaseEntry[];
126126
declare const __SHOWCASE_PREVIEW__: boolean;
127127
declare const __SHOWCASE_LOCAL_WORKSPACE__: boolean;
128+
declare const __GALLERY_INTERNAL_SHOWCASES__: boolean;
128129

129130
const BAKED_SHOWCASE_REGISTRY: ShowcaseEntry[] =
130131
typeof __SHOWCASE_REGISTRY__ !== 'undefined' ? __SHOWCASE_REGISTRY__ : [];
@@ -136,6 +137,9 @@ export const SHOWCASE_PREVIEW: boolean =
136137
typeof __SHOWCASE_PREVIEW__ !== 'undefined' ? __SHOWCASE_PREVIEW__ : false;
137138
export const SHOWCASE_LOCAL_WORKSPACE: boolean =
138139
typeof __SHOWCASE_LOCAL_WORKSPACE__ !== 'undefined' ? __SHOWCASE_LOCAL_WORKSPACE__ : false;
140+
/** Build-time switch for internal cards/cases on the Gallery surface only. */
141+
export const GALLERY_INTERNAL_SHOWCASES: boolean =
142+
typeof __GALLERY_INTERNAL_SHOWCASES__ !== 'undefined' ? __GALLERY_INTERNAL_SHOWCASES__ : false;
139143

140144
/**
141145
* file:// URLs of the Lynxtron mark beside app.asar; empty under vitest.

0 commit comments

Comments
 (0)