Skip to content

Commit b797732

Browse files
committed
feature #1887 [Demo] Infinite Scroll 2/2 (smnandre)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Demo] Infinite Scroll 2/2 | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Issues | Fix | License | MIT This took some time but.... what a beautiful collection of TShirts 😸 <img width="1206" alt="Capture d’écran 2024-06-04 à 20 40 14" src="https://github.com/symfony/ux/assets/1359581/5dea5970-d468-4506-ab96-7bf63b17428a"> Commits ------- a23123c [Demo] Infinite Scroll 2/2
2 parents 2173559 + a23123c commit b797732

25 files changed

+687
-141
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Controller } from '@hotwired/stimulus';
2+
3+
/* stimulusFetch: 'lazy' */
4+
export default class extends Controller {
5+
static targets = ['loader'];
6+
7+
loaderTargetConnected(element) {
8+
this.observer ??= new IntersectionObserver((entries) => {
9+
entries.forEach((entry) => {
10+
if (entry.isIntersecting) {
11+
entry.target.dispatchEvent(new CustomEvent('appear', {detail: {entry}}));
12+
}
13+
});
14+
});
15+
this.observer?.observe(element);
16+
}
17+
18+
loaderTargetDisconnected(element) {
19+
this.observer?.unobserve(element);
20+
}
21+
}
Loading
Loading

ux.symfony.com/assets/styles/app/_typography.scss

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ h3, a.component-title {
2020
font-size: 28px;
2121
line-height: 32px;
2222
letter-spacing: -1px;
23-
color: #0A0A0A;
2423
text-decoration: none;
24+
color: var(--bs-body-color);
2525
}
2626

2727
h4.ubuntu {
@@ -47,6 +47,26 @@ h4.ubuntu {
4747
}
4848
}
4949

50+
.code-description :is(h2, h3) {
51+
font-family: var(--font-family-title);
52+
}
53+
.code-description h2 {
54+
font-size: 2.5em;
55+
margin-block-end: 1.5rem;
56+
}
57+
.code-description h3 {
58+
font-size: 1.65em;
59+
font-weight: 500;
60+
margin-block-end: 1.125rem;
61+
margin-top: 2.25rem;
62+
}
63+
64+
.code-description:hover strong {
65+
background: var(--bs-body-color);
66+
color: var(--bs-body-bg);
67+
}
68+
69+
5070
.ubuntu-header {
5171
font-family: var(--font-family-title);
5272
font-weight: 700;

ux.symfony.com/assets/styles/components/_Browser.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
overflow-y: scroll;
7878
scrollbar-width: thin;
7979
}
80+
@media screen and (max-width: 768px) {
81+
.Browser__viewport {
82+
aspect-ratio: 1/2;
83+
}
84+
}
8085

8186
.Browser__dot {
8287
height: .75rem;

ux.symfony.com/assets/styles/components/_DemoContainer.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@
2424
}
2525
.demo-introduction code {
2626
font-size: 0.95em;
27+
letter-spacing: -.01em;
2728
}

ux.symfony.com/assets/styles/components/_ProductGrid.scss

Lines changed: 118 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
.ProductGrid {
66
--item-ratio: 1;
77
--grid-columns: 5;
8+
--color: rgba(252 240 240 / 0.9);
9+
--bg-color: #161719;
810
}
911
@media screen and (max-width: 768px) {
1012
.ProductGrid {
@@ -16,20 +18,34 @@
1618
padding: min(4%, 1.5rem);
1719
}
1820

19-
.ProductGrid_page {
21+
.ProductGrid_header {
2022
display: grid;
21-
grid-template-columns: repeat(var(--grid-columns), 1fr);
23+
position: sticky;
2224
gap: 1rem;
25+
padding: 1rem;
26+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
27+
border-bottom: 1px solid #070707;
28+
top: 0;
29+
background: #191C1F;
30+
z-index: 5;
31+
backdrop-filter: blur(5px);
32+
}
33+
34+
.ProductGrid_items,
35+
.ProductGrid_page {
36+
display: grid;
37+
grid-template-columns: repeat(auto-fit, minmax(min(35vw, 180px), 1fr));
38+
gap: min(1rem, 4vw);
2339
}
2440

2541
.ProductGrid_item {
2642
aspect-ratio: var(--item-ratio, 1/1);
2743
padding: 1rem;
44+
gap: 1rem;
2845
display: grid;
29-
background: #f0f8ff87;
30-
background: rgba(2, 12, 21, 0.98);
31-
grid-template-rows: 4fr 1fr;
32-
border-radius: 4px;
46+
background: #0000002b;
47+
background: var(--bg-color);
48+
border-radius: .5rem;
3349
}
3450

3551
[data-bs-theme="dark"] .ProductGrid_item {
@@ -42,27 +58,113 @@
4258
place-content: center;
4359
position: relative;
4460
justify-items: center;
61+
overflow: hidden;
4562
}
4663

47-
.ProductGrid_item svg {
48-
height: 100%;
49-
max-width: 100%;
50-
width: auto;
64+
.ProductGrid_media svg {
65+
height: auto;
66+
width: 100%;
5167
fill: var(--color);
52-
filter: drop-shadow(2px 2px 0px #fff) drop-shadow(-2px -2px 0px #461279);
68+
color: var(--color);
69+
min-width: 160px;
5370
}
5471

55-
.ProductGrid_item span {
72+
.ProductGrid_media span {
5673
top: 40%;
5774
font-size: 2rem;
5875
position: absolute;
5976
}
6077

61-
.ProductGrid_item data {
62-
text-align: center;
63-
font-size: small;
78+
.ProductGrid_price {
79+
font-size: .75rem;
6480
font-family: var(--font-family-code);
65-
color: black;
81+
color: var(--color);
82+
background: rgba(0, 0, 0, 0.2);
83+
display: inline-flex;
84+
margin-inline: auto;
85+
min-width: 48%;
86+
border-radius: 0.8rem;
87+
align-items: center;
88+
justify-content: center;
89+
padding: 0 1rem;
90+
height: 1.5rem;
91+
}
92+
.ProductGrid_price::before {
93+
content: attr(data-currency);
94+
font-weight: 300;
95+
padding-inline-end: 0.25em;
96+
opacity: .5;
97+
}
98+
.ProductGrid_price small {
99+
font-weight: 300;
100+
opacity: .9;
101+
}
66102

103+
.ProductGrid_more {
104+
display: grid;
105+
place-content: center;
106+
background: var(--bg-color);
107+
background-blend-mode: color-burn;
67108
color: var(--color);
109+
font-size: 1rem;
110+
text-transform: uppercase;
111+
padding: .75rem 2.5rem;
112+
border-radius: 2rem;
113+
font-weight: 300;
114+
font-stretch: semi-condensed;
115+
opacity: .75;
116+
transition: all 150ms;
117+
border: 2px solid #0009;
118+
}
119+
.ProductGrid_more:hover {
120+
opacity: 1;
121+
border: 2px solid #000e;
122+
}
123+
124+
.ProductGrid_item:has(.ProductGrid_loader) .ProductGrid_media {
125+
filter: brightness(0);
126+
opacity: 0.2;
127+
}
128+
.ProductGrid_loader {
129+
position: relative;
130+
height: 4px;
131+
width: 100%;
132+
border-radius: 1rem;
133+
overflow: hidden;
134+
content: "";
135+
}
136+
.ProductGrid_loader:after{
137+
content: '';
138+
position: absolute;
139+
left:0;
140+
top:0;
141+
height: 100%;
142+
width: 100%;
143+
background: var(--color);
144+
--duration: 1s;
145+
animation: productloading linear forwards;
146+
animation-delay: calc(var(--delay) * 0.9 * var(--duration));
147+
animation-duration: var(--duration);
148+
transform: translateX(-100%);
149+
}
150+
@keyframes productloading {
151+
100% { transform: translateX(0) }
152+
}
153+
@keyframes productloaded {
154+
0% {
155+
opacity: 0.2;
156+
filter: brightness(0)
157+
}
158+
100% {
159+
opacity: 1;
160+
filter: brightness(1)
161+
}
162+
}
163+
.ProductGrid_media.loaded span,
164+
.ProductGrid_media.loaded svg {
165+
opacity: .2;
166+
filter: brightness(0);
167+
--duration: 1000ms;
168+
animation: productloaded var(--duration) linear forwards;
169+
animation-delay: calc(var(--delay) * 0.9 * var(--duration));
68170
}

ux.symfony.com/assets/styles/layouts/_container.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
.container {
22
margin-inline: auto;
3-
max-width: 1200px;
3+
max-width: 1240px;
44
}
55
.container--fluid {
66
max-width: 100%;
77
}
88
.container--large {
99

10+
}
11+
.container-xxl {
12+
max-width: 1400px;
1013
}
1114
.container--xlarge {
1215

ux.symfony.com/assets/styles/layouts/_section.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ section:not([class]) {
2121
line-height: 1.2;
2222
color: var(--heading-color, var(--color-primary));
2323
}
24+
25+
26+
.section--alt {
27+
background: rgb(var(--bs-body-color-rgb), .025);
28+
border-block: 1px dotted var(--bs-primary-border-subtle);
29+
}

ux.symfony.com/src/Controller/Demo/LiveComponentDemoController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ public function infiniteScroll(LiveDemoRepository $liveDemoRepository): Response
124124
]);
125125
}
126126

127+
#[Route('/infinite-scroll-2', name: 'app_demo_live_component_infinite_scroll_2')]
128+
public function infiniteScroll2(LiveDemoRepository $liveDemoRepository): Response
129+
{
130+
return $this->render('demos/live_component/infinite_scroll_2.html.twig', parameters: [
131+
'demo' => $liveDemoRepository->find('infinite-scroll-2'),
132+
]);
133+
}
134+
127135
#[Route('/product-form', name: 'app_demo_live_component_product_form')]
128136
public function productForm(LiveDemoRepository $liveDemoRepository): Response
129137
{

ux.symfony.com/src/Service/EmojiCollection.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ private function loadEmojis(): array
5252
'🦦',
5353
'🦨',
5454
'🦘',
55-
'🦡',
5655
'🐾',
57-
'🦃',
58-
'🐔',
5956
'🐓',
6057
'🐣',
6158
'🐤',
@@ -68,11 +65,9 @@ private function loadEmojis(): array
6865
'🦢',
6966
'🦉',
7067
'🦤',
71-
'🪶',
7268
'🦩',
7369
'🦚',
7470
'🦜',
75-
'🪽',
7671
'🐦‍⬛',
7772
'🪿',
7873
'🐸',
@@ -88,13 +83,8 @@ private function loadEmojis(): array
8883
'🐋',
8984
'🐬',
9085
'🦭',
91-
'🐟',
92-
'🐠',
9386
'🐡',
94-
'🦈',
9587
'🐙',
96-
'🐚',
97-
'🪸',
9888
'🪼',
9989
'🐌',
10090
'🦋',
@@ -103,22 +93,11 @@ private function loadEmojis(): array
10393
'🐝',
10494
'🪲',
10595
'🐞',
106-
'🦗',
107-
'🪳',
108-
'🕷️',
109-
'🕸️',
110-
'🦂',
111-
'🦟',
112-
'🪰',
113-
'🪱',
114-
'🦠',
11596
'💐',
11697
'🌸',
117-
'💮',
11898
'🪷',
11999
'🏵️',
120100
'🌹',
121-
'🥀',
122101
'🌺',
123102
'🌻',
124103
'🌼',
@@ -137,8 +116,6 @@ private function loadEmojis(): array
137116
'🍁',
138117
'🍂',
139118
'🍃',
140-
'🪹',
141-
'🪺',
142119
'🍄',
143120
'🍇',
144121
'🍈',
@@ -160,21 +137,14 @@ private function loadEmojis(): array
160137
'🫒',
161138
'🥥',
162139
'🥑',
163-
'🍆',
164-
'🥔',
165140
'🥕',
166141
'🌽',
167142
'🌶️',
168143
'🫑',
169144
'🥒',
170145
'🥬',
171146
'🥦',
172-
'🧄',
173-
'🧅',
174147
'🍄',
175-
'🍠',
176-
'🥜',
177-
'🌰',
178148
];
179149
}
180150
}

0 commit comments

Comments
 (0)