text-shadow.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var IPropertyDescriptor_1 = require("../IPropertyDescriptor");
  4. var parser_1 = require("../syntax/parser");
  5. var length_percentage_1 = require("../types/length-percentage");
  6. var color_1 = require("../types/color");
  7. var length_1 = require("../types/length");
  8. exports.textShadow = {
  9. name: 'text-shadow',
  10. initialValue: 'none',
  11. type: IPropertyDescriptor_1.PropertyDescriptorParsingType.LIST,
  12. prefix: false,
  13. parse: function (tokens) {
  14. if (tokens.length === 1 && parser_1.isIdentWithValue(tokens[0], 'none')) {
  15. return [];
  16. }
  17. return parser_1.parseFunctionArgs(tokens).map(function (values) {
  18. var shadow = {
  19. color: color_1.COLORS.TRANSPARENT,
  20. offsetX: length_percentage_1.ZERO_LENGTH,
  21. offsetY: length_percentage_1.ZERO_LENGTH,
  22. blur: length_percentage_1.ZERO_LENGTH
  23. };
  24. var c = 0;
  25. for (var i = 0; i < values.length; i++) {
  26. var token = values[i];
  27. if (length_1.isLength(token)) {
  28. if (c === 0) {
  29. shadow.offsetX = token;
  30. }
  31. else if (c === 1) {
  32. shadow.offsetY = token;
  33. }
  34. else {
  35. shadow.blur = token;
  36. }
  37. c++;
  38. }
  39. else {
  40. shadow.color = color_1.color.parse(token);
  41. }
  42. }
  43. return shadow;
  44. });
  45. }
  46. };
  47. //# sourceMappingURL=text-shadow.js.map