Skip to content

Commit

Permalink
feat: add wide layout support
Browse files Browse the repository at this point in the history
  • Loading branch information
kurozenzen committed Jan 27, 2024
1 parent ac36973 commit f49032f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/lib/store/store-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export enum StoreKey {
AlwaysLoop = 'kurosearch:always-loop',
CookiesAccepted = 'kurosearch:cookies-accepted',
HighResolutionEnabled = 'kurosearch:high-resolution-enabled',
WideLayoutEnabled = 'kurosearch:wide-layout-enabled'
}
15 changes: 15 additions & 0 deletions src/lib/store/wide-layout-enabled-store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { boolParser, boolSerializer, persistentWritable } from './persistent-store';
import { StoreKey } from './store-keys';

const createWideLayoutEnabledStore = () => {
const initial = false;
const { subscribe, set } = persistentWritable(
StoreKey.WideLayoutEnabled,
initial,
boolSerializer,
boolParser
);
return { subscribe, set, reset: () => set(initial) };
};

export default createWideLayoutEnabledStore();
8 changes: 7 additions & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import CodiconLink from '$lib/components/pure/icon-link/CodiconLink.svelte';
import CodiconTextLink from '$lib/components/pure/icon-link/CodiconTextLink.svelte';
import theme from '$lib/store/theme-store';
import wideLayoutEnabled from '$lib/store/wide-layout-enabled-store';
import { browser } from '$app/environment';
import { page } from '$app/stores';
import './reset.css';
import './fonts.css';
import './defaults.css';
Expand Down Expand Up @@ -51,7 +53,7 @@
</nav>
</header>

<main>
<main class:extra-wide={$wideLayoutEnabled && $page.url.pathname === '/'}>
<slot />
</main>

Expand Down Expand Up @@ -91,6 +93,10 @@
max-width: var(--body-width);
}
main.extra-wide {
max-width: 90vw;
}
header,
footer {
padding: var(--grid-gap);
Expand Down
19 changes: 16 additions & 3 deletions src/routes/preferences/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import resultsStore from '$lib/store/results-store';
import activeTagsStore from '$lib/store/active-tags-store';
import activeSupertagsStore from '$lib/store/active-supertags-store';
import wideLayoutEnabled from '$lib/store/wide-layout-enabled-store';
let resetDialog: HTMLDialogElement;
Expand All @@ -41,6 +42,7 @@
resultColumns.reset();
cookiesAccepted.reset();
highResolutionEnabled.reset();
wideLayoutEnabled.reset();
};
</script>

Expand All @@ -63,7 +65,7 @@
<Checkbox id="checkbox-localstorage-enabled" bind:checked={$localstorageEnabled}>
{$localstorageEnabled ? 'Save' : "Don't save"}
</Checkbox>
<div>
<div class="button-row">
<TextButton title="Reset Posts" type="secondary" on:click={() => resultsStore.reset()}>
Reset Posts
</TextButton>
Expand Down Expand Up @@ -101,7 +103,12 @@
</Preference>

<Preference title="Result layout" description="Save active tags and posts between sessions.">
<Select bind:value={$resultColumns} options={RESULT_COLUMNS_OPTIONS} />
<div class="flex">
<Select bind:value={$resultColumns} options={RESULT_COLUMNS_OPTIONS} />
<Checkbox id="checkbox-wide-layout" bind:checked={$wideLayoutEnabled}>
{$wideLayoutEnabled ? 'Extra wide' : 'Default width'}
</Checkbox>
</div>
</Preference>

<Preference
Expand Down Expand Up @@ -136,10 +143,16 @@
padding-inline: var(--grid-gap);
}
div {
.button-row {
display: flex;
padding-block-start: var(--grid-gap);
flex-wrap: wrap;
gap: var(--grid-gap);
}
.flex {
display: flex;
flex-wrap: wrap;
gap: var(--grid-gap);
}
</style>

0 comments on commit f49032f

Please sign in to comment.