Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update date sidebar to support vertical and horizontal layouts. #291

Merged
merged 2 commits into from
Jan 28, 2024
Merged
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
37 changes: 34 additions & 3 deletions src/lib/Modal/DateConfig.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
<h2>{$lang('preview')}</h2>

<div class="preview">
<Date short_day={sel?.short_day} short_month={sel?.short_month} hide={sel?.hide} />
<Date
short_day={sel?.short_day}
short_month={sel?.short_month}
hide={sel?.hide}
layout={sel?.layout}
/>
</div>

<!-- DAY -->
Expand Down Expand Up @@ -79,19 +84,45 @@
</button>
<button
class:selected={sel?.hide === 'day'}
on:click={() => set('hide', 'day')}
on:click={() => {
set('hide', 'day');
set('layout', 'vertical');
}}
use:Ripple={$ripple}
>
{$lang('day')}
</button>
<button
class:selected={sel?.hide === 'month'}
on:click={() => set('hide', 'month')}
on:click={() => {
set('hide', 'month');
set('layout', 'vertical');
}}
use:Ripple={$ripple}
>
{$lang('month')}
</button>
</div>
{#if !sel?.hide || sel?.hide === 'none'}
<!-- Layout -->
<h2>{$lang('Layout')}</h2>
<div class="button-container">
<button
class:selected={!sel?.layout || sel?.layout === 'vertical'}
on:click={() => set('layout', 'vertical')}
use:Ripple={$ripple}
>
{$lang('vertical')}
</button>
<button
class:selected={sel?.layout === 'horizontal'}
on:click={() => set('layout', 'horizontal')}
use:Ripple={$ripple}
>
{$lang('horizontal')}
</button>
</div>
{/if}

<ConfigButtons {sel} />
</Modal>
Expand Down
18 changes: 13 additions & 5 deletions src/lib/Sidebar/Date.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
export let short_day: boolean | undefined = undefined;
export let short_month: boolean | undefined = undefined;
export let hide: string | undefined = undefined;
export let layout: string | undefined = undefined;

$: weekDay = $timer.toLocaleDateString($selectedLanguage, {
weekday: short_day ? 'short' : 'long'
Expand All @@ -13,15 +14,22 @@
day: 'numeric',
month: short_month ? 'short' : 'long'
});

$: orientation = layout || 'vertical';
</script>

<div>
{#if hide !== 'day'}
{weekDay}<br />
{/if}
{#if orientation === 'vertical'}
{#if hide !== 'day'}
{weekDay}<br />
{/if}

{#if hide !== 'month'}
{shortDate}<br />
{#if hide !== 'month'}
{shortDate}<br />
{/if}
{/if}
{#if orientation === 'horizontal'}
{weekDay},&nbsp;{shortDate}
{/if}
</div>

Expand Down
1 change: 1 addition & 0 deletions src/lib/Sidebar/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
short_day={item?.short_day}
short_month={item?.short_month}
hide={item?.hide}
layout={item?.layout}
/>
</button>

Expand Down
1 change: 1 addition & 0 deletions src/lib/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export interface DateItem {
short_day?: boolean;
short_month?: boolean;
hide?: string;
layout?: string;
}

export interface GraphItem {
Expand Down