Skip to content

Commit d6a0c3d

Browse files
janechuCopilot
andcommitted
fix(docs): update css imports and migration guide APIs in 3.x docs
- Update css imports from '@microsoft/fast-element' to '@microsoft/fast-element/styles.js' across 5 doc files - Replace ElementController.configHydration() with enableHydration() - Replace ElementHydrationCallbacks with HydrationOptions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 110c4a6 commit d6a0c3d

6 files changed

Lines changed: 20 additions & 11 deletions

File tree

sites/website/src/docs/3.x/advanced/working-with-custom-elements.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ const template = html<MyProgress>`
6666

6767
**Example:**
6868
```ts
69-
import { attr, css, FASTElement } from '@microsoft/fast-element';
69+
import { attr, FASTElement } from '@microsoft/fast-element';
70+
import { css } from "@microsoft/fast-element/styles.js";
7071

7172
class MyComponent extends FASTElement {
7273
private dynamicCSS = css`
@@ -99,7 +100,8 @@ class MyComponent extends FASTElement {
99100
For external signals such as [matchMedia()](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia), keep the listener on the element and toggle a separate stylesheet through the same controller APIs. `css` templates stay static, so move runtime conditions into the element rather than binding them inside the stylesheet:
100101

101102
```ts
102-
import { css, FASTElement } from "@microsoft/fast-element";
103+
import { FASTElement } from "@microsoft/fast-element";
104+
import { css } from "@microsoft/fast-element/styles.js";
103105

104106
const darkStyles = css`
105107
:host {

sites/website/src/docs/3.x/advanced/working-without-decorators.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Most of our documented examples include the use of TypeScript decorators. Howeve
1717
When defining your component, you may pass in attributes in the same configuration object as the name, template, and styles:
1818

1919
```javascript
20-
import { FASTElement, html, css } from '@microsoft/fast-element';
20+
import { FASTElement, html } from '@microsoft/fast-element';
21+
import { css } from "@microsoft/fast-element/styles.js";
2122

2223
export class MyElement extends FASTElement {
2324
// component logic
@@ -38,7 +39,8 @@ MyElement.define({
3839
This accepts the same configuration options as the `@attr` so for example to bind a property name that is different from an attribute name:
3940

4041
```javascript
41-
import { FASTElement, html, css } from '@microsoft/fast-element';
42+
import { FASTElement, html } from '@microsoft/fast-element';
43+
import { css } from "@microsoft/fast-element/styles.js";
4244

4345
export class MyElement extends FASTElement {
4446
constructor() {
@@ -71,7 +73,8 @@ In the above example we are setting the `currentCount` in the constructor and no
7173
If you need to add a converter to your attribute:
7274

7375
```javascript
74-
import { FASTElement, html, css } from '@microsoft/fast-element';
76+
import { FASTElement, html } from '@microsoft/fast-element';
77+
import { css } from "@microsoft/fast-element/styles.js";
7578

7679
const converter = {
7780
toView: (value) => {

sites/website/src/docs/3.x/declarative-templates/defining-elements.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ my-app/
7575
**`main.ts`:**
7676

7777
```ts
78-
import { FASTElement, attr, css, observable } from "@microsoft/fast-element";
78+
import { FASTElement, attr, observable } from "@microsoft/fast-element";
79+
import { css } from "@microsoft/fast-element/styles.js";
7980
import { declarativeTemplate } from "@microsoft/fast-element/declarative.js";
8081

8182
class TaskItem extends FASTElement {

sites/website/src/docs/3.x/getting-started/css-templates.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ The `@microsoft/fast-element` package offers a named export `css` which is a [ta
2020

2121
**Example:**
2222
```ts
23-
import { FASTElement, attr, css, html } from '@microsoft/fast-element';
23+
import { FASTElement, attr, html } from '@microsoft/fast-element';
24+
import { css } from "@microsoft/fast-element/styles.js";
2425

2526
const template = html`
2627
<span>${x => x.greeting.toUpperCase()}</span>

sites/website/src/docs/3.x/getting-started/quick-start.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ A web component created using FAST is comprised of 3 parts, the HTML template, t
2727

2828
To start, let's create a simple web component that combines all the necessary parts:
2929
```typescript
30-
import { attr, css, FASTElement, html } from "@microsoft/fast-element";
30+
import { attr, FASTElement, html } from "@microsoft/fast-element";
31+
import { css } from "@microsoft/fast-element/styles.js";
3132

3233
/**
3334
* Create an HTML template using the html tag template literal,

sites/website/src/docs/3.x/migration-guide.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ The `KernelServiceId` enum (used with `FAST.getById()`) has been removed. Import
251251

252252
2.x Example:
253253
```ts
254-
import { css, ElementStyles } from "@microsoft/fast-element";
254+
import { ElementStyles } from "@microsoft/fast-element";
255+
import { css } from "@microsoft/fast-element/styles.js";
255256
```
256257

257258
3.x Example:
@@ -313,8 +314,8 @@ The `HydrationMarkup` API methods have been renamed (e.g., `parseAttributeBindin
313314
|---|---|---|
314315
| `ElementController.isPrerendered` | `fast-element` | `Promise<boolean>` — resolves `true` when element had DSD at connect time |
315316
| `ElementController.isHydrated` | `fast-element` | `Promise<boolean>` — resolves `true` only when hydration ran successfully |
316-
| `ElementController.configHydration()` | `fast-element` | Registers hydration lifecycle callbacks |
317+
| `enableHydration()` | `fast-element/hydration.js` | Enables hydration support for FAST elements |
317318
| `HydrationTracker` | `fast-element` | Standalone hydration lifecycle tracker class |
318-
| `ElementHydrationCallbacks` | `fast-element` | Type for hydration lifecycle callbacks |
319+
| `HydrationOptions` | `fast-element/hydration.js` | Type for hydration configuration options |
319320
| `ViewController.isPrerendered` | `fast-element` | `Promise<boolean>` — DSD detection for custom directives |
320321
| `ViewController.isHydrated` | `fast-element` | `Promise<boolean>` — hydration status for custom directives |

0 commit comments

Comments
 (0)