|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | class Avo::Index::GridCoverEmptyStateComponent < Avo::BaseComponent |
| 4 | + ICONS = %w[ |
| 5 | + tabler/outline/star |
| 6 | + tabler/outline/bolt |
| 7 | + tabler/outline/clock |
| 8 | + tabler/outline/heart |
| 9 | + tabler/outline/leaf |
| 10 | + tabler/outline/sparkles |
| 11 | + tabler/outline/rocket |
| 12 | + tabler/outline/diamond |
| 13 | + ].freeze |
| 14 | + |
| 15 | + # Per-icon animation timing and color intensity (stable across all layouts) |
| 16 | + ICON_META = [ |
| 17 | + {duration: 3.8, delay: 0.0, intensity: 15}, |
| 18 | + {duration: 4.2, delay: 0.4, intensity: 18}, |
| 19 | + {duration: 3.5, delay: 0.8, intensity: 13}, |
| 20 | + {duration: 4.6, delay: 1.2, intensity: 20}, |
| 21 | + {duration: 3.2, delay: 1.6, intensity: 16}, |
| 22 | + {duration: 4.8, delay: 2.0, intensity: 14}, |
| 23 | + {duration: 3.6, delay: 2.4, intensity: 19}, |
| 24 | + {duration: 4.4, delay: 2.8, intensity: 17} |
| 25 | + ].freeze |
| 26 | + |
| 27 | + # 5 preset spatial layouts — each is an array of 8 position+rotation hashes. |
| 28 | + # v_edge: "top"|"bottom", h_edge: CSS logical "inset-inline-start"|"inset-inline-end" |
| 29 | + # v_px / h_px: distance in px from that edge. rotation: degrees. |
| 30 | + LAYOUTS = [ |
| 31 | + # Layout 1 — scattered, original feel |
| 32 | + [ |
| 33 | + {v_edge: "top", v_px: 28, h_edge: "inset-inline-start", h_px: 28, rotation: 12}, |
| 34 | + {v_edge: "top", v_px: 32, h_edge: "inset-inline-end", h_px: 32, rotation: -12}, |
| 35 | + {v_edge: "top", v_px: 72, h_edge: "inset-inline-start", h_px: 24, rotation: 0}, |
| 36 | + {v_edge: "bottom", v_px: 28, h_edge: "inset-inline-start", h_px: 44, rotation: 6}, |
| 37 | + {v_edge: "top", v_px: 40, h_edge: "inset-inline-start", h_px: 72, rotation: -6}, |
| 38 | + {v_edge: "bottom", v_px: 32, h_edge: "inset-inline-end", h_px: 32, rotation: 12}, |
| 39 | + {v_edge: "top", v_px: 28, h_edge: "inset-inline-end", h_px: 52, rotation: -6}, |
| 40 | + {v_edge: "bottom", v_px: 28, h_edge: "inset-inline-end", h_px: 60, rotation: 6} |
| 41 | + ], |
| 42 | + # Layout 2 — corners and mid-edges |
| 43 | + [ |
| 44 | + {v_edge: "top", v_px: 24, h_edge: "inset-inline-start", h_px: 20, rotation: -8}, |
| 45 | + {v_edge: "top", v_px: 24, h_edge: "inset-inline-end", h_px: 20, rotation: 8}, |
| 46 | + {v_edge: "bottom", v_px: 24, h_edge: "inset-inline-start", h_px: 20, rotation: 8}, |
| 47 | + {v_edge: "bottom", v_px: 24, h_edge: "inset-inline-end", h_px: 20, rotation: -8}, |
| 48 | + {v_edge: "top", v_px: 24, h_edge: "inset-inline-start", h_px: 68, rotation: 0}, |
| 49 | + {v_edge: "bottom", v_px: 24, h_edge: "inset-inline-start", h_px: 68, rotation: 0}, |
| 50 | + {v_edge: "top", v_px: 60, h_edge: "inset-inline-start", h_px: 20, rotation: 12}, |
| 51 | + {v_edge: "top", v_px: 60, h_edge: "inset-inline-end", h_px: 20, rotation: -12} |
| 52 | + ], |
| 53 | + # Layout 3 — diagonal scatter |
| 54 | + [ |
| 55 | + {v_edge: "top", v_px: 24, h_edge: "inset-inline-start", h_px: 36, rotation: 15}, |
| 56 | + {v_edge: "top", v_px: 48, h_edge: "inset-inline-end", h_px: 24, rotation: -10}, |
| 57 | + {v_edge: "top", v_px: 66, h_edge: "inset-inline-start", h_px: 28, rotation: 5}, |
| 58 | + {v_edge: "bottom", v_px: 66, h_edge: "inset-inline-end", h_px: 28, rotation: -5}, |
| 59 | + {v_edge: "bottom", v_px: 48, h_edge: "inset-inline-start", h_px: 24, rotation: 10}, |
| 60 | + {v_edge: "bottom", v_px: 24, h_edge: "inset-inline-end", h_px: 36, rotation: -15}, |
| 61 | + {v_edge: "top", v_px: 36, h_edge: "inset-inline-start", h_px: 72, rotation: 8}, |
| 62 | + {v_edge: "bottom", v_px: 36, h_edge: "inset-inline-end", h_px: 60, rotation: -8} |
| 63 | + ], |
| 64 | + # Layout 4 — even frame |
| 65 | + [ |
| 66 | + {v_edge: "top", v_px: 24, h_edge: "inset-inline-start", h_px: 44, rotation: 12}, |
| 67 | + {v_edge: "top", v_px: 24, h_edge: "inset-inline-end", h_px: 44, rotation: -12}, |
| 68 | + {v_edge: "top", v_px: 60, h_edge: "inset-inline-start", h_px: 20, rotation: 0}, |
| 69 | + {v_edge: "top", v_px: 60, h_edge: "inset-inline-end", h_px: 20, rotation: 0}, |
| 70 | + {v_edge: "bottom", v_px: 60, h_edge: "inset-inline-start", h_px: 20, rotation: 6}, |
| 71 | + {v_edge: "bottom", v_px: 60, h_edge: "inset-inline-end", h_px: 20, rotation: -6}, |
| 72 | + {v_edge: "bottom", v_px: 24, h_edge: "inset-inline-start", h_px: 44, rotation: -12}, |
| 73 | + {v_edge: "bottom", v_px: 24, h_edge: "inset-inline-end", h_px: 44, rotation: 12} |
| 74 | + ], |
| 75 | + # Layout 5 — asymmetric cluster |
| 76 | + [ |
| 77 | + {v_edge: "top", v_px: 24, h_edge: "inset-inline-start", h_px: 20, rotation: 8}, |
| 78 | + {v_edge: "top", v_px: 40, h_edge: "inset-inline-start", h_px: 52, rotation: -8}, |
| 79 | + {v_edge: "top", v_px: 24, h_edge: "inset-inline-end", h_px: 36, rotation: 12}, |
| 80 | + {v_edge: "top", v_px: 66, h_edge: "inset-inline-end", h_px: 20, rotation: -5}, |
| 81 | + {v_edge: "bottom", v_px: 24, h_edge: "inset-inline-start", h_px: 36, rotation: -12}, |
| 82 | + {v_edge: "bottom", v_px: 52, h_edge: "inset-inline-start", h_px: 20, rotation: 8}, |
| 83 | + {v_edge: "bottom", v_px: 24, h_edge: "inset-inline-end", h_px: 20, rotation: 10}, |
| 84 | + {v_edge: "bottom", v_px: 40, h_edge: "inset-inline-end", h_px: 52, rotation: -10} |
| 85 | + ] |
| 86 | + ].freeze |
| 87 | + |
| 88 | + def icon_items |
| 89 | + layout = LAYOUTS.sample |
| 90 | + ICONS.each_with_index.map do |path, i| |
| 91 | + ICON_META[i].merge(layout[i]).merge(path: path) |
| 92 | + end |
| 93 | + end |
4 | 94 | end |
0 commit comments