-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project structure refactoring, moved library files in dedicated folder to separate them from demo source code Unified the components base style in separate file and changed base class names Changed default hardcoded css base icons in favor of fully customizable svg icon or replaceable slot, see #2 for the discussion
- Loading branch information
Filippo Conti
committed
Dec 28, 2019
1 parent
514bf2c
commit 9fbb2fa
Showing
13 changed files
with
263 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<template lang="html"> | ||
<div | ||
v-if="isSupported" | ||
v-bind:class="{ | ||
'vue-record': true, | ||
'vue-record-audio': true, | ||
'active': isRecording, | ||
'paused': isPaused | ||
}" | ||
v-on="{ | ||
'mousedown': startRecording, | ||
'mouseleave': stopRecording, | ||
'mouseup': startRecording, | ||
'touchstart': startRecording, | ||
'touchend': startRecording, | ||
'touchcancel': startRecording, | ||
}" | ||
> | ||
<div class="icon-container" :style="backgroundStyle"> | ||
<slot> | ||
<svg v-bind="foregroundStyle" viewBox="0 0 24 24"> | ||
<path d="M12,2A3,3 0 0,1 15,5V11A3,3 0 0,1 12,14A3,3 0 0,1 9,11V5A3,3 0 0,1 12,2M19,11C19,14.53 16.39,17.44 13,17.93V21H11V17.93C7.61,17.44 5,14.53 5,11H7A5,5 0 0,0 12,16A5,5 0 0,0 17,11H19Z" /> | ||
</svg> | ||
</slot> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
const supportedTypes = [ | ||
'audio/aac', | ||
'audio/ogg', | ||
'audio/wav', | ||
'audio/webm' | ||
] | ||
import ElementMixin from '../mixins/Element' | ||
export default { | ||
name: 'VueRecordAudio', | ||
mixins: [ElementMixin], | ||
supportedTypes, | ||
props: { | ||
mimeType: { | ||
type: String, | ||
default: 'audio/webm', | ||
validator: v => supportedTypes.includes(v) | ||
} | ||
}, | ||
data () { | ||
return { | ||
constraints: { | ||
audio: true, | ||
video: false | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss" src="../index.scss"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<template lang="html"> | ||
<div | ||
v-if="isSupported" | ||
v-on="{ | ||
'mousedown': startRecording, | ||
'mouseleave': stopRecording, | ||
'mouseup': startRecording, | ||
'touchstart': startRecording, | ||
'touchend': startRecording, | ||
'touchcancel': startRecording, | ||
}" | ||
class="vue-record vue-video-recorder" | ||
:class="{ | ||
'vue-record': true, | ||
'vue-record-video': true, | ||
'active': isRecording, | ||
'paused': isPaused | ||
}" | ||
> | ||
<div class="icon-container" :style="backgroundStyle"> | ||
<template v-if="isRecording"> | ||
<svg v-bind="foregroundStyle" viewBox="0 0 24 24"> | ||
<path fill="#000000" d="M18,18H6V6H18V18Z" /> | ||
</svg> | ||
</template> | ||
|
||
<template v-else> | ||
<svg v-bind="foregroundStyle" viewBox="0 0 24 24"> | ||
<path | ||
fill="#000000" | ||
d="M17,10.5V7A1,1 0 0,0 16,6H4A1,1 0 0,0 3,7V17A1,1 0 0,0 4,18H16A1,1 0 0,0 17,17V13.5L21,17.5V6.5L17,10.5Z" | ||
/> | ||
</svg> | ||
</template> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
const supportedTypes = [ | ||
'video/x-msvideo', | ||
'video/ogg', | ||
'video/mpeg', | ||
'video/webm' | ||
] | ||
import ElementMixin from '../mixins/Element' | ||
// <svg style="width:24px;height:24px" viewBox="0 0 24 24"> | ||
// <path fill="#000000" d="M14,19H18V5H14M6,19H10V5H6V19Z" /> | ||
// </svg> | ||
export default { | ||
name: 'VueRecordVideo', | ||
mixins: [ElementMixin], | ||
props: { | ||
mimeType: { | ||
type: String, | ||
default: 'video/webm', | ||
validator: v => supportedTypes.includes(v) | ||
}, | ||
audio: { | ||
type: Boolean, | ||
default: true | ||
}, | ||
mode: { | ||
default: 'press' | ||
} | ||
}, | ||
computed: { | ||
constraints () { | ||
return { | ||
video: true, | ||
audio: this.audio | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss" src="../index.scss"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import VueRecordAudio from './components/RecordAudio' | ||
import VueRecordVideo from './components/RecordVideo' | ||
|
||
export { | ||
VueRecordAudio, | ||
VueRecordVideo | ||
} | ||
|
||
export default function install(Vue, options = {}) { | ||
Vue.prototype.$VueRecord = options; | ||
Vue.component('VueRecordAudio', VueRecordAudio) | ||
Vue.component('VueRecordVideo', VueRecordVideo) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.vue-record { | ||
display: inline-block; | ||
height: 100%; | ||
|
||
.icon-container { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
&.vue-record-audio {} | ||
|
||
&.vue-record-video {} | ||
} | ||
|
||
// &.active > .icon-container { | ||
// -webkit-animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1); | ||
// -moz-animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1); | ||
// animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1); | ||
// } | ||
|
||
// @keyframes pulse { | ||
// to { | ||
// -webkit-transform: scale(0.9); | ||
// transform: scale(0.9); | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
export default { | ||
props: { | ||
color: { | ||
type: String, | ||
default: '#000' | ||
}, | ||
bgColor: { | ||
type: String, | ||
default: '#eee' | ||
}, | ||
padding: { | ||
type: Number, | ||
default: 4 | ||
}, | ||
size: { | ||
type: [Number, String], | ||
default: 64 | ||
}, | ||
radius: { | ||
type: Number, | ||
default: 0 | ||
}, | ||
rounded: Boolean, | ||
}, | ||
computed: { | ||
backgroundStyle() { | ||
return { | ||
backgroundColor: this.bgColor, | ||
width: `${this.size}px`, | ||
height: `${this.size}px`, | ||
borderRadius: `${this.radius}px`, | ||
padding: `${this.padding}px` | ||
} | ||
}, | ||
foregroundStyle() { | ||
return { | ||
fill: this.color, | ||
width: this.size, | ||
height: this.size, | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.