Skip to content

Commit

Permalink
Merge pull request #63 from ya-erm/dev
Browse files Browse the repository at this point in the history
Version 2.8.6
  • Loading branch information
ya-erm authored Jun 2, 2024
2 parents c45cd60 + 5114c3c commit 6d4f22a
Show file tree
Hide file tree
Showing 28 changed files with 565 additions and 123 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "client",
"version": "2.8.5",
"version": "2.8.6",
"private": true,
"scripts": {
"dev": "vite dev",
Expand Down
1 change: 1 addition & 0 deletions src/lib/data/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export type Account = {
color?: string;
tagIds?: string[];
deleted?: boolean;
archived?: boolean;
};

export type AccountViewModel = Account & {
Expand Down
5 changes: 5 additions & 0 deletions src/lib/translate/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ export const enDict: Dictionary = {
'accounts.select_color': 'Select color',
'accounts.tags': 'Tags',
'accounts.sort': 'Sort accounts',
'accounts.archived_accounts': 'Archived accounts',
'accounts.archive': 'Archive',
'accounts.archived': 'Archived',
'accounts.restore': 'Restore',
// Analytics
'analytics.title': 'Analytics',
'analytics.categories.start_date': 'Start date',
Expand Down Expand Up @@ -215,6 +219,7 @@ export const enDict: Dictionary = {
'transactions.import.select_category_for_all_operations': 'Select categories for all operations',
'transactions.import.finish': 'Finish import',
'transactions.import.finished': '{count, plural, one {# operation was imported} other {# operations were imported}}',
'transactions.show_more': 'Show more',
// Import rules
'transactions.import.rules.title': 'Rules of import',
'transactions.import.rules.create': 'Create rule',
Expand Down
5 changes: 5 additions & 0 deletions src/lib/translate/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export type Messages =
| 'accounts.select_color'
| 'accounts.tags'
| 'accounts.sort'
| 'accounts.archived_accounts'
| 'accounts.archive'
| 'accounts.archived'
| 'accounts.restore'
// Analytics
| 'analytics.title'
| 'analytics.categories.start_date'
Expand Down Expand Up @@ -194,6 +198,7 @@ export type Messages =
| 'transactions.feature_operations'
| 'transactions.another_currency'
| 'transactions.same_currency'
| 'transactions.show_more'
// Transactions import
| 'transactions.import'
| 'transactions.import.title'
Expand Down
5 changes: 5 additions & 0 deletions src/lib/translate/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ export const ruDict: Dictionary = {
'accounts.select_color': 'Выбрать цвет',
'accounts.tags': 'Теги',
'accounts.sort': 'Сортировка счетов',
'accounts.archived_accounts': 'Архивные счета',
'accounts.archive': 'В архив',
'accounts.archived': 'В архиве',
'accounts.restore': 'Восстановить',
// Analytics
'analytics.title': 'Аналитика',
'analytics.categories.start_date': 'Начало интервала',
Expand Down Expand Up @@ -201,6 +205,7 @@ export const ruDict: Dictionary = {
'transactions.feature_operations': 'Будущие операции',
'transactions.another_currency': 'Другая валюта',
'transactions.same_currency': 'Та же валюта',
'transactions.show_more': 'Показать ещё',
// Transactions import
'transactions.import': 'Импорт',
'transactions.import.title': 'Импорт операций',
Expand Down
8 changes: 4 additions & 4 deletions src/lib/ui/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -98,28 +98,28 @@
button.transparent.primary {
color: var(--active-color);
}
button.transparent.primary.border {
button.primary.border {
box-shadow: 0 0 0 1px var(--active-color);
}
button.transparent.secondary {
color: var(--secondary-text-color);
}
button.transparent.secondary.border {
button.secondary.border {
box-shadow: 0 0 0 1px var(--secondary-text-color);
}
button.transparent.success {
color: var(--green-color);
}
button.transparent.success.border {
button.success.border {
box-shadow: 0 0 0 1px var(--green-color);
}
button.transparent.danger {
color: var(--red-color);
}
button.transparent.danger.border {
button.danger.border {
box-shadow: 0 0 0 1px var(--red-color);
}
Expand Down
112 changes: 112 additions & 0 deletions src/lib/ui/IntersectionObserver.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<script>
/**
* The HTML Element to observe.
* @type {null | HTMLElement}
*/
export let element = null;
/**
* Set to `true` to unobserve the element
* after it intersects the viewport.
* @type {boolean}
*/
export let once = false;
/**
* `true` if the observed element
* is intersecting the viewport.
*/
export let intersecting = false;
/**
* Specify the containing element.
* Defaults to the browser viewport.
* @type {null | HTMLElement}
*/
export let root = null;
/** Margin offset of the containing element. */
export let rootMargin = '0px';
/**
* Percentage of element visibility to trigger an event.
* Value must be between 0 and 1.
*/
export let threshold = 0;
/**
* Observed element metadata.
* @type {null | IntersectionObserverEntry}
*/
export let entry = null;
/**
* `IntersectionObserver` instance.
* @type {null | IntersectionObserver}
*/
export let observer = null;
import { tick, createEventDispatcher, afterUpdate, onMount } from 'svelte';
const dispatch = createEventDispatcher();
/** @type {null | string} */
let prevRootMargin = null;
/** @type {null | HTMLElement} */
let prevElement = null;
const initialize = () => {
observer = new IntersectionObserver(
(entries) => {
entries.forEach((_entry) => {
entry = _entry;
intersecting = _entry.isIntersecting;
});
},
{ root, rootMargin, threshold },
);
};
onMount(() => {
initialize();
return () => {
if (observer) {
observer.disconnect();
observer = null;
}
};
});
afterUpdate(async () => {
if (entry !== null) {
dispatch('observe', entry);
if (entry.isIntersecting) {
dispatch('intersect', entry);
if (element && once) observer?.unobserve(element);
}
}
await tick();
if (element !== null && element !== prevElement) {
observer?.observe(element);
if (prevElement !== null) observer?.unobserve(prevElement);
prevElement = element;
}
if (prevRootMargin && rootMargin !== prevRootMargin) {
observer?.disconnect();
prevElement = null;
initialize();
}
prevRootMargin = rootMargin;
});
</script>
<slot {intersecting} {entry} {observer} />
2 changes: 1 addition & 1 deletion src/lib/ui/Modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
.modal {
max-width: calc(100vw - 4rem);
max-height: calc(100vh - 4rem);
border-radius: 0.75em;
border-radius: 1.5em;
background: var(--header-background-color);
border: 1px solid var(--border-color);
padding: 1em;
Expand Down
39 changes: 39 additions & 0 deletions src/lib/ui/ShowMoreContainer.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script lang="ts">
import { translate } from '$lib/translate';
import Button from '$lib/ui/Button.svelte';
import IntersectionObserver from '$lib/ui/IntersectionObserver.svelte';
export let limit: number;
export let step: number;
export let total: number;
let showMoreContainer: HTMLDivElement;
const showMore = () => {
limit = Math.min(total, limit + step);
};
</script>

<IntersectionObserver element={showMoreContainer} on:intersect={showMore}>
<slot />
<div class="show-more">
<div bind:this={showMoreContainer} class="show-more-before" />
{#if limit < total}
<div class="flex-col px-1 pb-1">
<Button color="white" on:click={showMore}>
{$translate('transactions.show_more')}
</Button>
</div>
{/if}
</div>
</IntersectionObserver>

<style>
.show-more {
position: relative;
}
.show-more-before {
position: absolute;
top: -200px;
}
</style>
10 changes: 4 additions & 6 deletions src/lib/ui/Spoiler.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
export let duration = '0.5s';
let content: HTMLDivElement;
$: height = hidden ? 0 : content?.getBoundingClientRect()?.height;
</script>

<div class="spoiler-header" style:--duration={duration}>
<slot name="spoiler-header" />
</div>
<div
class="spoiler"
class:spoiler-hidden={hidden}
style:--height={`${content?.getBoundingClientRect()?.height}px`}
style:--duration={duration}
>
<div class="spoiler" class:spoiler-hidden={hidden} style:--height={`${height}px`} style:--duration={duration}>
<div class="spoiler-content" bind:this={content}>
<slot />
</div>
Expand All @@ -24,6 +21,7 @@
overflow: hidden;
height: var(--height, auto);
transition: height var(--duration, 0.5s);
flex-shrink: 0;
}
.spoiler-hidden {
height: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
import Icon from '$lib/ui/Icon.svelte';
export let hidden: boolean;
export let futureOperationsCount: number;
</script>

<button class="future-operations-button flex gap-1 items-center justify-between" on:click={() => (hidden = !hidden)}>
<button
class="spoiler-toggle flex gap-1 items-center justify-between"
on:click={() => (hidden = !hidden)}
type="button"
>
<h3 class="m-0 font-normal">
<span>{$translate('transactions.feature_operations')}</span>
<span class="operations-count">
{$translate('common.count', { values: { count: futureOperationsCount } })}
</span>
<slot />
</h3>
<div class="flex items-center">
<span>{$translate(hidden ? 'common.show' : 'common.hide')}</span>
<div class="future-operations-button-icon" class:shown={!hidden}>
<div class="spoiler-toggle-icon" class:shown={!hidden}>
<Icon padding={0} name={'mdi:chevron-down'} />
</div>
</div>
</button>

<style>
.future-operations-button {
.spoiler-toggle {
border: none;
background: none;
color: var(--primary-text-color);
Expand All @@ -31,17 +31,13 @@
width: 100%;
padding: 0;
}
.future-operations-button:hover {
.spoiler-toggle:hover {
color: var(--active-color);
}
.future-operations-button-icon {
.spoiler-toggle-icon {
transition: transform var(--duration, 0.5s);
}
.future-operations-button-icon.shown {
.spoiler-toggle-icon.shown {
transform: scaleY(-1);
}
.operations-count {
font-size: 0.85rem;
color: var(--secondary-text-color);
}
</style>
2 changes: 2 additions & 0 deletions src/lib/widgets/TagsList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
export let tags: Tag[];
export let selectedTags: string[] = [];
export let readOnly: boolean = false;
export let onAdd: (tag: Tag) => void;
export let onEdit: (tag: Tag) => void;
Expand Down Expand Up @@ -58,5 +59,6 @@
onAdd={addTag}
onEdit={editTag}
onDelete={deleteTag}
{readOnly}
/>
<input name="tags" class="hidden" multiple value={selectedTags} />
Loading

0 comments on commit 6d4f22a

Please sign in to comment.