vue-github-badge.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*!
  2. * vue-github-badge v1.0.1
  3. * (c) 2017-present egoist <0x142857@gmail.com>
  4. * Released under the MIT License.
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  8. typeof define === 'function' && define.amd ? define(factory) :
  9. (global.GitHubBadge = factory());
  10. }(this, (function () { 'use strict';
  11. var nestRE = /^(attrs|props|on|nativeOn|class|style|hook)$/;
  12. var index$1 = function mergeJSXProps(objs) {
  13. return objs.reduce(function (a, b) {
  14. var aa, bb, key, nestedKey, temp;
  15. for (key in b) {
  16. aa = a[key];
  17. bb = b[key];
  18. if (aa && nestRE.test(key)) {
  19. // normalize class
  20. if (key === 'class') {
  21. if (typeof aa === 'string') {
  22. temp = aa;
  23. a[key] = aa = {};
  24. aa[temp] = true;
  25. }
  26. if (typeof bb === 'string') {
  27. temp = bb;
  28. b[key] = bb = {};
  29. bb[temp] = true;
  30. }
  31. }
  32. if (key === 'on' || key === 'nativeOn' || key === 'hook') {
  33. // merge functions
  34. for (nestedKey in bb) {
  35. aa[nestedKey] = mergeFn(aa[nestedKey], bb[nestedKey]);
  36. }
  37. } else if (Array.isArray(aa)) {
  38. a[key] = aa.concat(bb);
  39. } else if (Array.isArray(bb)) {
  40. a[key] = [aa].concat(bb);
  41. } else {
  42. for (nestedKey in bb) {
  43. aa[nestedKey] = bb[nestedKey];
  44. }
  45. }
  46. } else {
  47. a[key] = b[key];
  48. }
  49. }
  50. return a;
  51. }, {});
  52. };
  53. function mergeFn(a, b) {
  54. return function () {
  55. a.apply(this, arguments);
  56. b.apply(this, arguments);
  57. };
  58. }
  59. var index = {
  60. name: 'github-badge',
  61. functional: true,
  62. props: {
  63. slug: { type: String, required: true },
  64. width: { type: Number, default: 36 },
  65. height: { type: Number, default: 36 },
  66. fill: { type: String, default: 'black' }
  67. },
  68. render: function render(h, ctx) {
  69. var _ctx$props = ctx.props,
  70. slug = _ctx$props.slug,
  71. height = _ctx$props.height,
  72. width = _ctx$props.width,
  73. fill = _ctx$props.fill;
  74. var style = {
  75. position: 'fixed',
  76. top: '1rem',
  77. right: '1rem',
  78. zIndex: 9999
  79. };
  80. return h(
  81. 'a',
  82. index$1([{ style: style, attrs: { href: 'https://github.com/' + slug, target: '_blank' }
  83. }, ctx.data]),
  84. [h(
  85. 'svg',
  86. {
  87. attrs: { id: 'i-github', viewBox: '0 0 64 64', width: height, height: width }
  88. },
  89. [h(
  90. 'path',
  91. {
  92. attrs: { 'stroke-width': '0', fill: fill, d: 'M32 0 C14 0 0 14 0 32 0 53 19 62 22 62 24 62 24 61 24 60 L24 55 C17 57 14 53 13 50 13 50 13 49 11 47 10 46 6 44 10 44 13 44 15 48 15 48 18 52 22 51 24 50 24 48 26 46 26 46 18 45 12 42 12 31 12 27 13 24 15 22 15 22 13 18 15 13 15 13 20 13 24 17 27 15 37 15 40 17 44 13 49 13 49 13 51 20 49 22 49 22 51 24 52 27 52 31 52 42 45 45 38 46 39 47 40 49 40 52 L40 60 C40 61 40 62 42 62 45 62 64 53 64 32 64 14 50 0 32 0 Z' }
  93. },
  94. []
  95. )]
  96. )]
  97. );
  98. }
  99. };
  100. return index;
  101. })));