aephiday commited on
Commit
320456a
·
verified ·
1 Parent(s): 852d9bb

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +119 -2
app.R CHANGED
@@ -1,4 +1,11 @@
1
  library(shiny)
 
 
 
 
 
 
 
2
 
3
  max_hint <- 3
4
  size <- 200
@@ -246,7 +253,118 @@ solve_puzzle_bfs <- function(initial_puzzle) {
246
 
247
  # UI
248
  ui <- fluidPage(
249
- titlePanel(h1("Puzzle8", style='font-weight: bold;')),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
 
251
  fluidRow(
252
  column(5,
@@ -438,7 +556,6 @@ server <- function(input, output, session) {
438
  # Tentukan style berdasarkan apakah ini adalah hint
439
  is_hint <- !is.null(game_state$hint_position) && game_state$hint_position == tile_index
440
  hint_style <- if(is_hint) "box-shadow: 0 0 10px 3px orange; border: 3px solid orange;" else ""
441
- size <- 200
442
 
443
  if(value == 0) {
444
  # Kotak kosong
 
1
  library(shiny)
2
+ # library(shinyjs)
3
+ # library(shinydashboard)
4
+ # library(future)
5
+ # library(promises)
6
+
7
+ # Enable future support
8
+ # plan(multisession)
9
 
10
  max_hint <- 3
11
  size <- 200
 
253
 
254
  # UI
255
  ui <- fluidPage(
256
+ # CSS untuk desain responsif
257
+ tags$head(
258
+ tags$style(HTML("
259
+ /* Base styles */
260
+ .puzzle-tile {
261
+ border: 2px solid #333;
262
+ background-color: #4CAF50;
263
+ color: white;
264
+ font-weight: bold;
265
+ display: flex;
266
+ align-items: center;
267
+ justify-content: center;
268
+ cursor: pointer;
269
+ transition: all 0.2s ease;
270
+ }
271
+
272
+ .puzzle-tile:hover {
273
+ opacity: 0.9;
274
+ transform: scale(0.95);
275
+ }
276
+
277
+ .puzzle-tile:disabled {
278
+ cursor: not-allowed;
279
+ }
280
+
281
+ .empty-tile {
282
+ background-color: #f0f0f0;
283
+ border: 2px solid #333;
284
+ }
285
+
286
+ .hint-highlight {
287
+ box-shadow: 0 0 15px 5px orange;
288
+ border: 3px solid orange !important;
289
+ z-index: 10;
290
+ }
291
+
292
+ /* Responsive grid */
293
+ .puzzle-grid {
294
+ display: grid;
295
+ grid-template-columns: repeat(3, 1fr);
296
+ grid-gap: 8px;
297
+ max-width: 500px;
298
+ margin: 0 auto;
299
+ padding: 10px;
300
+ }
301
+
302
+ .puzzle-cell {
303
+ aspect-ratio: 1;
304
+ width: 100%;
305
+ }
306
+
307
+ /* Responsive button sizes */
308
+ .action-button {
309
+ width: 100%;
310
+ padding: 8px 12px;
311
+ font-size: clamp(12px, 2vw, 16px);
312
+ margin-bottom: 5px;
313
+ }
314
+
315
+ /* Stats table */
316
+ .stats-table {
317
+ width: 100%;
318
+ margin: 15px auto;
319
+ text-align: center;
320
+ font-size: clamp(14px, 2vw, 18px);
321
+ }
322
+
323
+ .stats-table td {
324
+ padding: 5px;
325
+ }
326
+
327
+ /* Large screens */
328
+ @media (min-width: 992px) {
329
+ .puzzle-grid {
330
+ max-width: 400px;
331
+ }
332
+ }
333
+
334
+ /* Medium screens */
335
+ @media (min-width: 768px) and (max-width: 991px) {
336
+ .puzzle-grid {
337
+ max-width: 350px;
338
+ }
339
+ }
340
+
341
+ /* Small screens */
342
+ @media (max-width: 767px) {
343
+ .puzzle-grid {
344
+ max-width: 90vw;
345
+ grid-gap: 5px;
346
+ }
347
+
348
+ .stats-table {
349
+ font-size: clamp(12px, 3vw, 16px);
350
+ }
351
+ }
352
+
353
+ /* Very small screens */
354
+ @media (max-width: 480px) {
355
+ .puzzle-grid {
356
+ max-width: 95vw;
357
+ grid-gap: 3px;
358
+ }
359
+
360
+ .action-button {
361
+ padding: 6px 8px;
362
+ font-size: clamp(10px, 2.5vw, 14px);
363
+ }
364
+ }
365
+ "))
366
+ ),
367
+ titlePanel(h1("Puzzle8", style='font-weight: bold;'), windowTitle = "Puzzle8"),
368
 
369
  fluidRow(
370
  column(5,
 
556
  # Tentukan style berdasarkan apakah ini adalah hint
557
  is_hint <- !is.null(game_state$hint_position) && game_state$hint_position == tile_index
558
  hint_style <- if(is_hint) "box-shadow: 0 0 10px 3px orange; border: 3px solid orange;" else ""
 
559
 
560
  if(value == 0) {
561
  # Kotak kosong