Skip to content

Commit 40bb0e5

Browse files
committed
добавлены кнопки действий на страницу быстрой очистки на портале
1 parent c4004db commit 40bb0e5

File tree

12 files changed

+447
-75
lines changed

12 files changed

+447
-75
lines changed

portal/CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# Changelog
22

3+
## 1.7.0 Зелёный дипломат (2025-08-31)
4+
<img width="128" height="128" src="release-images/1.7.0.png"/>
5+
6+
https://github.com/tmible/wishlist/compare/c4004db..master
7+
8+
39
## 1.6.5 Пассажирский коридорный контролёр (2025-08-28)
410
<img width="128" height="128" src="release-images/1.6.5.png"/>
511

6-
https://github.com/tmible/wishlist/compare/e2679d3..master
12+
https://github.com/tmible/wishlist/compare/e2679d3..c4004db
713

814

915
## 1.6.4 Эпоха космический рассвет (2025-08-27)

portal/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tmible/wishlist-portal",
3-
"version": "1.6.5",
3+
"version": "1.7.0",
44
"private": true,
55
"description": "Портал со списками желаний",
66
"repository": {

portal/release-images/1.7.0.png

1.7 MB
Loading

portal/src/lib/card-swiper/card-swiper.svelte

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!-- https://github.com/flo-bit/svelte-swiper-cards -->
2+
<!-- 62d93b2ed39794899b6d293693ecc45850c4f921 -->
23
<!--
34
Copyright 2024 flo-bit
45
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@@ -8,9 +9,31 @@ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I
89
<script lang="ts">
910
import { onMount } from 'svelte';
1011
import { DragGesture, type FullGestureState } from '@use-gesture/vanilla';
11-
import type { CardData, Direction } from '.';
12+
import type { CardData, Direction, SwipeEventData } from '.';
1213
import Card from './card.svelte';
1314
15+
interface Props {
16+
swipe: (direction: Direction) => void;
17+
onSwipe: ((cardInfo: SwipeEventData) => void) | undefined;
18+
cardData: (index: number) => CardData;
19+
minSwipeDistance?: number;
20+
minSwipeVelocity?: number;
21+
arrowKeys?: boolean;
22+
thresholdPassed?: number;
23+
anchor?: number | null;
24+
}
25+
26+
let {
27+
swipe = $bindable(),
28+
onSwipe,
29+
cardData,
30+
minSwipeDistance = 0.5,
31+
minSwipeVelocity = 0.5,
32+
arrowKeys = true,
33+
thresholdPassed = $bindable(0),
34+
anchor = null,
35+
}: Props = $props();
36+
1437
let container: HTMLElement = $state();
1538
1639
let card1: HTMLElement = $state(), card2: HTMLElement = $state();
@@ -43,7 +66,9 @@ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I
4366
4467
let direction: Direction = movement[0] > 0 ? 'right' : 'left';
4568
let data = el === card1 ? card1Data : card2Data;
46-
swiped({ direction, element: el, data, index: cardIndex - 2 });
69+
70+
if (onSwipe) onSwipe({ direction, element: el, data, index: cardIndex - 2 });
71+
4772
thresholdPassed = movement[0] > 0 ? 1 : -1;
4873
4974
let moveOutWidth = document.body.clientWidth;
@@ -87,22 +112,22 @@ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I
87112
) => {
88113
let elWidth = el.offsetWidth;
89114
90-
if (state.pressed) {
115+
if (state.active) {
91116
let rotate = state.movement[0] * 0.03 * (state.movement[1] / 80);
92117
93118
// fix movement on a curved path if anchor is set
94119
if (anchor) {
95120
let vec = [state.movement[0], state.movement[1] - anchor];
96121
let len = Math.sqrt(vec[0] ** 2 + vec[1] ** 2);
97-
vec = [vec[0] / len * anchor, vec[1] / len * anchor];
122+
vec = [(vec[0] / len) * anchor, (vec[1] / len) * anchor];
98123
99124
state.movement[0] = vec[0];
100125
state.movement[1] = vec[1] + anchor;
101126
}
102127
103128
el.style.transform = `translate(${state.movement[0]}px, ${state.movement[1]}px) rotate(${rotate}deg)`;
104129
105-
if(Math.abs(state.movement[0]) / elWidth > minSwipeDistance) {
130+
if (Math.abs(state.movement[0]) / elWidth > minSwipeDistance) {
106131
thresholdPassed = state.movement[0] > 0 ? 1 : -1;
107132
} else {
108133
thresholdPassed = 0;
@@ -126,42 +151,24 @@ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I
126151
}
127152
};
128153
129-
export const swipe = (direction: Direction = 'right') => {
130-
if(thresholdPassed !== 0) return;
154+
swipe = (direction: Direction = 'right') => {
155+
if (thresholdPassed !== 0) return;
131156
132157
let dir = direction === 'left' ? -1 : 1;
133158
cardSwiped(topCard, [dir, 0.1], [dir, 1]);
134159
};
135-
136-
interface Props {
137-
cardData: (index: number) => CardData;
138-
minSwipeDistance?: number;
139-
minSwipeVelocity?: number;
140-
arrowKeys?: boolean;
141-
thresholdPassed?: number;
142-
anchor?: number | null;
143-
swiped: () => void;
144-
}
145-
146-
let {
147-
cardData,
148-
minSwipeDistance = 0.5,
149-
minSwipeVelocity = 0.5,
150-
arrowKeys = true,
151-
thresholdPassed = $bindable(0),
152-
anchor = null,
153-
swiped,
154-
}: Props = $props();
155160
</script>
156161

157-
<svelte:body onkeydown={(e) => {
158-
if(!arrowKeys) return;
159-
if (e.key === 'ArrowLeft') {
160-
swipe('left');
161-
} else if (e.key === 'ArrowRight') {
162-
swipe('right');
163-
}
164-
}} />
162+
<svelte:body
163+
onkeydown={(e) => {
164+
if(!arrowKeys) return;
165+
if (e.key === 'ArrowLeft') {
166+
swipe('left');
167+
} else if (e.key === 'ArrowRight') {
168+
swipe('right');
169+
}
170+
}}
171+
/>
165172

166173
<div class="w-full h-full">
167174
<div class="w-full h-full relative hidden z-0" bind:this={container}>

portal/src/lib/card-swiper/card.svelte

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
11
<!-- https://github.com/flo-bit/svelte-swiper-cards -->
2+
<!-- 62d93b2ed39794899b6d293693ecc45850c4f921 -->
23
<!--
34
Copyright 2024 flo-bit
45
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
56
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
67
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
78
-->
89
<script lang="ts">
9-
import { fade } from "svelte/transition";
10-
11-
1210
interface Props {
1311
element: HTMLElement;
14-
color?: string;
1512
title?: string;
1613
description?: string;
1714
image?: string | undefined;
1815
}
1916
2017
let {
2118
element = $bindable(),
22-
color = '',
2319
title = '',
2420
description = '',
2521
image = undefined
2622
}: Props = $props();
2723
</script>
2824

2925
<div
30-
class="w-full h-full absolute cursor-grab ease-in-out rounded-xl touch-none select-none border border-black bg-base-100 {color}"
26+
class="w-full h-full absolute cursor-grab ease-in-out rounded-xl touch-none select-none md:border bg-base-100"
3127
bind:this={element}
3228
>
3329
{#key image}
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
// https://github.com/flo-bit/svelte-swiper-cards
2+
// 62d93b2ed39794899b6d293693ecc45850c4f921
23
/*
34
Copyright 2024 flo-bit
45
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
56
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
67
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
78
*/
9+
/**
10+
* change this to your own data structure, that each card will use
11+
* then change the Card.svelte file to use your data structure
12+
*/
813
export type CardData = {
914
title?: string;
10-
color?: string;
1115
description?: string;
1216
image?: string;
1317
};
1418

19+
export type SwipeEventData = {
20+
direction: Direction;
21+
data: CardData;
22+
index: number;
23+
element: HTMLElement;
24+
};
25+
1526
export type Direction = 'left' | 'right';
1627

1728
export { default as CardSwiper } from './card-swiper.svelte';

0 commit comments

Comments
 (0)