This repository has been archived by the owner on May 28, 2024. It is now read-only.
forked from starboardcoop/things-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from pvdthings/dev
v0.12
- Loading branch information
Showing
40 changed files
with
321 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as Button } from "./Button.svelte"; | ||
export * from "./button"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
button.chooser-button { | ||
@apply px-3 py-1 font-bold font-display text-left outline-none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<script lang="ts"> | ||
import "./Chooser.css"; | ||
import { createEventDispatcher } from 'svelte'; | ||
import { t, locale } from '$lib/language/translate'; | ||
import ChevronIcon from "$lib/icons/chevron.svg"; | ||
import ChooserBody from './ChooserBody.svelte'; | ||
export let options = []; | ||
let chosenOption = options[0]; | ||
let dropdownHidden = true; | ||
let innerWidth: number; | ||
$: isEnglish = $locale === 'en'; | ||
const dispatch = createEventDispatcher(); | ||
const toggleDropdown = () => { | ||
dropdownHidden = !dropdownHidden; | ||
if (innerWidth < 768) { | ||
document.body.classList.toggle('overflow-hidden'); | ||
} else { | ||
document.body.classList.remove('overflow-hidden'); | ||
} | ||
}; | ||
const optionChosen = (option) => { | ||
chosenOption = option; | ||
toggleDropdown(); | ||
dispatch('chosen', option); | ||
}; | ||
</script> | ||
|
||
<svelte:window bind:innerWidth on:click={() => (dropdownHidden = true)} /> | ||
|
||
<div class="relative h-11" on:click|stopPropagation={() => {}} on:keypress={() => {}}> | ||
<button | ||
on:click={toggleDropdown} | ||
class="chooser-button bg-indigo-100 hover:bg-indigo-50 h-full w-48 brutal hovers" | ||
> | ||
<img | ||
class="inline mr-1" | ||
src={ChevronIcon} | ||
alt="Dropdown" | ||
/> | ||
<span>{isEnglish ? chosenOption : $t(chosenOption)}</span> | ||
</button> | ||
<ChooserBody | ||
hidden={dropdownHidden} | ||
title={$t('Category')} | ||
{chosenOption} | ||
{options} | ||
onOptionClick={optionChosen} | ||
onClose={toggleDropdown} | ||
/> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<script lang="ts"> | ||
import "./Chooser.css"; | ||
import ChevronIcon from "$lib/icons/chevron.svg"; | ||
import CloseIcon from '$lib/icons/x-mark.svg'; | ||
import ChooserItem from './ChooserItem.svelte'; | ||
import { t } from "$lib/language/translate"; | ||
export let title: string; | ||
export let chosenOption: string; | ||
export let options: string[]; | ||
export let hidden: boolean; | ||
export let onOptionClick: (option: string) => void; | ||
export let onClose: () => void; | ||
</script> | ||
|
||
<div | ||
class:body-hidden={hidden} | ||
class="fixed top-0 left-0 w-full h-full overflow-hidden md:h-fit md:absolute bg-indigo-50 md:brutal md:hovers-above md:rounded-md flex flex-col z-50" | ||
> | ||
<div class="md:hidden"> | ||
<div class="p-4 bg-primary text-2xl font-bold text-left sticky top-0"> | ||
{title} | ||
<button class="float-right" on:click={onClose}> | ||
<img class="w-[30px] h-[30px]" src={CloseIcon} alt="close" /> | ||
</button> | ||
</div> | ||
<hr class="border-black border-opacity-20" /> | ||
</div> | ||
<button | ||
on:click={onClose} | ||
class="chooser-button hidden md:block bg-primary h-11 w-full border-b-2 border-black" | ||
> | ||
<img | ||
class="inline rotate-180 mr-1" | ||
src={ChevronIcon} | ||
alt="Dropdown" | ||
/> | ||
<span>{$t(chosenOption)}</span> | ||
</button> | ||
<div class="flex flex-col overflow-y-scroll"> | ||
{#each options as option} | ||
<hr /> | ||
<ChooserItem | ||
on:click={() => onOptionClick(option)} | ||
selected={chosenOption == option} | ||
> | ||
{$t(option)} | ||
</ChooserItem> | ||
{/each} | ||
</div> | ||
</div> | ||
|
||
<style lang="postcss"> | ||
.body-hidden { | ||
@apply hidden; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<script lang="ts"> | ||
import CheckIcon from "$lib/icons/check.svg"; | ||
export let selected: boolean; | ||
</script> | ||
|
||
<button | ||
on:click | ||
class:selected | ||
class="text-2xl md:text-lg p-4 md:py-2 text-left hover:bg-gray-300 align-middle" | ||
> | ||
<slot /> | ||
{#if selected} | ||
<img class="inline-block float-right mt-1 w-[20px] h-[20px]" src={CheckIcon} alt="Selected" /> | ||
{/if} | ||
</button | ||
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Chooser } from "./Chooser.svelte"; |
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/lib/LoadingIndicator.svelte → src/lib/components/LoadingIndicator.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export { default as Button } from "./Button/Button.svelte"; | ||
export { Chooser } from "./Chooser"; | ||
export { default as Column } from "./Column.svelte"; | ||
export { default as Head } from "./Head.svelte"; | ||
export { default as LoadingIndicator } from "./LoadingIndicator.svelte"; | ||
export { default as Row } from "./Row.svelte"; | ||
export { default as TextInput } from "./TextInput.svelte"; | ||
export { default as Title } from "./Title.svelte"; |
2 changes: 1 addition & 1 deletion
2
src/lib/layout/Footer.svelte → src/lib/components/layout/Footer.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
src/lib/things/BorrowModal.svelte → ...nts/things/BorrowModal/BorrowModal.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as BorrowModal } from './BorrowModal.svelte'; | ||
export * from './stores'; |
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/lib/things/Thing.svelte → src/lib/components/things/Thing.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/lib/things/Things.svelte → src/lib/components/things/Things.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { defaultFilterCategory, filter } from "$lib/utils/filters"; | ||
import { derived, writable } from "svelte/store"; | ||
|
||
export const categoryFilter = writable<string>(defaultFilterCategory); | ||
|
||
export const searchFilter = writable<string>(''); | ||
|
||
export const wishListFilter = writable<boolean>(false); | ||
|
||
export const things = writable<[]>(undefined); | ||
|
||
export const filteredThings = derived( | ||
[things, categoryFilter, searchFilter, wishListFilter], | ||
([$things, $categoryFilter, $searchFilter, $wishListFilter]) => { | ||
return filter($things, { | ||
keyword: $searchFilter, | ||
onlyWishList: $wishListFilter, | ||
category: $categoryFilter | ||
}); | ||
} | ||
); | ||
|
||
export const categories = writable<[]>(undefined); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<script> | ||
import { Chooser } from "$lib/components"; | ||
import { categories, categoryFilter } from "$lib/stores/catalog"; | ||
const filterThingsByCategory = (event) => { | ||
$categoryFilter = event.detail; | ||
}; | ||
</script> | ||
|
||
<Chooser on:chosen={filterThingsByCategory} options={$categories} /> |
Oops, something went wrong.