Skip to content

Instantly share code, notes, and snippets.

@MaximBalaganskiy
Forked from mreiche/index.html
Last active November 23, 2020 06:01
Show Gist options
  • Save MaximBalaganskiy/154401783b83d0cfe77a2c8f5e132958 to your computer and use it in GitHub Desktop.
Save MaximBalaganskiy/154401783b83d0cfe77a2c8f5e132958 to your computer and use it in GitHub Desktop.
mdc-list
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dumber Gist</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<base href="/">
</head>
<!--
Dumber gist uses dumber bundler, the default bundle file
is /dist/entry-bundle.js.
The starting module is pointed to aurelia-bootstrapper
(data-main attribute on script) for Aurelia,
The aurelia bootstrapper then loads up user module "main"
(aurelia-app attribute on <body>) which is your src/main.ts.
-->
<body aurelia-app="main" class="mdc-typography">
<script src="/dist/entry-bundle.js" data-main="aurelia-bootstrapper"></script>
</body>
</html>
{
"dependencies": {
"aurelia-bootstrapper": "^2.3.3"
}
}
<template>
<require from="@material/textfield/dist/mdc.textfield.css"></require>
<require from="./parent"></require>
<parent></parent>
</template>
export class App {
public message: string = 'Hello Aurelia MDC!';
}
<template>
<mdc-text-field value.bind="internalValue"></mdc-text-field>
</template>
import { inject, useView, PLATFORM } from 'aurelia-framework';
@useView(PLATFORM.moduleName('./datepicker.html'))
@inject(Element)
export class Datepicker {
constructor(private element: Element){
const viewModel = this;
Object.defineProperties(element, {
value: {
get(this: Element) {
return viewModel.value;
},
set(this: Element, value: string) {
viewModel.value = value;
},
configurable: true
}
});
}
internalValue: string;
get value(): string {
return this.internalValue;
}
set value(v: string) {
this.internalValue = v;
}
}
import {Aurelia, PLATFORM, ValueAttributeObserver, EventSubscriber, bindingMode} from 'aurelia-framework';
import { MdcComponentAdapters } from '@aurelia-mdc-web/base';
export function configure(aurelia: Aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging('info')
.plugin(PLATFORM.moduleName('@aurelia-mdc-web/all'));
aurelia.start().then(() => aurelia.setRoot());
aurelia.container.get(MdcComponentAdapters).registerMdcElementConfig({
tagName: 'datepicker',
properties: {
value: {
defaultBindingMode: bindingMode.twoWay,
getObserver(element: Element) {
return new ValueAttributeObserver(element, 'value', new EventSubscriber(['change', 'input']));
}
}
}
});
}
<template>
<require from="./datepicker"></require>
<datepicker value.bind="testValue"></datepicker>
<span>${testValue}</span>
</template>
export class Parent {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment