The æternity æpp components are meant to provide æpp developers with reusable Vue.js components that adhere to our styleguide.
The github repository is here.
Note: this repository is currently in active development and things might break / change in the future but we will be adhering to the Semantic versioning.
Full component documentation can be found at http://aeternity.com/aepp-components/
Install the æternity æpp components via npm
npm install -g @vue/cli
vue create project-name
cd project-name
npm i
#develop
branch is the most up to date version.npm i --save https://github.com/aeternity/aepp-components.git#develop
npm run serve
App running at:
- Local: http://localhost:8080/
- Network: http://192.xxx.xxx.xxx:8080/
In your new Vue project with the downloaded directory open your Table of Contents and navigate too src --> main.js
There its the root file of your application, where you can import
æpp components.
In case you want to include normalize.css, and some style resets, include: this will include fonts and some small global css styles
import '@aeternity/aepp-components/dist/aepp.global.css'
If you already have global styles in your application, but only need the fonts, use this import file.
import '@aeternity/aepp-components/dist/aepp.fonts.css'
Import the entire components styles (this will include all components css, except fonts and global styles)
import '@aeternity/aepp-components/dist/aepp.components.css'
Below there's a list of ways in which you can import your components to your application.
import Components from '@aeternity/aepp-components'
Vue.use(Components)
import { AeButton } from '@aeternity/aepp-components'
Vue.use(AeButton)
// or
Vue.component('ae-button', AeButton)
import { AeButton } from '@aeternity/aepp-components'
new Vue({
components: {
AeButton
}
})
import '@aeternity/aepp-components/dist/ae-button/ae-button.css'
import AeButton from '@aeternity/aepp-components/dist/ae-button/ae-button.vue'
new Vue({
components: {
AeButton
}
})
Global registration (Method 1 & 2) will make the æternity æpp components available throughout your app, local registration (Method 3 and 4) will have to be declared in each relevant section of your app.
<template>
<div id="app">
<ae-button @click="buttonPress()">My Button</ae-button>
</div>
</template>
There's also a helper mixin / directives and filters available for handy utilities.
import { mixins } from '@aeternity/aepp-components'
export default {
/* … */
mixins: [mixins.events],
}
import { directives } from '@aeternity/aepp-components'
export default {
/* … */
directives: { removeSpacesOnCopy: directives.removeSpacesOnCopy },
}
import { filters } from '@aeternity/aepp-components'
export default {
/* … */
mixins: [filters.example],
}
Below you'll find some examples how you can import and use the components.
import Vue from 'vue'
import App from './App.vue'
import Components from '@aeternity/aepp-components'
Vue.use(Components)
new Vue({
el: '#app',
render: h => h(App)
})
<template>
<main id="app">
<!-- add components here -->
<ae-button>BUTTON</ae-button>
</main>
</template>
<script>
import { AeButton, mixins } from '@aeternity/aepp-components'
export default {
name: 'app',
mixins: [mixins.events],
components: {
AeButton
},
data () {
return {
showModal: false,
identity: {
balance: '1337210000000000000', // wei as string, int or BN
address: '0x1234567890987654321'
}
}
},
methods: {
buttonPress (what) {
console.log("button pressed", what)
}
}
}
</script>
<style>
div.example {
margin-bottom: 40px;
}
</style>
Further documentation on the components can be found at http://aeternity.com/aepp-components/.