Skip to content

Commit

Permalink
Merge branch 'master' into users/janechu/remove-fast-route-for-produc…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
janechu authored Aug 16, 2024
2 parents 476560f + 92e82f7 commit 66db2df
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 14 deletions.
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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"apiReport": {
"enabled": true,
"reportFolder": "<projectFolder>/docs/context",
"reportFileName": "api-report.md"
"reportFileName": "api-report"
},
"docModel": {
"enabled": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/web-components/fast-element/api-extractor.di.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"apiReport": {
"enabled": true,
"reportFolder": "<projectFolder>/docs/di",
"reportFileName": "api-report.md"
"reportFileName": "api-report"
},
"docModel": {
"enabled": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const Context: Readonly<{
// @public
export type ContextCallback<ValueType> = (value: ValueType, dispose?: () => void) => void;

// Warning: (ae-forgotten-export) The symbol "ParameterDecorator" needs to be exported by the entry point context.d.ts
// Warning: (ae-forgotten-export) The symbol "ParameterDecorator_2" needs to be exported by the entry point context.d.ts
//
// @public
export type ContextDecorator<T = any> = Readonly<Context<T>> & PropertyDecorator & ParameterDecorator_2;
Expand Down
2 changes: 1 addition & 1 deletion sites/website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = {
},
items: [
"advanced/working-with-custom-elements",
"advanced/component-libraries",
"advanced/working-without-decorators",
"advanced/dependency-injection",
],
},
Expand Down
9 changes: 0 additions & 9 deletions sites/website/src/docs/advanced/component-libraries.md

This file was deleted.

90 changes: 90 additions & 0 deletions sites/website/src/docs/advanced/working-without-decorators.md
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);
```
2 changes: 1 addition & 1 deletion sites/website/src/docs/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ Here's an example starter `taconfig.json` that you can use:
"target": "ES2015",
"module": "ES2015",
"moduleResolution": "node",
"importHelpers": true,
"importHelpers": true, // when using decorators this allows for the smallest footprint using tslib
"experimentalDecorators": true,
"declaration": true,
"declarationMap": true,
Expand Down

0 comments on commit 66db2df

Please sign in to comment.