frontblocks-shape-animation-option.js
1 month ago
frontblocks-shape-animation-option.jsx
1 month ago
frontblocks-shape-animations.css
1 month ago
frontblocks-shape-animations.js
7 months ago
frontblocks-shape-animations.css
138 lines
| 1 | /** |
| 2 | * FrontBlocks Custom SVG Animations |
| 3 | * Base styles for custom SVG animations via JSON |
| 4 | */ |
| 5 | |
| 6 | /* Base animation class */ |
| 7 | .frbl-custom-svg-animation { |
| 8 | display: inline-block; |
| 9 | animation-fill-mode: both; |
| 10 | animation-timing-function: ease-in-out; |
| 11 | } |
| 12 | |
| 13 | /* Hover trigger: pause animation until hover */ |
| 14 | .frbl-custom-svg-animation.frbl-shape-trigger-hover { |
| 15 | animation-play-state: paused; |
| 16 | } |
| 17 | |
| 18 | .frbl-custom-svg-animation.frbl-shape-trigger-hover:hover { |
| 19 | animation-play-state: running; |
| 20 | } |
| 21 | |
| 22 | /* Respect user's motion preferences */ |
| 23 | @media (prefers-reduced-motion: reduce) { |
| 24 | .frbl-custom-svg-animation, |
| 25 | .frbl-custom-svg-animation:hover { |
| 26 | animation: none !important; |
| 27 | transition: none !important; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | /* Editor preview support */ |
| 32 | .block-editor-block-list__block .frbl-custom-svg-animation.frbl-shape-trigger-load { |
| 33 | animation-play-state: running; |
| 34 | } |
| 35 | |
| 36 | /* Show hover state in editor for better UX */ |
| 37 | .block-editor-block-list__block.is-selected .frbl-custom-svg-animation.frbl-shape-trigger-hover { |
| 38 | opacity: 0.9; |
| 39 | } |
| 40 | |
| 41 | /* Ensure SVG inherits size from parent */ |
| 42 | .frbl-custom-svg-animation svg { |
| 43 | width: 100%; |
| 44 | height: 100%; |
| 45 | display: block; |
| 46 | } |
| 47 | |
| 48 | /* ======================================== |
| 49 | LOTTIE ANIMATIONS |
| 50 | ======================================== */ |
| 51 | |
| 52 | /* Lottie animation container */ |
| 53 | .frbl-lottie-animation { |
| 54 | display: block; |
| 55 | position: relative; |
| 56 | opacity: 0; |
| 57 | transition: opacity 0.1s ease-in; |
| 58 | } |
| 59 | |
| 60 | /* Show Lottie after color is applied */ |
| 61 | .frbl-lottie-animation.frbl-color-applied { |
| 62 | opacity: 1; |
| 63 | } |
| 64 | |
| 65 | /* Lottie preview in editor */ |
| 66 | .frbl-lottie-preview { |
| 67 | display: block; |
| 68 | position: relative; |
| 69 | width: 100%; |
| 70 | height: 100%; |
| 71 | min-width: 48px; |
| 72 | min-height: 48px; |
| 73 | opacity: 1 !important; |
| 74 | } |
| 75 | |
| 76 | /* Wrapper for blocks with Lottie */ |
| 77 | .frbl-has-lottie-animation { |
| 78 | display: inline-block; |
| 79 | } |
| 80 | |
| 81 | /* Hide original SVG when Lottie is active (frontend) */ |
| 82 | .frbl-has-lottie-animation .gb-shape > svg, |
| 83 | .frbl-has-lottie-animation .wp-block-icon > svg, |
| 84 | .frbl-has-lottie-animation .wp-block-icon__icon { |
| 85 | display: none !important; |
| 86 | } |
| 87 | |
| 88 | /* Hide original SVG when Lottie preview is active (editor) */ |
| 89 | .block-editor-block-list__block .gb-shape:has(.frbl-lottie-preview) > svg, |
| 90 | .block-editor-block-list__block .wp-block-icon:has(.frbl-lottie-preview) > svg { |
| 91 | display: none !important; |
| 92 | } |
| 93 | |
| 94 | /* Ensure Lottie SVG scales properly and inherits size */ |
| 95 | .frbl-lottie-animation svg, |
| 96 | .frbl-lottie-preview svg { |
| 97 | width: 100% !important; |
| 98 | height: 100% !important; |
| 99 | max-width: 100%; |
| 100 | max-height: 100%; |
| 101 | } |
| 102 | |
| 103 | /* Color inheritance for Lottie - Base rule (will be overridden by JS for better control) */ |
| 104 | .frbl-lottie-animation path[fill]:not([fill="none"]), |
| 105 | .frbl-lottie-animation ellipse[fill]:not([fill="none"]), |
| 106 | .frbl-lottie-animation circle[fill]:not([fill="none"]), |
| 107 | .frbl-lottie-animation rect[fill]:not([fill="none"]), |
| 108 | .frbl-lottie-animation polygon[fill]:not([fill="none"]), |
| 109 | .frbl-lottie-animation polyline[fill]:not([fill="none"]), |
| 110 | .frbl-lottie-preview path[fill]:not([fill="none"]), |
| 111 | .frbl-lottie-preview ellipse[fill]:not([fill="none"]), |
| 112 | .frbl-lottie-preview circle[fill]:not([fill="none"]), |
| 113 | .frbl-lottie-preview rect[fill]:not([fill="none"]), |
| 114 | .frbl-lottie-preview polygon[fill]:not([fill="none"]), |
| 115 | .frbl-lottie-preview polyline[fill]:not([fill="none"]) { |
| 116 | fill: var(--lottie-color, currentColor) !important; |
| 117 | } |
| 118 | |
| 119 | /* Editor preview support for Lottie */ |
| 120 | .block-editor-block-list__block .frbl-lottie-animation { |
| 121 | pointer-events: auto; |
| 122 | } |
| 123 | |
| 124 | /* Respect user's motion preferences for Lottie */ |
| 125 | @media (prefers-reduced-motion: reduce) { |
| 126 | .frbl-lottie-animation { |
| 127 | display: none; |
| 128 | } |
| 129 | |
| 130 | /* Show a fallback or warning */ |
| 131 | .frbl-has-lottie-animation::before { |
| 132 | content: "Animation disabled (motion preferences)"; |
| 133 | font-size: 12px; |
| 134 | color: #666; |
| 135 | display: block; |
| 136 | } |
| 137 | } |
| 138 |