Skip to content

Commit bf3dd7f

Browse files
committed
fix: gallery icons
1 parent 53720b8 commit bf3dd7f

7 files changed

Lines changed: 129 additions & 20 deletions

File tree

docs/src/app/components/icon-list.const.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ import {
242242
FrameIcon,
243243
GalleryHorizontalEndIcon,
244244
GalleryHorizontalIcon,
245-
// GalleryThumbnailsIcon,
245+
GalleryThumbnailsIcon,
246246
GalleryVerticalEndIcon,
247247
GalleryVerticalIcon,
248248
GaugeIcon,
@@ -746,11 +746,11 @@ export const ICONS_LIST: IconItem[] = [
746746
{ name: 'folder-sync', component: FolderSyncIcon },
747747
{ name: 'folder-up', component: FolderUpIcon },
748748
// { wip: true, name: 'frame', component: FrameIcon },
749-
// { wip: true, name: 'gallery-horizontal-end', component: GalleryHorizontalEndIcon },
750-
// { wip: true, name: 'gallery-horizontal', component: GalleryHorizontalIcon },
751-
// // { wip: true, name: 'gallery-thumbnails', component: GalleryThumbnailsIcon },
752-
// { wip: true, name: 'gallery-vertical-end', component: GalleryVerticalEndIcon },
753-
// { wip: true, name: 'gallery-vertical', component: GalleryVerticalIcon },
749+
{ name: 'gallery-horizontal-end', component: GalleryHorizontalEndIcon },
750+
{ name: 'gallery-horizontal', component: GalleryHorizontalIcon },
751+
{ name: 'gallery-thumbnails', component: GalleryThumbnailsIcon },
752+
{ name: 'gallery-vertical-end', component: GalleryVerticalEndIcon },
753+
{ name: 'gallery-vertical', component: GalleryVerticalIcon },
754754
{ name: 'gauge', component: GaugeIcon },
755755
{ name: 'gavel', component: GavelIcon },
756756
{ name: 'grid-2x2-check', component: Grid2x2CheckIcon },

packages/animated-icons/src/icons/gallery-horizontal-end.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ import { ANIMATED_ICONS_CONFIG } from '../tokens/provider';
2626
stroke-linecap="round"
2727
stroke-linejoin="round"
2828
>
29-
<svg:path d="M2 7v10" custom="1" />
30-
<svg:path d="M6 5v14" custom="2" />
29+
<svg:path class="path1" d="M2 7v10" />
30+
<svg:path class="path2" d="M6 5v14" />
3131
<svg:rect width="12" height="18" x="10" y="3" rx="2" />
3232
</svg>
3333
`,
3434
styles: `
3535
:host {
3636
display: inline-block;
3737
}
38-
path {
38+
.gallery-horizontal-end-icon path {
3939
transition:
4040
transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
4141
opacity 0.3s ease;
@@ -44,11 +44,11 @@ import { ANIMATED_ICONS_CONFIG } from '../tokens/provider';
4444
transform: translateX(0);
4545
}
4646
47-
path[custom='1'].animate {
47+
.gallery-horizontal-end-icon.animate .path1 {
4848
animation: disappearThenAppear1 0.6s forwards;
4949
}
5050
51-
path[custom='2'].animate {
51+
.gallery-horizontal-end-icon.animate .path2 {
5252
animation: disappearThenAppear2 0.6s forwards;
5353
}
5454
@@ -116,7 +116,7 @@ export class GalleryHorizontalEndIcon {
116116
handleMouseEnter(forced = false) {
117117
if (forced || (!this.animate() && !this.isAnimating())) {
118118
this.isAnimating.set(true);
119-
this.#timer = setTimeout(() => this.isAnimating.set(false), 1400);
119+
this.#timer = setTimeout(() => this.isAnimating.set(false), 600);
120120
}
121121
}
122122

packages/animated-icons/src/icons/gallery-horizontal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class GalleryHorizontalIcon {
108108
handleMouseEnter(forced = false) {
109109
if (forced || (!this.animate() && !this.isAnimating())) {
110110
this.isAnimating.set(true);
111-
this.#timer = setTimeout(() => this.isAnimating.set(false), 1400);
111+
this.#timer = setTimeout(() => this.isAnimating.set(false), 600);
112112
}
113113
}
114114

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import {
2+
booleanAttribute,
3+
ChangeDetectionStrategy,
4+
Component,
5+
effect,
6+
inject,
7+
input,
8+
linkedSignal,
9+
numberAttribute,
10+
} from '@angular/core';
11+
import { ANIMATED_ICONS_CONFIG } from '../tokens/provider';
12+
13+
@Component({
14+
selector: 'i-gallery-thumbnails',
15+
template: `
16+
<svg
17+
class="gallery-thumbnails-icon"
18+
[attr.width]="size()"
19+
[attr.height]="size()"
20+
[attr.stroke]="color()"
21+
[attr.stroke-width]="strokeWidth()"
22+
[class.animate]="isAnimating()"
23+
xmlns="http://www.w3.org/2000/svg"
24+
viewBox="0 0 24 24"
25+
fill="none"
26+
stroke-linecap="round"
27+
stroke-linejoin="round"
28+
>
29+
<svg:rect width="18" height="14" x="3" y="3" rx="2" />
30+
@for (thumb of thumbs; track thumb; let index = $index) {
31+
<svg:path class="thumbnail-line" [attr.d]="thumb" [style.--gallery-thumbnails-delay]="index + 1" />
32+
}
33+
</svg>
34+
`,
35+
styles: `
36+
:host {
37+
display: inline-block;
38+
}
39+
.gallery-thumbnails-icon {
40+
overflow: visible;
41+
}
42+
43+
.thumbnail-line {
44+
opacity: 1;
45+
transition: opacity 0.2s ease;
46+
}
47+
48+
.gallery-thumbnails-icon.animate .thumbnail-line {
49+
opacity: 0;
50+
animation: fadeInSequence 0.3s ease forwards;
51+
animation-delay: calc(0.1s + var(--gallery-thumbnails-delay) * 0.09s);
52+
}
53+
54+
@keyframes fadeInSequence {
55+
0% {
56+
opacity: 0;
57+
}
58+
100% {
59+
opacity: 1;
60+
}
61+
}
62+
`,
63+
host: {
64+
'[class]': 'class()',
65+
'aria-label': 'gallery-thumbnails',
66+
role: 'img',
67+
'(mouseenter)': 'handleMouseEnter()',
68+
'(focusin)': 'handleMouseEnter()',
69+
'(touchstart)': 'handleMouseEnter()',
70+
},
71+
changeDetection: ChangeDetectionStrategy.OnPush,
72+
})
73+
export class GalleryThumbnailsIcon {
74+
#options = inject(ANIMATED_ICONS_CONFIG);
75+
76+
color = input(this.#options?.color ?? 'currentColor');
77+
size = input(this.#options?.size ?? 24, { transform: numberAttribute });
78+
strokeWidth = input(this.#options?.strokeWidth ?? 2, { transform: numberAttribute });
79+
class = input('');
80+
animate = input(false, { transform: booleanAttribute });
81+
82+
protected isAnimating = linkedSignal(() => this.animate());
83+
84+
#timer: ReturnType<typeof setTimeout> | null = null;
85+
86+
handleMouseEnter(forced = false) {
87+
if (forced || (!this.animate() && !this.isAnimating())) {
88+
this.isAnimating.set(true);
89+
this.#timer = setTimeout(() => this.isAnimating.set(false), 850);
90+
}
91+
}
92+
93+
protected thumbs = ['M4 21h1', 'M9 21h1', 'M14 21h1', 'M19 21h1'];
94+
95+
constructor() {
96+
effect(() => {
97+
const animate = this.animate();
98+
if (animate) {
99+
this.handleMouseEnter(true);
100+
} else {
101+
if (this.#timer) {
102+
clearTimeout(this.#timer);
103+
this.#timer = null;
104+
}
105+
}
106+
});
107+
}
108+
}

packages/animated-icons/src/icons/gallery-vertical-end.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ import { ANIMATED_ICONS_CONFIG } from '../tokens/provider';
2626
stroke-linecap="round"
2727
stroke-linejoin="round"
2828
>
29-
<svg:path d="M7 2h10" custom="1" />
30-
<svg:path d="M5 6h14" custom="2" />
29+
<svg:path class="path1" d="M7 2h10" />
30+
<svg:path class="path2" d="M5 6h14" />
3131
<svg:rect width="18" height="12" x="3" y="10" rx="2" />
3232
</svg>
3333
`,
3434
styles: `
3535
:host {
3636
display: inline-block;
3737
}
38-
path {
38+
.gallery-vertical-end-icon path {
3939
transition:
4040
transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
4141
opacity 0.3s ease;
@@ -44,11 +44,11 @@ import { ANIMATED_ICONS_CONFIG } from '../tokens/provider';
4444
transform: translateY(0);
4545
}
4646
47-
path[custom='1'].animate {
47+
.gallery-vertical-end-icon.animate .path1 {
4848
animation: disappearThenAppear1 0.6s forwards;
4949
}
5050
51-
path[custom='2'].animate {
51+
.gallery-vertical-end-icon.animate .path2 {
5252
animation: disappearThenAppear2 0.6s forwards;
5353
}
5454
@@ -116,7 +116,7 @@ export class GalleryVerticalEndIcon {
116116
handleMouseEnter(forced = false) {
117117
if (forced || (!this.animate() && !this.isAnimating())) {
118118
this.isAnimating.set(true);
119-
this.#timer = setTimeout(() => this.isAnimating.set(false), 1400);
119+
this.#timer = setTimeout(() => this.isAnimating.set(false), 600);
120120
}
121121
}
122122

packages/animated-icons/src/icons/gallery-vertical.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class GalleryVerticalIcon {
108108
handleMouseEnter(forced = false) {
109109
if (forced || (!this.animate() && !this.isAnimating())) {
110110
this.isAnimating.set(true);
111-
this.#timer = setTimeout(() => this.isAnimating.set(false), 1400);
111+
this.#timer = setTimeout(() => this.isAnimating.set(false), 800);
112112
}
113113
}
114114

packages/animated-icons/src/icons/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export * from './folder-up';
240240
export * from './frame';
241241
export * from './gallery-horizontal-end';
242242
export * from './gallery-horizontal';
243+
export * from './gallery-thumbnails';
243244
export * from './gallery-vertical-end';
244245
export * from './gallery-vertical';
245246
export * from './gauge';

0 commit comments

Comments
 (0)