Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

findAnimationName.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. 'use strict';
  2. const getUnitFromValueNode = require('./getUnitFromValueNode');
  3. const isStandardSyntaxValue = require('./isStandardSyntaxValue');
  4. const isVariable = require('./isVariable');
  5. const keywordSets = require('../reference/keywordSets');
  6. const postcssValueParser = require('postcss-value-parser');
  7. /** @typedef {import('postcss-value-parser').Node} Node */
  8. /**
  9. * Get the animation name within an `animation` shorthand property value.
  10. *
  11. * @param {string} value
  12. *
  13. * @returns {Node[]}
  14. */
  15. module.exports = function findAnimationName(value) {
  16. /** @type {Node[]} */
  17. const animationNames = [];
  18. const valueNodes = postcssValueParser(value);
  19. // Handle `inherit`, `initial` and etc
  20. if (
  21. valueNodes.nodes.length === 1 &&
  22. keywordSets.basicKeywords.has(valueNodes.nodes[0].value.toLowerCase())
  23. ) {
  24. return [valueNodes.nodes[0]];
  25. }
  26. valueNodes.walk((valueNode) => {
  27. if (valueNode.type === 'function') {
  28. return false;
  29. }
  30. if (valueNode.type !== 'word') {
  31. return;
  32. }
  33. const valueLowerCase = valueNode.value.toLowerCase();
  34. // Ignore non-standard syntax
  35. if (!isStandardSyntaxValue(valueLowerCase)) {
  36. return;
  37. }
  38. // Ignore variables
  39. if (isVariable(valueLowerCase)) {
  40. return;
  41. }
  42. // Ignore keywords for other animation parts
  43. if (keywordSets.animationShorthandKeywords.has(valueLowerCase)) {
  44. return;
  45. }
  46. // Ignore numbers with units
  47. const unit = getUnitFromValueNode(valueNode);
  48. if (unit || unit === '') {
  49. return;
  50. }
  51. animationNames.push(valueNode);
  52. });
  53. return animationNames;
  54. };