{
"$schema": "../../schemas/code-crispies-module-schema.json",
"id": "transitions-animations",
"title": "CSS Анімації",
"description": "Додайте інтерактивність до інтерфейсу через плавні переходи властивостей та анімації на основі keyframes.",
"difficulty": "intermediate",
"lessons": [
{
"id": "transitions-1",
"title": "Transitions",
"description": "Навчіться застосовувати transition до властивостей для плавних змін при зміні стану.
transition: property duration;\n/* напр. transition: background-color 0.3s; */", "task": "Додайте transition: background-color 0.3s, щоб колір плавно змінювався при наведенні.", "previewHTML": "", "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .btn { background: black; color: white; padding: 0.5rem 1rem; border: none; cursor: pointer; } .btn:hover { background: white; color: black; }", "sandboxCSS": "", "codePrefix": "/* Add transition */\n.btn {", "initialCode": "", "codeSuffix": "}", "solution": " transition: background-color 0.3s;", "previewContainer": "preview-area", "validations": [ { "type": "contains", "value": "transition", "message": "Використайте властивість transition", "options": { "caseSensitive": false } }, { "type": "regex", "value": "transition:\\s*background-color\\s*0\\.3s", "message": "Встановіть transition: background-color 0.3s", "options": { "caseSensitive": false } } ] }, { "id": "transitions-2", "title": "Timing Funcs", "description": "Дослідіть функції пом'якшення як ease, linear, ease-in, ease-out для контролю темпу анімації.", "task": "Встановіть transition-timing-function на ease-in-out.", "previewHTML": "", "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .btn { background: navy; color: gold; padding: 0.5rem 1rem; border: none; cursor: pointer; transition: all 0.5s; } .btn:hover { background: gold; color: navy; transform: scale(1.1); }", "sandboxCSS": "", "codePrefix": "/* Set timing function */\n.btn {", "initialCode": "", "codeSuffix": "}", "solution": " transition-timing-function: ease-in-out;", "previewContainer": "preview-area", "validations": [ { "type": "contains", "value": "transition-timing-function", "message": "Використайте transition-timing-function", "options": { "caseSensitive": false } }, { "type": "property_value", "value": { "property": "transition-timing-function", "expected": "ease-in-out" }, "message": "Встановіть timing на ease-in-out" } ] }, { "id": "transitions-3", "title": "Keyframes", "description": "Створюйте іменовані анімації використовуючи @keyframes та застосовуйте їх через скорочення animation.
@keyframes bounce {\n 50% { transform: translateY(-20px); }\n}\n.ball {\n animation: bounce 1s infinite;\n}",
"task": "Визначте keyframe при 50% з transform: translateY(-20px) та застосуйте animation: bounce 1s infinite на .ball.",
"previewHTML": "",
"previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .ball { width: 50px; height: 50px; background: crimson; border-radius: 50%; margin: 2rem auto; }",
"sandboxCSS": "",
"codePrefix": "/* Define keyframes and apply animation */\n@keyframes bounce {",
"initialCode": "",
"codeSuffix": "}\n.ball { }",
"solution": " 50% { transform: translateY(-20px); }\n}\n.ball {\n animation: bounce 1s infinite;",
"previewContainer": "preview-area",
"validations": [
{
"type": "contains",
"value": "@keyframes bounce",
"message": "Визначте @keyframes bounce",
"options": { "caseSensitive": false }
},
{
"type": "regex",
"value": "50%.*transform: translateY\\(-20px\\)",
"message": "При 50%, використайте transform: translateY(-20px)",
"options": { "caseSensitive": false }
},
{
"type": "contains",
"value": "animation",
"message": "Використайте властивість animation на .ball",
"options": { "caseSensitive": false }
},
{
"type": "regex",
"value": "animation:.*bounce.*1s.*infinite",
"message": "Застосуйте animation: bounce 1s infinite",
"options": { "caseSensitive": false }
}
]
},
{
"id": "transitions-4",
"title": "Animation Properties",
"description": "Налаштуйте анімації за допомогою animation-delay, animation-iteration-count, animation-direction та animation-fill-mode.",
"task": "Застосуйте анімацію pulse до .box з animation-name: pulse, animation-duration: 2s, animation-delay: 1s, animation-iteration-count: 2 та animation-fill-mode: forwards.",
"previewHTML": "