Skip to content

Commit

Permalink
Add FAST examples and support fast syntax property assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
Matsuuu committed Nov 8, 2023
1 parent a608b5b commit 4bf4173
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function resolveAttributeKind(attributeName: string, currentTag: string, textSpa
} as EventActionContext;
}

if (attributeName.startsWith(".")) {
if (attributeName.startsWith(".") || attributeName.startsWith(":")) {
return {
kind: ActionContextKind.PropertyName,
propertyName: attributeName.substring(1),
Expand Down
69 changes: 69 additions & 0 deletions usage-testing-project/src/fast-component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import {
FASTElement,
customElement,
attr,
observable,
Observable,

Check warning on line 6 in usage-testing-project/src/fast-component.ts

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused import

Unused import specifier Observable
html,
repeat
} from "@microsoft/fast-element";

const template = html<NameTag>`<div>
<h2>Hello!</h2>
<p>I am ${(x) => x.name}. I enjoy:</p>
<ul>
${repeat(
(x) => x.hobbies,
html`<li>
${(hobby) => {
return hobby;
}}
</li> `
)}
</ul>
<fast-button @click=${(x) => x.onDelete()}>Delete</fast-button>
</div>`;

@customElement({ name: "name-tag", template })
export class NameTag extends FASTElement {
@attr() name: string = "John Doe";

@attr() foo: string = "Bar";

/**
* Color of project card background and general theme
* */
@attr() color: string = "#000000";

@observable() data: any;

@observable() hobbies: string[] = ["1", "2", "3"];

connectedCallback() {
super.connectedCallback();
const test = ["test1", "test2", "test3"];
// this.hobbies = ["tom", "jerry", "dave"];
this.hobbies = test;
// const notifier = Observable.getNotifier(this.hobbies);
// const handler = {
// handleChange(source: any, splices: any) {
// console.log("WORKING", source, splices);
// // respond to the change here
// // source will be the array instance
// // splices will be an array of change records
// // describing the mutations in the array in
// // terms of splice operations
// }
// };
// notifier.subscribe(handler);
}

// hobbiesChanged() {
// console.log("changed hobbies", this.hobbies);
// }

public onDelete = () => {
this.hobbies.splice(0, 1);
};
}

8 changes: 8 additions & 0 deletions usage-testing-project/src/fast.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {
html
} from "@microsoft/fast-element";
import "./fast-component.js";

const temp = html`

Check warning on line 6 in usage-testing-project/src/fast.ts

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused local symbol

Unused constant temp
<name-tag :foo=""></name-tag>
`

0 comments on commit 4bf4173

Please sign in to comment.