Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ packages/codify/
#code-graph
.adaptive-codegraph/
.fastembed_cache/
.vscode/
.vscode/
.playwright-mcp/
8 changes: 7 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,13 @@ const config: StorybookConfig = {
typescript: {
reactDocgen: 'react-docgen-typescript',
},
staticDirs: ['./public', { from: '../node_modules/@kerebron/wasm/assets', to: '/kerebron-wasm' }],
staticDirs: [
'./public',
{ from: '../node_modules/@kerebron/wasm/assets', to: '/kerebron-wasm' },
// Serve the exported Loco translation pack so the Loco runtime can load it
// in file (package) mode: Loco.init({ file: '/i18n/i18n-translations.json' })
{ from: '../src/i18n', to: '/i18n' },
],
async viteFinal(config) {
const optimizeDepNames = [
...datavisDependencyNames,
Expand Down
49 changes: 49 additions & 0 deletions .storybook/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,55 @@ addons.register('mieweb-brand-sync', (api) => {
});
});

// Hide the locale switcher while Loco is disabled — switching languages has no
// effect in that mode. The button is matched by the stable aria-label derived
// from the `locale` globalType description in preview.tsx.
const localeVisibilityStyleId = 'mieweb-loco-locale-visibility';

function setLocaleSwitcherHidden(hidden: boolean) {
const existing = document.getElementById(localeVisibilityStyleId);
if (!hidden) {
existing?.remove();
return;
}
if (existing) return;
const style = document.createElement('style');
style.id = localeVisibilityStyleId;
style.textContent = `
[role="toolbar"] button[aria-label^="Locale used by i18n"] {
display: none !important;
}
`;
Comment on lines +454 to +458
document.head.appendChild(style);
}

addons.register('mieweb-loco-locale-visibility', (api) => {
let previousLocoMode: unknown = api.getGlobals()?.locoMode;
setLocaleSwitcherHidden(previousLocoMode === 'disable');

const onGlobalsChanged = (globals?: Record<string, unknown>) => {
const locoMode = globals?.locoMode;
setLocaleSwitcherHidden(locoMode === 'disable');

// Changing the Loco mode resets the locale to English so every mode
// starts from the untranslated baseline.
if (previousLocoMode !== undefined && locoMode !== previousLocoMode && globals?.locale !== 'en') {
api.updateGlobals({ locale: 'en' });
}
previousLocoMode = locoMode;
};

// 'setGlobals' fires once when the preview boots with the initial globals
// (from the URL); 'globalsUpdated' fires on every toolbar change.
api.on('setGlobals', ({ globals }: { globals?: Record<string, unknown> }) => {
previousLocoMode = globals?.locoMode;
setLocaleSwitcherHidden(globals?.locoMode === 'disable');
});
api.on('globalsUpdated', ({ globals }) => {
onGlobalsChanged(globals);
});
});

// Redirect old/broken story bookmarks to the Introduction page
addons.register('mieweb-404-redirect', (api) => {
const FALLBACK_ID = 'introduction--docs';
Expand Down
Loading
Loading