|
15 | 15 | // to ensure variable is bound after its creation
|
16 | 16 | onMount(() => settingHeight = settingEl.offsetTop)
|
17 | 17 | const isSmallScreen = window.screen.width < 470
|
18 |
| - const goToSetting = async () => { |
| 18 | + const goToSetting = sectionName => async () => { |
| 19 | + section = sectionName |
19 | 20 | if (isSmallScreen) {
|
20 |
| - await wait(5) // |
| 21 | + await wait(5) |
21 | 22 | window.scrollTo({
|
22 | 23 | top: settingHeight,
|
23 | 24 | behavior: 'smooth'
|
|
29 | 30 | <div class="wrapper">
|
30 | 31 | <div class="subwrapper">
|
31 | 32 | <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')}> |
33 | 34 | {I18n('profile')}
|
34 | 35 | </button>
|
35 |
| - <button class="{section === 'account' ? 'active' : ''}" on:click={goToSetting} on:click="{() => { section = 'account' }}"> |
| 36 | + <button class:active={section === 'account'} on:click={goToSetting('account')}> |
36 | 37 | {I18n('account')}
|
37 | 38 | </button>
|
38 |
| - <button class="{section === 'notifications' ? 'active' : ''}" on:click={goToSetting} on:click="{() => { section = 'notifications' }}"> |
| 39 | + <button class:active={section === 'notifications'} on:click={goToSetting('notifications')}> |
39 | 40 | {I18n('notifications')}
|
40 | 41 | </button>
|
41 |
| - <button class="{section === 'data' ? 'active' : ''}" on:click={goToSetting} on:click="{() => { section = 'data' }}"> |
| 42 | + <button class:active={section === 'data'} on:click={goToSetting('data')}> |
42 | 43 | {I18n('data')}
|
43 | 44 | </button>
|
44 |
| - <button class="{section === 'display' ? 'active' : ''}" on:click={goToSetting} on:click="{() => { section = 'display' }}"> |
| 45 | + <button class:active={section === 'display'} on:click={goToSetting('display')}> |
45 | 46 | {I18n('display')}
|
46 | 47 | </button>
|
47 | 48 | </nav>
|
48 | 49 | </div>
|
49 | 50 | <div class="setting" bind:this={settingEl}>
|
50 | 51 | {#if section === 'profile'}
|
51 | 52 | <Profile user={app.user}/>
|
52 |
| - {/if} |
53 |
| - {#if section === 'account'} |
| 53 | + {:else if section === 'account'} |
54 | 54 | <Account user={app.user}/>
|
55 |
| - {/if} |
56 |
| - {#if section === 'notifications'} |
| 55 | + {:else if section === 'notifications'} |
57 | 56 | <Notifications/>
|
58 |
| - {/if} |
59 |
| - {#if section === 'display'} |
| 57 | + {:else if section === 'display'} |
60 | 58 | <Display/>
|
61 |
| - {/if} |
62 |
| - {#if section === 'data'} |
| 59 | + {:else if section === 'data'} |
63 | 60 | <Data user={app.user}/>
|
64 | 61 | {/if}
|
65 | 62 | </div>
|
|
0 commit comments