Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.

Commit 1688e14

Browse files
committed
settings_layout: refactor
1 parent 980bf6c commit 1688e14

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

app/modules/settings/components/settings_layout.svelte

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
// to ensure variable is bound after its creation
1616
onMount(() => settingHeight = settingEl.offsetTop)
1717
const isSmallScreen = window.screen.width < 470
18-
const goToSetting = async () => {
18+
const goToSetting = sectionName => async () => {
19+
section = sectionName
1920
if (isSmallScreen) {
20-
await wait(5) //
21+
await wait(5)
2122
window.scrollTo({
2223
top: settingHeight,
2324
behavior: 'smooth'
@@ -29,37 +30,33 @@
2930
<div class="wrapper">
3031
<div class="subwrapper">
3132
<nav class="navigation">
32-
<button class="{section === 'profile' ? 'active' : ''}" on:click={goToSetting} on:click="{() => { section = 'profile' }}">
33+
<button class:active={section === 'profile'} on:click={goToSetting('profile')}>
3334
{I18n('profile')}
3435
</button>
35-
<button class="{section === 'account' ? 'active' : ''}" on:click={goToSetting} on:click="{() => { section = 'account' }}">
36+
<button class:active={section === 'account'} on:click={goToSetting('account')}>
3637
{I18n('account')}
3738
</button>
38-
<button class="{section === 'notifications' ? 'active' : ''}" on:click={goToSetting} on:click="{() => { section = 'notifications' }}">
39+
<button class:active={section === 'notifications'} on:click={goToSetting('notifications')}>
3940
{I18n('notifications')}
4041
</button>
41-
<button class="{section === 'data' ? 'active' : ''}" on:click={goToSetting} on:click="{() => { section = 'data' }}">
42+
<button class:active={section === 'data'} on:click={goToSetting('data')}>
4243
{I18n('data')}
4344
</button>
44-
<button class="{section === 'display' ? 'active' : ''}" on:click={goToSetting} on:click="{() => { section = 'display' }}">
45+
<button class:active={section === 'display'} on:click={goToSetting('display')}>
4546
{I18n('display')}
4647
</button>
4748
</nav>
4849
</div>
4950
<div class="setting" bind:this={settingEl}>
5051
{#if section === 'profile'}
5152
<Profile user={app.user}/>
52-
{/if}
53-
{#if section === 'account'}
53+
{:else if section === 'account'}
5454
<Account user={app.user}/>
55-
{/if}
56-
{#if section === 'notifications'}
55+
{:else if section === 'notifications'}
5756
<Notifications/>
58-
{/if}
59-
{#if section === 'display'}
57+
{:else if section === 'display'}
6058
<Display/>
61-
{/if}
62-
{#if section === 'data'}
59+
{:else if section === 'data'}
6360
<Data user={app.user}/>
6461
{/if}
6562
</div>

0 commit comments

Comments
 (0)