box-shadow.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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.boxShadow = {
  9. name: 'box-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: 0x000000ff,
  20. offsetX: length_percentage_1.ZERO_LENGTH,
  21. offsetY: length_percentage_1.ZERO_LENGTH,
  22. blur: length_percentage_1.ZERO_LENGTH,
  23. spread: length_percentage_1.ZERO_LENGTH,
  24. inset: false
  25. };
  26. var c = 0;
  27. for (var i = 0; i < values.length; i++) {
  28. var token = values[i];
  29. if (parser_1.isIdentWithValue(token, 'inset')) {
  30. shadow.inset = true;
  31. }
  32. else if (length_1.isLength(token)) {
  33. if (c === 0) {
  34. shadow.offsetX = token;
  35. }
  36. else if (c === 1) {
  37. shadow.offsetY = token;
  38. }
  39. else if (c === 2) {
  40. shadow.blur = token;
  41. }
  42. else {
  43. shadow.spread = token;
  44. }
  45. c++;
  46. }
  47. else {
  48. shadow.color = color_1.color.parse(token);
  49. }
  50. }
  51. return shadow;
  52. });
  53. }
  54. };
  55. //# sourceMappingURL=box-shadow.js.map