@qwerty123321123

Возможно ли используя style-dictionary создать переменную для @keyframe?

Добрый день! Есть JSON приведенный ниже, необходимо собрать переменную с помощью style-dictionary которую можно будет применять в animation без создания @keyframe

{
  "animation": {
      "keyframe": { "value": "@keyframes test { 0% { background-position: 0 } 100% { background-position: 100px } }" }
  }
}


Вопрос следующий, возможно ли вообще такое?)
  • Вопрос задан
  • 45 просмотров
Решения вопроса 1
Mike_Ro
@Mike_Ro Куратор тега JavaScript
Python, JS, WordPress, SEO, Bots, Adversting
Пример styleDictionary конфигурации, которая определяет animationKeyframe переменную на основе Вашего JSON-объекта:
{
  "source": ["tokens/**/*.json"],
  "platforms": {
    "css": {
      "transformGroup": "css",
      "buildPath": "build/",
      "files": [
        {
          "destination": "animation.css",
          "format": "css/variables",
          "filter": {
            "type": "animation",
            "property": "keyframe"
          },
          "options": {
            "outputReferences": true
          }
        }
      ]
    }
  },
  "properties": {
    "animation": {
      "keyframe": {
        "type": "animation",
        "category": "asset",
        "value": "@keyframes test { 0% { background-position: 0 } 100% { background-position: 100px } }"
      }
    }
  },
  "types": {
    "animation": {
      "type": "object",
      "properties": {
        "keyframe": {
          "type": "string",
          "transform": {
            "type": "name",
            "value": "animationKeyframe"
          }
        }
      }
    }
  }
}

out:
.my-animation {
  animation-name: animationKeyframe;
  animation-duration: 2s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы