Skip to content

Instantly share code, notes, and snippets.

@sn123
Last active September 30, 2020 07:38
Show Gist options
  • Save sn123/ad1b185cdd76abab4d0bd5eb4c8c4b22 to your computer and use it in GitHub Desktop.
Save sn123/ad1b185cdd76abab4d0bd5eb4c8c4b22 to your computer and use it in GitHub Desktop.
An animated number widget for mustard
<template>
<div class="center number">
<h4>{{ title }}</h4>
<AnimatedNumberComponent v-bind:value="model.value" />
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { getStoreItem, State } from "../store";
import AnimatedNumberComponent from "./shared/AnimatedNumber.vue";
@Component({
components: {
AnimatedNumberComponent
}
})
export default class NumberComponent extends Vue {
@Prop() private value?: number;
@Prop() private title?: string;
@Prop() private eventId?: string;
get model(): { value: number } {
return (
getStoreItem((this.$store.state as unknown) as State, this.eventId) || {
value: this.value || 0
}
);
}
}
</script>
<style scoped lang="scss">
.number {
background: #bc3908;
justify-content: center;
align-items: center;
flex-direction: column;
h1 {
font-size: 60px;
}
}
.red {
background: #ef2d56;
}
.green {
background: #0a8657;
}
</style>
@sn123
Copy link
Author

sn123 commented May 3, 2020

Animated number widget for Mustard

Setting up

Install this widget by running $ mustard -gist=ad1b185cdd76abab4d0bd5eb4c8c4b22

Configuration

In App.Vue add this component and set the event Id to which this widget should be bound on server. Don't forget to provide an empty definition of the eventId in ./store/index.ts. This widget works best with binding this event to the Kafka consumer on server.

<NumberWidget eventId="eventId" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment