-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into users/janechu/remove-fast-route-for-produc…
…tion
- Loading branch information
Showing
9 changed files
with
102 additions
and
14 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@microsoft-fast-element-ffdf0a73-daa4-462a-bc2f-60a25ce2066f.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "Add working with decorators doc and updated api-report markdown", | ||
"packageName": "@microsoft/fast-element", | ||
"email": "7559015+janechu@users.noreply.github.com", | ||
"dependentChangeType": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
90 changes: 90 additions & 0 deletions
90
sites/website/src/docs/advanced/working-without-decorators.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
id: working-without-decorators | ||
title: Working without Decorators | ||
sidebar_label: Working without Decorators | ||
keywords: | ||
- decorators | ||
--- | ||
|
||
Most of our documented examples include the use of TypeScript decorators. However, as decorators are an unimplemented feature in JavaScript, using them may not be right for your project. See [TypeScript documentation](https://www.typescriptlang.org/docs/handbook/decorators.html) for details on our implementation. | ||
|
||
The static `definition` accepts the same configuration options as the `@attr` decorator. For example, to bind a property name that is different from an attribute name: | ||
|
||
```javascript | ||
import { FASTElement, html, css } from '@microsoft/fast-element'; | ||
|
||
export class MyElement extends FASTElement { | ||
static definition = { | ||
name: 'my-element', | ||
template: html`<div>${(x) => x.count}</div>`, | ||
styles: css`div { background: red }`, | ||
attributes: [ | ||
'count', | ||
], | ||
}; | ||
} | ||
|
||
FASTElement.define(MyElement); | ||
``` | ||
|
||
```html | ||
<my-element count="42"> | ||
``` | ||
|
||
This accepts the same configuration options as the `@attr` so for example to bind a property name that is different from an attribute name: | ||
|
||
```javascript | ||
import { FASTElement, html, css } from '@microsoft/fast-element'; | ||
|
||
export class MyElement extends FASTElement { | ||
static definition = { | ||
name: 'my-element', | ||
template: html`<div>${(x) => x.currentCount}</div>`, | ||
styles: css`div { background: red }`, | ||
attributes: [ | ||
{ | ||
attribute: 'current-count', | ||
property: 'currentCount' | ||
}, | ||
], | ||
}; | ||
|
||
currentCount = 42; | ||
} | ||
|
||
FASTElement.define(MyElement); | ||
``` | ||
|
||
If you need to add a converter to your attribute: | ||
|
||
```javascript | ||
import { FASTElement, html, css } from '@microsoft/fast-element'; | ||
|
||
const converter = { | ||
toView: (value) => { | ||
return value / 2; | ||
}, | ||
fromView: (value) => { | ||
return value / 2; | ||
}, | ||
}; | ||
|
||
export class MyElement extends FASTElement { | ||
static definition = { | ||
name: 'my-element', | ||
template: html`<div>${(x) => x.currentCount}</div>`, | ||
styles: css`div { background: red }`, | ||
attributes: [ | ||
{ | ||
attribute: 'current-count', | ||
property: 'currentCount', | ||
converter | ||
}, | ||
], | ||
}; | ||
|
||
currentCount = 42; | ||
} | ||
|
||
FASTElement.define(MyElement); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters