-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add vue example and cleanup comments (#4607)
* add vue example and cleanup comments * remove vue dependency * Update app.ts
- Loading branch information
1 parent
36ff6f0
commit c06be22
Showing
8 changed files
with
78 additions
and
32 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
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
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
53 changes: 53 additions & 0 deletions
53
examples/hosts/app-integration/external-controller/src/vueView.ts.preview
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,53 @@ | ||
/*! | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
import { createApp } from "vue"; | ||
import { IKeyValueDataObject } from "./kvpair-dataobject"; | ||
|
||
/** | ||
* Render Dice into a given HTMLElement as a text character, with a button to roll it. | ||
* @param dataObject - The Data Object to be rendered | ||
* @param div - The HTMLElement to render into | ||
*/ | ||
export function renderDiceRoller(dataObject: IKeyValueDataObject, div: HTMLDivElement) { | ||
const app = createApp({ | ||
template: ` | ||
<div style="text-align: center" > | ||
<div v-bind:style="{ fontSize: '200px', color: diceColor }"> | ||
{{diceCharacter}} | ||
</div> | ||
<button style="font-size: 50px;" v-on:click="rollDice"> | ||
Roll | ||
</button> | ||
</div>`, | ||
data: () => ( | ||
{ diceValue: 1 } | ||
), | ||
computed:{ | ||
diceCharacter() { | ||
return String.fromCodePoint(0x267F + (this.diceValue as number)); | ||
}, | ||
diceColor() { | ||
return `hsl(${this.diceValue * 60}, 70%, 50%)`; | ||
}, | ||
}, | ||
methods: { | ||
rollDice() { | ||
dataObject.set("dice", Math.floor(Math.random() * 6) + 1); | ||
}, | ||
syncLocalAndFluidState() { | ||
this.diceValue = dataObject.get("dice"); | ||
}, | ||
}, | ||
mounted() { | ||
dataObject.on("changed", this.syncLocalAndFluidState); | ||
}, | ||
unmounted() { | ||
dataObject.off("changed", this.syncLocalAndFluidState); | ||
}, | ||
}); | ||
|
||
app.mount(div); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.