Skip to content

Commit

Permalink
build: fix type of globalThis
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB committed Nov 28, 2024
1 parent a3d0b51 commit 956f340
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 8 additions & 2 deletions src/elements/core/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ export interface SbbConfig {

export function readConfig(): SbbConfig {
if (!('sbbConfig' in globalThis)) {
(globalThis as any).sbbConfig = {}; // TODO: fix any type
globalThis.sbbConfig = {};
}
return (globalThis as any).sbbConfig as SbbConfig; // TODO: fix any type
return globalThis.sbbConfig as SbbConfig;
}

export function mergeConfig(config: Partial<SbbConfig>): void {
const oldConfig = readConfig();
Object.assign(oldConfig, config);
}

declare global {
// Only `var` is working
// eslint-disable-next-line no-var
var sbbConfig: SbbConfig;
}
4 changes: 2 additions & 2 deletions src/elements/icon/icon.snapshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe(`sbb-icon`, () => {
let interceptorCalled = false;
globalConfig.icon = {};

const sbbIconConfig: SbbIconConfig = (globalThis as any).sbbConfig.icon; // TODO: fix any type
const sbbIconConfig: SbbIconConfig = globalThis.sbbConfig.icon!;
sbbIconConfig.namespaces = new Map<string, string>().set(
'kom',
'https://icons.app.sbb.ch/kom/',
Expand Down Expand Up @@ -154,7 +154,7 @@ describe(`sbb-icon`, () => {
expect(interceptorCalled).to.be.true;

// Reset icon config
delete (globalThis as any).sbbConfig.icon; // TODO: fix any type
delete globalThis.sbbConfig.icon;
});

testA11yTreeSnapshot(html`<sbb-icon name="app-icon-medium"></sbb-icon>`);
Expand Down
8 changes: 1 addition & 7 deletions src/elements/navigation/navigation/navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,8 @@
--sbb-navigation-content-transform: translateX(-100%);

@include sbb.mq($from: 'large') {
--sbb-navigation-expanded-width: 100vw;
--sbb-navigation-expanded-width: 100dvw;
--sbb-navigation-content-transform: translateX(0%);

// Needed for backwards compatibility
// TODO: Remove once not needed
@supports (height: 100dvw) {
--sbb-navigation-expanded-width: 100dvw;
}
}
}

Expand Down

0 comments on commit 956f340

Please sign in to comment.