Skip to content

Commit

Permalink
do not show language selection if there is only one language
Browse files Browse the repository at this point in the history
  • Loading branch information
Uptaker committed Nov 10, 2023
1 parent c66f957 commit 53bc1d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/layout/LangSwitcher.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
}
$: if (lang) localProjectStore.setLang(lang)
</script>

<select bind:value={lang} class="form-select w-auto shadow-sm">
{#each project.langs as l}
<option>{l}</option>
{/each}
</select>
{#if project.langs.length > 1}
<select bind:value={lang} class="form-select w-auto shadow-sm">
{#each project.langs as l}
<option>{l}</option>
{/each}
</select>
{/if}
7 changes: 7 additions & 0 deletions src/layout/LangSwticher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@ describe('<LangSwitcher>', () => {
expect(select).to.exist
expect(select.options).to.have.length(3)
})

it('hides if only one language', () => {
const project = new LoadedProject({} as Project, {de: {}})
const {container} = render(LangSwitcher, {project, lang})
let select = container.querySelector('select')!
expect(select).to.not.exist
})
})

0 comments on commit 53bc1d3

Please sign in to comment.