Skip to content

Instantly share code, notes, and snippets.

@dabit3
Last active October 19, 2019 14:54
Show Gist options
  • Save dabit3/89f452e967e931045dab326ef42beee3 to your computer and use it in GitHub Desktop.
Save dabit3/89f452e967e931045dab326ef42beee3 to your computer and use it in GitHub Desktop.
Using amplify-photo-picker & amplify-s3-album Vue components
<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