index.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Vue.js Radial Progress Bar Demo</title>
  5. <style>
  6. html, body {
  7. background: #4e4f4f;
  8. text-align: center;
  9. color: #FFF;
  10. font-family: 'Open Sans', Helvetica, Verdana, sans-serif;
  11. font-size: 16px;
  12. }
  13. #app {
  14. display: flex;
  15. align-items: center;
  16. }
  17. .radial-progress-display {
  18. flex: 1;
  19. display: flex;
  20. flex-direction: column;
  21. align-items: center;
  22. }
  23. .radial-progress-controls {
  24. display: flex;
  25. flex: 1;
  26. }
  27. .controls {
  28. margin-top: 10px;
  29. text-align: center;
  30. }
  31. .controls button {
  32. border-radius: 5px;
  33. color: #fff;
  34. padding: 13px 20px;
  35. background: #ff9f37;
  36. border: 0;
  37. outline: 0;
  38. line-height: 1.3em;
  39. text-transform: uppercase;
  40. cursor: pointer;
  41. box-sizing: border-box;
  42. }
  43. .controls button:hover {
  44. background: #ff9f37;
  45. }
  46. p {
  47. margin: 5px 0;
  48. }
  49. .visible-collapse {
  50. visibility: collapse;
  51. }
  52. input {
  53. margin: 0;
  54. padding: 8px;
  55. border: 1px solid #ccc;
  56. border-radius: 5px;
  57. }
  58. input, button {
  59. font: inherit;
  60. margin-bottom: 10px;
  61. }
  62. .text-left {
  63. text-align: left;
  64. }
  65. .text-right {
  66. text-align: right;
  67. }
  68. label {
  69. margin-right: 15px;
  70. }
  71. .spc-b {
  72. margin-bottom: 30px;
  73. }
  74. </style>
  75. <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
  76. <script async defer src="https://buttons.github.io/buttons.js"></script>
  77. </head>
  78. <body>
  79. <h1>Vue.js Radial Progress Bar</h1>
  80. <p class="spc-b">Customizable radial progress bar component with gradients and animations!</p>
  81. <div class="spc-b">
  82. <a class="github-button"
  83. href="https://github.com/wyzant-dev/vue-radial-progress"
  84. data-style="mega"
  85. data-count-href="/wyzant-dev/vue-radial-progress/stargazers"
  86. data-count-api="/repos/wyzant-dev/vue-radial-progress#stargazers_count"
  87. data-count-aria-label="# stargazers on GitHub"
  88. aria-label="Star wyzant-dev/vue-radial-progress on GitHub">View on Github</a>
  89. </div>
  90. <div id="app">
  91. <div class="radial-progress-display">
  92. <radial-progress-bar :diameter="diameter"
  93. :total-steps="totalSteps"
  94. :completed-steps="completedSteps"
  95. :animate-speed="animateSpeed"
  96. :stroke-width="strokeWidth"
  97. :start-color="startColor"
  98. :stop-color="stopColor"
  99. :inner-stroke-color="innerStrokeColor"
  100. :timing-func="timingFunc">
  101. <p>Total steps: {{ totalSteps }}</p>
  102. <p>Completed steps: {{ completedSteps }}</p>
  103. </radial-progress-bar>
  104. <div class="controls">
  105. <button :disabled="completedSteps <= 0"
  106. @click.prevent="prevStep">Prev</button>
  107. <button :disabled="completedSteps >= totalSteps"
  108. @click.prevent="nextStep">Next</button>
  109. </div>
  110. </div>
  111. <table class="radial-progress-controls text-right">
  112. <tr>
  113. <td>
  114. <label for="total-steps">Total steps</label>
  115. </td>
  116. <td>
  117. <input id="total-steps" type="number" placeholder="Total steps" :value="totalSteps" @input="totalStepsChanged">
  118. </td>
  119. </tr>
  120. <tr>
  121. <td>
  122. <label for="animate-speed">Animate speed</label>
  123. </td>
  124. <td>
  125. <input id="animate-speed" type="number" placeholder="Animate speed" :value="animateSpeed" @input="animateSpeedChanged">
  126. </td>
  127. </tr>
  128. <tr>
  129. <td>
  130. <label for="diameter">Diameter</label>
  131. </td>
  132. <td>
  133. <input id="diameter" type="number" placeholder="Diameter" :value="diameter" @input="diameterChanged">
  134. </td>
  135. </tr>
  136. <tr>
  137. <td>
  138. <label for="stroke-width">Stoke width</label>
  139. </td>
  140. <td>
  141. <input id="stroke-width" type="number" placeholder="Stroke width" :value="strokeWidth" @input="strokeWidthChanged">
  142. </td>
  143. </tr>
  144. <tr>
  145. <td>
  146. <label for="timing-function">Timing function</label>
  147. </td>
  148. <td>
  149. <input id="timing-function" type="text" placeholder="Timing function" :value="timingFunc" @input="timingFuncChanged">
  150. </td>
  151. </tr>
  152. <tr>
  153. <td>
  154. <label for="start-color">Start color</label>
  155. </td>
  156. <td>
  157. <input id="start-color" type="color" placeholder="Start color" :value="startColor" @input="startColorChanged">
  158. </td>
  159. </tr>
  160. <tr>
  161. <td>
  162. <label for="stop-color">Stop color</label>
  163. </td>
  164. <td>
  165. <input id="stop-color" type="color" placeholder="Stop color" :value="stopColor" @input="stopColorChanged">
  166. </td>
  167. </tr>
  168. <tr>
  169. <td>
  170. <label for="inner-stroke-color">Inner stroke color</label>
  171. </td>
  172. <td>
  173. <input id="inner-stroke-color" type="color" placeholder="Inner stroke color" :value="innerStrokeColor" @input="innerStrokeColorChanged">
  174. </td>
  175. </tr>
  176. </div>
  177. </table>
  178. <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.1/vue.min.js"></script>
  179. <script src="./dist/vue-radial-progress.min.js"></script>
  180. <script>
  181. Vue.config.debug = true
  182. new Vue({
  183. el: '#app',
  184. components: {
  185. RadialProgressBar: RadialProgressBar,
  186. },
  187. data () {
  188. return {
  189. completedSteps: 1,
  190. totalSteps: 6,
  191. animateSpeed: 1000,
  192. diameter: 300,
  193. strokeWidth: 10,
  194. startColor: '#bbff42',
  195. stopColor: '#429321',
  196. innerStrokeColor: '#323232',
  197. timingFunc: 'linear'
  198. }
  199. },
  200. methods: {
  201. timingFuncChanged(e) {
  202. this.timingFunc = e.target.value
  203. },
  204. innerStrokeColorChanged (e) {
  205. this.innerStrokeColor = e.target.value
  206. },
  207. stopColorChanged (e) {
  208. this.stopColor = e.target.value
  209. },
  210. startColorChanged (e) {
  211. this.startColor = e.target.value
  212. },
  213. strokeWidthChanged (e) {
  214. e.preventDefault()
  215. const val = e.target.value
  216. if (!val || isNaN(val)) {
  217. return false
  218. }
  219. this.strokeWidth = parseInt(val)
  220. },
  221. diameterChanged (e) {
  222. e.preventDefault()
  223. const val = e.target.value
  224. if (!val || isNaN(val)) {
  225. return false
  226. }
  227. this.diameter = parseInt(val)
  228. },
  229. animateSpeedChanged (e) {
  230. e.preventDefault()
  231. const val = e.target.value
  232. if (!val || isNaN(val)) {
  233. return false
  234. }
  235. this.animateSpeed = parseInt(val)
  236. },
  237. totalStepsChanged (e) {
  238. e.preventDefault()
  239. const val = e.target.value
  240. if (!val || isNaN(val)) {
  241. return false
  242. }
  243. this.totalSteps = parseInt(val)
  244. },
  245. nextStep () {
  246. this.completedSteps += 1
  247. },
  248. prevStep () {
  249. this.completedSteps -= 1
  250. }
  251. }
  252. })
  253. </script>
  254. </body>
  255. </html>