@mora-light/vue
Mora Light
Vue
Use the Mora Light component according to the following steps.
1. Install the necessary packages
npm i -S @mora-light/core @mora-light/vue
2. Import css
import '@mora-light/vue/index.css';
import '@mora-light/vue/iconfont.css';
3. How to use component
a. Method 1
If you want to use Light which is reviewed by Mora,you will know it's Anchor data. Include:
canister_id: For example: 'nciuh-jiaaa-aaaai-qo75a-cai'
hash: For example: 'AA5O64TBZ2FMJXM'
This way will automatically fetch Light data from the Mora's canister to display and run.
<script lang="ts" setup>
import { ref } from 'vue';
import { HttpAgent } from '@dfinity/agent';
import { WrappedMoraLight as WrappedMoraLightVue } from '@mora-light/vue';
import { ComponentStatus } from '@mora-light/core/types/running';
import '@mora-light/vue/index.css';
import '@mora-light/vue/iconfont.css';
const canister_id = ref('nciuh-jiaaa-aaaai-qo75a-cai')
const hash = ref('AA5O64TBZ2FMJXM')
const prop: string = JSON.stringify({
canister_id: { // If the operation of the light requires some data
type: 'principal',
value: 'ipcaz-wiaaa-aaaai-qoy4q-cai',
},
});
const status = ref<ComponentStatus>('running'); // Run status
const hostAgent = ref<HttpAgent | undefined>(undefined); // If you have login information, you can provide Light components
</script>
<template>
<div class="test-light">
<WrappedMoraLightVue
:anchor="{ canister_id, hash }"
:prop="prop"
:status="status"
:hostAgent="hostAgent"
/>
</div>
</template>
<style lang="less"></style>
b. Method 2
If you want to construct Light data yourself.
<script lang="ts" setup>
import { ref } from 'vue';
import { Principal } from '@dfinity/principal';
import { HttpAgent } from '@dfinity/agent';
import { WrappedMoraLight as WrappedMoraLightVue } from '@mora-light/vue';
import { ComponentStatus } from '@mora-light/core/types/running';
import { LightCore } from '@mora-light/core/types';
import '@mora-light/vue/index.css';
import '@mora-light/vue/iconfont.css';
// Construct Light data by yourself
let core: LightCore = {
version: '0.0.1',
data: [],
transmits: [],
};
const info = {
name: 'Light', // Light Name
cover: 'QmfVV8acYbEnhjMN4G8Pru2gzLcsam8Y12zZt2TTNvsy9S', // Cover Image
thumbnail: 'QmPMgAEogb3oaygekaEVZGvTtRcrag9RUYiizt7sPk4oSW', // Thumbnail Image
categories: ['Tools'], // categories
runnable_planet: { All: null }, // Runnable Planet
instruction: "Light Instruction", // Light Instruction
};
const value = {
hash: 'XXX', // Custom data
id: 'XXX', // Custom data
created: BigInt(new Date().getTime() * 1000000),
creator: Principal.fromText('aaaaa-aa'),
updated: BigInt(new Date().getTime() * 1000000),
info_json: JSON.stringify(info),
core_json: JSON.stringify(core),
audited: BigInt(new Date().getTime() * 1000000),
auditor: Principal.fromText('aaaaa-aa'),
};
const data = { value };
const prop: string = JSON.stringify({
canister_id: { // If the operation of this light requires certain data
type: 'principal',
value: 'ipcaz-wiaaa-aaaai-qoy4q-cai',
},
});
const status = ref<ComponentStatus>('running'); // Run status
const hostAgent = ref<HttpAgent | undefined>(undefined); // If you have login information, you can provide Light components
</script>
<template>
<div class="test-light">
<WrappedMoraLightVue
:data="data"
:prop="prop"
:status="status"
:hostAgent="hostAgent"
/>
</div>
</template>
<style lang="less"></style>
Related Packages
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 0.0.5 | * | MIT | |
| 0.0.4 | * | MIT |
Pre-releases (131)
| Version | Released | Vue | License |
|---|---|---|---|
| 0.0.4-alpha.2 | * | MIT | |
| 0.0.3-alpha.3 | * | MIT | |
| 0.0.3-alpha.2 | * | MIT | |
| 0.0.3-alpha.1 | * | MIT | |
| 0.0.1-alpha.128 | * | MIT | |
| 0.0.1-alpha.126 | * | MIT | |
| 0.0.1-alpha.125 | * | MIT | |
| 0.0.1-alpha.124 | * | MIT | |
| 0.0.1-alpha.123 | * | MIT | |
| 0.0.1-alpha.122 | * | MIT | |
| 0.0.1-alpha.121 | * | MIT | |
| 0.0.1-alpha.120 | * | MIT | |
| 0.0.1-alpha.118 | * | MIT | |
| 0.0.1-alpha.117 | * | MIT | |
| 0.0.1-alpha.116 | * | MIT | |
| 0.0.1-alpha.115 | * | MIT | |
| 0.0.1-alpha.114 | * | MIT | |
| 0.0.1-alpha.113 | * | MIT | |
| 0.0.1-alpha.112 | * | MIT | |
| 0.0.1-alpha.111 | * | MIT | |
| 0.0.1-alpha.110 | * | MIT | |
| 0.0.1-alpha.109 | * | MIT | |
| 0.0.1-alpha.108 | * | MIT | |
| 0.0.1-alpha.107 | * | MIT | |
| 0.0.1-alpha.106 | * | MIT | |
| 0.0.1-alpha.105 | * | MIT | |
| 0.0.1-alpha.104 | * | MIT | |
| 0.0.1-alpha.103 | * | MIT | |
| 0.0.1-alpha.102 | * | MIT | |
| 0.0.1-alpha.101 | * | MIT |
Showing the latest 30 of 131. See every release on npm