Skip to content

Instantly share code, notes, and snippets.

View lstrrs's full-sized avatar

Luis Torres lstrrs

View GitHub Profile
@lstrrs
lstrrs / components.button\.js
Created May 22, 2023 23:53
contextComponent
import Component from '@glimmer/component';
export default class extends Component {
context = {
a: 1,
b:2
};
}
import Component from '@glimmer/component';
import { action } from '@ember/object';
export default class extends Component {
@action
click() {
console.log('Clicked: ', this.args.text);
}
}
@lstrrs
lstrrs / components.block\.js
Last active May 8, 2023 01:31
ComponentSpacingLayout
import Component from '@glimmer/component';
// Need to support auto and 0 as params
function getClassName(type, edge, unit) {
if (unit === '0') {
return '';
}
return `${type}${edge}-${unit}`;
@lstrrs
lstrrs / components.badge-outlet\.js
Last active July 26, 2022 22:22
Badge-in-element
import Component from '@glimmer/component';
import STEPS from '../steps';
export default class extends Component {
get destinationElement() {
return document.getElementById('badge-outlet');
}
get styles() {
const newDestinationElement = document.getElementById(`${STEPS[this.args.step]}-2`);
@lstrrs
lstrrs / controllers.application\.js
Last active September 15, 2020 22:11
Parent-child-click
import Controller from '@ember/controller';
import { set, action } from '@ember/object';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@action
onClickParent() {
console.log('Clicked Parent');
}
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class extends Component {
@tracked pos1 = 0;
@tracked pos2 = 0;
@tracked pos3 = 0;
@tracked pos4 = 0;
@lstrrs
lstrrs / components.my-component.js
Created September 10, 2019 19:31
aria-labelled-by
import Ember from 'ember';
export default Ember.Component.extend({
attributeBindings: [
'ariaLabelledBy:aria-labelled-by',
],
ariaLabelledBy: 'hello-world',
});
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['my-component', 'display-flex'],
classNameBindings: ['showComponent::hidden'],
isVisible: true,
showComponent: true,
actions: {
onClick() {
console.log('Hi');
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'button',
classNames: ['button']
});
@lstrrs
lstrrs / components.my-component.js
Created October 10, 2018 23:15
experiment-classNameBindingds
import Ember from 'ember';
import { computed } from '@ember/object';
export default Ember.Component.extend({
classNameBindings: [
'_isEdited',
],
_isEdited: computed('isEdited', function() {
return this.isEdited ? 'a b c' : '';