Skip to content

Instantly share code, notes, and snippets.

View ilikerobots's full-sized avatar

Mike Hoolehan ilikerobots

View GitHub Profile
@ilikerobots
ilikerobots / 2021-05-11-django-vue3.js
Created May 12, 2021 08:51
string-property-passing-01
const selector = "#my_app_element";
const mountEl = document.querySelector(selector);
const app = createApp(AppComponent, {...mountEl.dataset});
class _RainbowBoxState extends State<RainbowBox>
with SingleTickerProviderStateMixin {
AnimationController _controller;
Animation<double> _anim;
@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(seconds: 5),
Animatable<Color> bgColor = RainbowColorTween([
Colors.red,
Colors.blue,
Colors.green,
Colors.yellow,
Colors.red,
])
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _controller,
builder: (context, child) {
return Container(
padding: EdgeInsets.all(24.0),
decoration: BoxDecoration(color: _colorAnim.value),
child: Text('Tween Sequence'),
);
});
class _TweenSequenceBoxState extends State<TweenSequenceBox>
with SingleTickerProviderStateMixin {
AnimationController _controller;
Animation<Color> _colorAnim;
@override
void initState() {
super.initState();
_controller = AnimationController(
Animatable<Color> bgColor = TweenSequence<Color>([
TweenSequenceItem(
weight: 1.0,
tween: ColorTween(begin: Colors.red, end: Colors.blue),
),
TweenSequenceItem(
weight: 1.0,
tween: ColorTween(begin: Colors.blue, end: Colors.green),
),
TweenSequenceItem(
<div>
<input id="button_loader" type="button" value="Load stopwatch">
</div>
<div id="stopwatch">
<stopwatch></stopwatch>
</div>
<script>
let stopwatchBtn = document.getElementById('button_loader');
from typing import Dict
from django import template
register = template.Library()
@register.inclusion_tag('lazy_render_bundle.html', takes_context=False)
def lazy_render_bundle(bundle: Dict[str, str]) -> Dict[str, Dict[str, str]]:
return {'bundle': bundle}
function load_bundle_file(url, filetype) {
let fileref;
if (filetype === "js") { // build js script tag
fileref = document.createElement('script');
fileref.setAttribute("type", "text/javascript");
fileref.setAttribute("src", url);
} else if (filetype === "css") { // build css link tag
fileref = document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
import Vue from "vue/dist/vue.js";
const Stopwatch = () => import( /* webpackChunkName: "chunk-stopwatch" */ "./components/Stopwatch.vue");
Vue.config.productionTip = false;
new Vue({
el: "#stopwatch",
components: {Stopwatch}
});