Button.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template >
  2. <div class='playStopButton' @click='togglePlay' :class='{ active: status === "play", loading }'>
  3. <!-- //- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" fill='white' xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" xml:space="preserve">
  4. //- <circle id='circle' cx="50%" cy="50%" r="5%" fill/>
  5. //- </svg> -->
  6. <div id='stop'>
  7. <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
  8. <g><g transform="translate(0.000000,500.000000) scale(0.100000,-0.100000)"><path d="M3598.3,1507.4l-46.2-48.3v-1354v-1356.1l48.3-44.1l48.3-46.2h1354h1356.1l44.1,48.3l46.2,48.3v1354v1356l-48.3,44.1l-48.3,46.2h-1354h-1356L3598.3,1507.4z"/></g></g>
  9. </svg>
  10. </div>
  11. <div id='play'>
  12. <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
  13. <g><g transform="translate(0.000000,500.000000) scale(0.100000,-0.100000)"><path d="M3885.7,2036.4c-29.2-29.2-33.4-229.6-33.4-1888.8c0-1241.8,6.3-1872.1,20.9-1899.2c27.1-48,104.4-52.2,194.1-6.3C4286.4-1645.2,7143.6,14,7166.6,41.2c33.4,41.7,33.4,154.4-2.1,196.2c-20.9,27.1-2876,1686.3-3097.2,1799C3983.8,2078.1,3927.5,2078.1,3885.7,2036.4z"/></g></g>
  14. </svg>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. export default {
  20. data () {
  21. return {
  22. loading: false,
  23. status: 'stop'
  24. }
  25. },
  26. methods: {
  27. play () {
  28. this.status = 'play'
  29. },
  30. stop () {
  31. this.status = 'stop'
  32. },
  33. togglePlay () {
  34. this.status = this.status === 'play' ? 'stop' : 'play'
  35. this.$emit(this.status)
  36. }
  37. }
  38. }
  39. </script>
  40. <style scoped>
  41. .playStopButton {
  42. width: 60px;
  43. height: 60px;
  44. margin: 5px 0px 5px 5px;
  45. cursor: pointer;
  46. position: relative;
  47. }
  48. .playStopButton:focus {
  49. outline:0;
  50. }
  51. .playStopButton.active #play {
  52. transform: rotate( 90deg ) scale( 0 );
  53. opacity: 0;
  54. }
  55. .playStopButton:not( .active ) #stop {
  56. transform: rotate( -90deg ) scale( 0 );
  57. opacity: 0;
  58. }
  59. .playStopButton svg {
  60. height: 100%;
  61. width: 100%;
  62. }
  63. #play, #stop {
  64. width: 100%;
  65. height: 100%;
  66. transition: all .35s ease-in-out;
  67. position: absolute;
  68. stroke: rgba(248, 113, 113, var(--tw-text-opacity));
  69. fill:rgba(248, 113, 113, var(--tw-text-opacity));
  70. top: 0px;
  71. left: 0px;
  72. }
  73. #circle {
  74. fill: none;
  75. stroke: red;
  76. stroke-width: 3px;
  77. }
  78. </style>