Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to the cheat sheet for the Octane launch #19

Merged
merged 11 commits into from
Dec 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/constructors/classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import Component from '@ember/component';
export default Component.extend({
init() {
this._super(...arguments)
this.set('bestActor', "Milo")
this.set('answer', 42)
}
});
4 changes: 2 additions & 2 deletions code/constructors/octane.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Component from '@glimmer/component';

export default class SomeComponent extends Component {
constructor() {
super();
this.bestActor = 'Milo';
super(...arguments);
this.answer = 42;
}
}
5 changes: 5 additions & 0 deletions code/ddau/classic-child.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{!-- child-component.hbs --}}

<button {{action "plusOne"}}>
Click Me
</button>
12 changes: 12 additions & 0 deletions code/ddau/classic-child.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// child-component.js

import Component from '@ember/component';

export default Component.extend({
actions: {
plusOne() {
let count = this.get("count");
this.set("count", count)
}
}
});
3 changes: 3 additions & 0 deletions code/ddau/classic-parent.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{!-- parent-component.hbs --}}
{{child-component count=count}}
Count: {{this.count}}
6 changes: 6 additions & 0 deletions code/ddau/classic-parent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// parent-component.js
import Component from '@ember/component';

export default Component.extend({
count: 0
});
5 changes: 5 additions & 0 deletions code/ddau/octane-child.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{!-- child-component.hbs --}}

<button {{on "click" @plusOne}}>
Click Me
</button>
4 changes: 4 additions & 0 deletions code/ddau/octane-parent.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{!-- parent-component.hbs --}}

<ChildComponent @plusOne={{this.plusOne}} />
Count: {{this.count}}
13 changes: 13 additions & 0 deletions code/ddau/octane-parent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// parent-component.js
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';

export default class ParentComponent extends Component {
@tracked count = 0;

@action
plusOne() {
this.count += 1;
}
}
8 changes: 8 additions & 0 deletions code/element-id/classic.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="form-group">
<label for="textInput-{{elementId}}">{{inputLabelText}}</label>
<input
id="textInput-{{elementId}}"
name={{inputName}}
type="text"
/>
</div>
7 changes: 7 additions & 0 deletions code/element-id/classic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Component from '@ember/component';

export default Component.extend({
didInsertElement() {
console.log("Elememt id ", this.elementId)
}
});
8 changes: 8 additions & 0 deletions code/element-id/octane.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="form-group">
<label for={{this.inputId}}>{{@inputLabelText}}</label>
<input
id={{this.inputId}}
name={{@inputName}}
type="text"
/>
</div>
6 changes: 6 additions & 0 deletions code/element-id/octane.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Component from '@glimmer/component';
import { guidFor } from '@ember/object/internals';

export default class InputTextComponent extends Component {
inputId = 'textInput-' + guidFor(this);
jenweber marked this conversation as resolved.
Show resolved Hide resolved
}
6 changes: 6 additions & 0 deletions code/file-structure/classic.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
app/
components/
my-component.js
templates/
components/
my-component.hbs
5 changes: 5 additions & 0 deletions code/file-structure/octane.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
app/
components/
my-component.js
my-component.hbs

1 change: 1 addition & 0 deletions code/generating-component/classic.shell
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ember generate component
8 changes: 8 additions & 0 deletions code/generating-component/octane.shell
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -gc stands for glimmer component
ember generate component my-component -gc

# -cc stands for classic component
ember generate component my-component -cc

# See the full set of options with this:
ember generate component --help
12 changes: 12 additions & 0 deletions code/get-and-set/classic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// child-component.js

import Component from '@ember/component';

export default Component.extend({
count: 0,
actions: {
minusOne() {
this.set("count", this.count - 1)
}
}
});
12 changes: 12 additions & 0 deletions code/get-and-set/octane.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';

export default class SomeComponent extends Component {
@tracked count = 0;

@action
minusOne() {
this.count = this.count - 1
}
}
2 changes: 0 additions & 2 deletions code/js-boilerplate/classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ import Component from '@ember/component';
export default Component.extend({
init() {
this._super(...arguments);

// initialize
},
});
4 changes: 2 additions & 2 deletions code/js-properties/classic.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Component from '@ember/component';

export default Component.extend({
fireNation: 'Zuko',
airNation: 'Tenzen',
min: 0,
max: 100,
});
4 changes: 2 additions & 2 deletions code/js-properties/octane.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Component from '@glimmer/component';

export default class SomeComponent extends Component {
fireNation = 'Zuko';
airNation = 'Tenzen';
min = 0;
max = 100;
}
6 changes: 6 additions & 0 deletions code/mixins/classic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Component from '@ember/component';
import SomeMixin from 'some-addon';

export default Component.extend(SomeMixin, {
// ...
});
1 change: 1 addition & 0 deletions code/model-access/classic.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
First name: {{model.firstName}}
1 change: 1 addition & 0 deletions code/model-access/octane.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
First name: {{@model.firstName}}
4 changes: 2 additions & 2 deletions code/template-arguments-default/classic.handlebars
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{my-component avatar=avatar}}
{{my-component answer=answer}}

<!-- my-component's template -->
{{avatar}}
{{answer}}
2 changes: 1 addition & 1 deletion code/template-arguments-default/classic.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from '@ember/component';

export default Component.extend({
avatar: 'default',
answer: 42,
});
4 changes: 2 additions & 2 deletions code/template-arguments-default/octane.handlebars
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<MyComponent @avatar={{this.avatar}} />
<MyComponent @answer={{this.answer}} />

<!-- my-component's template -->
{{this.avatar}}
{{this.answer}}
4 changes: 2 additions & 2 deletions code/template-arguments-default/octane.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Component from '@glimmer/component';

export default class MyComponent extends Component {
get avatar() {
return this.args.avatar || 'default';
get answer() {
return this.args.answer || 42;
}
}
2 changes: 1 addition & 1 deletion code/template-arguments-named/classic.handlebars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{my-component avatar="aang"}}
{{my-component answer=42}}
2 changes: 1 addition & 1 deletion code/template-arguments-named/octane.handlebars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<MyComponent @avatar="aang" />
<MyComponent @answer={{42}} />
2 changes: 1 addition & 1 deletion code/template-arguments-this/classic.handlebars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{my-component avatar=avatar}}
{{my-component answer=answer}}
2 changes: 1 addition & 1 deletion code/template-arguments-this/octane.handlebars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<MyComponent @avatar={{this.avatar}} />
<MyComponent @answer={{this.answer}} />
2 changes: 1 addition & 1 deletion code/template-named/classic.handlebars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{avatar}} is the master of all four elements.
{{answer}} is the answer.
2 changes: 1 addition & 1 deletion code/template-named/octane.handlebars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{@avatar}} is the master of all four elements.
{{@answer}} is the answer.
2 changes: 1 addition & 1 deletion code/template-this/classic.handlebars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{bestEpisode}} is my favorite
{{answer}} is the answer.
2 changes: 1 addition & 1 deletion code/template-this/octane.handlebars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{this.bestEpisode}} is my favorite
{{this.answer}} is the answer.
Loading