Last active
October 19, 2019 14:54
-
-
Save dabit3/89f452e967e931045dab326ef42beee3 to your computer and use it in GitHub Desktop.
Using amplify-photo-picker & amplify-s3-album Vue components
This file contains hidden or 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
<template> | |
<div id="app"> | |
<div v-if="!signedIn"> | |
<amplify-authenticator></amplify-authenticator> | |
</div> | |
<div v-if="signedIn"> | |
<amplify-sign-out class="signout"></amplify-sign-out> | |
<div class="container"> | |
<amplify-photo-picker | |
v-bind:photoPickerConfig="photoPickerConfig" | |
></amplify-photo-picker> | |
<amplify-s3-album path="images/"></amplify-s3-album> | |
</div> | |
</div> | |
</div> | |
</template> | |
<script> | |
import { AmplifyEventBus } from 'aws-amplify-vue' | |
import { Auth } from 'aws-amplify' | |
const photoPickerConfig = { | |
path: 'images/', | |
} | |
export default { | |
name: 'app', | |
async beforeCreate() { | |
try { | |
const user = await Auth.currentAuthenticatedUser() | |
this.signedIn = true | |
} catch (err) { | |
this.signedIn = false | |
} | |
AmplifyEventBus.$on('authState', info => { | |
if (info === 'signedIn') { | |
this.signedIn = true | |
} else { | |
this.signedIn = false | |
} | |
}); | |
}, | |
data () { | |
return { | |
photoPickerConfig, | |
signedIn: false | |
} | |
} | |
} | |
</script> | |
<style> | |
body { | |
margin: 0 | |
} | |
#app { | |
font-family: 'Avenir', Helvetica, Arial, sans-serif; | |
-webkit-font-smoothing: antialiased; | |
-moz-osx-font-smoothing: grayscale; | |
text-align: center; | |
color: #2c3e50; | |
} | |
.container { | |
padding: 40px; | |
} | |
.signout { | |
background-color: #ededed; | |
margin: 0; | |
padding: 11px 0px 1px; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment