Skip to content

Instantly share code, notes, and snippets.

@thousand
Last active May 29, 2020 21:27
Show Gist options
  • Save thousand/59472041ff27b0d2b9e9c8b83775084f to your computer and use it in GitHub Desktop.
Save thousand/59472041ff27b0d2b9e9c8b83775084f to your computer and use it in GitHub Desktop.
classic component modifiers
import Component from '@ember/component';
export default Component.extend({
classNames: ['component-box'],
})
import Component from '@glimmer/component';
export default class extends Component {
}
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@tracked
clicked = 0;
@tracked
lastElClickedClasses = '(null)';
@action
didClick({target}) {
this.lastElClickedClasses = target.getAttribute('class');
this.clicked++;
}
}
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.component-box {
width: 100px;
height: 100px;
border: 1px solid;
background: rgba(0,0,0,0.2);
padding: 0.5rem;
border-radius: 0.5rem;
display: inline-block;
}
[data-attribute] {
color: fuchsia;
}
<ClassicComponent
{{on 'click' this.didClick}}
data-attribute="true"
/>
<GlimmerComponent
{{on 'click' this.didClick}}
data-attribute="true"
/>
<p>{{this.lastElClickedClasses}} clicked, {{this.clicked}} total clicks</p>
<p class="classic-component-p">classic component</p>
<button class="classic-component-button">button</button>
<div class="component-box glimmer-component">
<p class="glimmer-component-p">glimmer component</p>
<button ...attributes class="glimmer-component-button">
button
</button>
</div>
{
"version": "0.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment