Spaces:
Sleeping
Sleeping
deploy at 2024-09-16 13:21:26.356100
Browse files- config.ini +6 -0
- fasthtml_hf/__pycache__/__init__.cpython-312.pyc +0 -0
- fasthtml_hf/__pycache__/backup.cpython-312.pyc +0 -0
- fasthtml_hf/__pycache__/deploy.cpython-312.pyc +0 -0
- main.py +19 -7
- public/app.css +26 -13
config.ini
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[DEFAULT]
|
2 |
+
dataset_id = space-backup
|
3 |
+
db_dir = data
|
4 |
+
private_backup = True
|
5 |
+
interval = 15
|
6 |
+
|
fasthtml_hf/__pycache__/__init__.cpython-312.pyc
ADDED
Binary file (235 Bytes). View file
|
|
fasthtml_hf/__pycache__/backup.cpython-312.pyc
ADDED
Binary file (3.28 kB). View file
|
|
fasthtml_hf/__pycache__/deploy.cpython-312.pyc
ADDED
Binary file (3.39 kB). View file
|
|
main.py
CHANGED
@@ -4,7 +4,7 @@ from svgs import fasthtml_logo
|
|
4 |
from fasthtml_hf import setup_hf_backup
|
5 |
|
6 |
app,rt = fast_app(
|
7 |
-
|
8 |
id=int,
|
9 |
title=str,
|
10 |
done=bool,
|
@@ -25,12 +25,14 @@ function game() {
|
|
25 |
cds.sort((a, b) => 0.5 - Math.random());
|
26 |
|
27 |
return {
|
|
|
28 |
cheats: 3,
|
29 |
cards: cds,
|
30 |
get flippedCards() {
|
31 |
return this.cards.filter(card => card.flipped);
|
32 |
},
|
33 |
flipCard(card) {
|
|
|
34 |
if( card.cleared ) { return; }
|
35 |
if( this.flippedCards.length <= 1 ) { card.flipped = ! card.flipped; }
|
36 |
|
@@ -61,7 +63,8 @@ function game() {
|
|
61 |
c.flipped = false;
|
62 |
c.cleared = false;
|
63 |
});
|
64 |
-
this.cheats
|
|
|
65 |
setTimeout(() => {
|
66 |
this.cards.sort((a, b) => 0.5 - Math.random());
|
67 |
}, 500);
|
@@ -76,7 +79,7 @@ function game() {
|
|
76 |
this.cards.forEach(c => {
|
77 |
c.flipped = false;
|
78 |
});
|
79 |
-
},
|
80 |
}
|
81 |
},
|
82 |
};
|
@@ -129,9 +132,14 @@ def get(): return Title('Card Memory Game in FastHTML'), Div(
|
|
129 |
cls='grid grid-cols-6 gap-4 w-[944px]'
|
130 |
),
|
131 |
),
|
132 |
-
cls='flex items-center justify-center
|
133 |
),
|
134 |
Div(
|
|
|
|
|
|
|
|
|
|
|
135 |
Div(
|
136 |
A(
|
137 |
'Restart Game',
|
@@ -145,16 +153,20 @@ def get(): return Title('Card Memory Game in FastHTML'), Div(
|
|
145 |
),
|
146 |
cls='flex items-center justify-center gap-4'
|
147 |
),
|
148 |
-
|
149 |
-
'
|
150 |
cls='mt-6 flex items-center justify-center gap-4'
|
151 |
),
|
|
|
|
|
|
|
|
|
152 |
),
|
153 |
cls='mb-20',
|
154 |
x_data='game()',
|
155 |
),
|
156 |
Footer(
|
157 |
-
A('
|
158 |
cls='bg-gray-800 text-white text-center py-8'
|
159 |
),
|
160 |
cls='bg-gray-100 text-gray-800'
|
|
|
4 |
from fasthtml_hf import setup_hf_backup
|
5 |
|
6 |
app,rt = fast_app(
|
7 |
+
live=True,
|
8 |
id=int,
|
9 |
title=str,
|
10 |
done=bool,
|
|
|
25 |
cds.sort((a, b) => 0.5 - Math.random());
|
26 |
|
27 |
return {
|
28 |
+
card_clicks: 0,
|
29 |
cheats: 3,
|
30 |
cards: cds,
|
31 |
get flippedCards() {
|
32 |
return this.cards.filter(card => card.flipped);
|
33 |
},
|
34 |
flipCard(card) {
|
35 |
+
this.card_clicks += 1;
|
36 |
if( card.cleared ) { return; }
|
37 |
if( this.flippedCards.length <= 1 ) { card.flipped = ! card.flipped; }
|
38 |
|
|
|
63 |
c.flipped = false;
|
64 |
c.cleared = false;
|
65 |
});
|
66 |
+
this.cheats = 3;
|
67 |
+
this.card_clicks = 0;
|
68 |
setTimeout(() => {
|
69 |
this.cards.sort((a, b) => 0.5 - Math.random());
|
70 |
}, 500);
|
|
|
79 |
this.cards.forEach(c => {
|
80 |
c.flipped = false;
|
81 |
});
|
82 |
+
}, 750);
|
83 |
}
|
84 |
},
|
85 |
};
|
|
|
132 |
cls='grid grid-cols-6 gap-4 w-[944px]'
|
133 |
),
|
134 |
),
|
135 |
+
cls='flex items-center justify-center mt-10'
|
136 |
),
|
137 |
Div(
|
138 |
+
Div(
|
139 |
+
Div(),
|
140 |
+
cls='flex items-center justify-center my-5 font-bold',
|
141 |
+
**{"x-text": "'Card clicks: ' + card_clicks"},
|
142 |
+
),
|
143 |
Div(
|
144 |
A(
|
145 |
'Restart Game',
|
|
|
153 |
),
|
154 |
cls='flex items-center justify-center gap-4'
|
155 |
),
|
156 |
+
Div(
|
157 |
+
'Reveal all the matching pairs of cards in the fewest clicks possible.',
|
158 |
cls='mt-6 flex items-center justify-center gap-4'
|
159 |
),
|
160 |
+
Div(
|
161 |
+
'Click the \'Cheat Mode\' button to reveal all tiles, but you only have three per game so use wisely!',
|
162 |
+
cls='flex items-center justify-center gap-4'
|
163 |
+
),
|
164 |
),
|
165 |
cls='mb-20',
|
166 |
x_data='game()',
|
167 |
),
|
168 |
Footer(
|
169 |
+
A('Created by David Gwyer - Follow me on X', href="https://x.com/dgwyer", _target="_blank", cls="drop-shadow-lg text-lg"),
|
170 |
cls='bg-gray-800 text-white text-center py-8'
|
171 |
),
|
172 |
cls='bg-gray-100 text-gray-800'
|
public/app.css
CHANGED
@@ -526,24 +526,30 @@ video {
|
|
526 |
margin-bottom: 5rem;
|
527 |
}
|
528 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
.mb-4 {
|
530 |
margin-bottom: 1rem;
|
531 |
}
|
532 |
|
533 |
-
.mt-
|
534 |
-
margin-top:
|
535 |
}
|
536 |
|
537 |
.mb-20 {
|
538 |
margin-bottom: 5rem;
|
539 |
}
|
540 |
|
541 |
-
.mt-
|
542 |
-
margin-top:
|
543 |
-
}
|
544 |
-
|
545 |
-
.mt-6 {
|
546 |
-
margin-top: 1.5rem;
|
547 |
}
|
548 |
|
549 |
.flex {
|
@@ -566,6 +572,18 @@ video {
|
|
566 |
width: 944px;
|
567 |
}
|
568 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
569 |
.transform {
|
570 |
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
571 |
}
|
@@ -629,11 +647,6 @@ video {
|
|
629 |
padding-bottom: 0.75rem;
|
630 |
}
|
631 |
|
632 |
-
.py-6 {
|
633 |
-
padding-top: 1.5rem;
|
634 |
-
padding-bottom: 1.5rem;
|
635 |
-
}
|
636 |
-
|
637 |
.py-8 {
|
638 |
padding-top: 2rem;
|
639 |
padding-bottom: 2rem;
|
|
|
526 |
margin-bottom: 5rem;
|
527 |
}
|
528 |
|
529 |
+
.my-10 {
|
530 |
+
margin-top: 2.5rem;
|
531 |
+
margin-bottom: 2.5rem;
|
532 |
+
}
|
533 |
+
|
534 |
+
.my-5 {
|
535 |
+
margin-top: 1.25rem;
|
536 |
+
margin-bottom: 1.25rem;
|
537 |
+
}
|
538 |
+
|
539 |
.mb-4 {
|
540 |
margin-bottom: 1rem;
|
541 |
}
|
542 |
|
543 |
+
.mt-6 {
|
544 |
+
margin-top: 1.5rem;
|
545 |
}
|
546 |
|
547 |
.mb-20 {
|
548 |
margin-bottom: 5rem;
|
549 |
}
|
550 |
|
551 |
+
.mt-10 {
|
552 |
+
margin-top: 2.5rem;
|
|
|
|
|
|
|
|
|
553 |
}
|
554 |
|
555 |
.flex {
|
|
|
572 |
width: 944px;
|
573 |
}
|
574 |
|
575 |
+
.w-96 {
|
576 |
+
width: 24rem;
|
577 |
+
}
|
578 |
+
|
579 |
+
.w-\[500px\] {
|
580 |
+
width: 500px;
|
581 |
+
}
|
582 |
+
|
583 |
+
.w-\[400px\] {
|
584 |
+
width: 400px;
|
585 |
+
}
|
586 |
+
|
587 |
.transform {
|
588 |
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
589 |
}
|
|
|
647 |
padding-bottom: 0.75rem;
|
648 |
}
|
649 |
|
|
|
|
|
|
|
|
|
|
|
650 |
.py-8 {
|
651 |
padding-top: 2rem;
|
652 |
padding-bottom: 2rem;
|