Skip to content

Commit

Permalink
[Chore]: Create Spinner base class to abstract out style and layout s…
Browse files Browse the repository at this point in the history
…pecific api. (#32067)
  • Loading branch information
eljefe223 authored Jul 23, 2024
1 parent 60952ac commit 970bf5c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "chore: create base class for spinner and remove style and layout specfic api",
"packageName": "@fluentui/web-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
12 changes: 8 additions & 4 deletions packages/web-components/docs/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,13 @@ export class BaseProgressBar extends FASTElement {
protected valueChanged(prev: number | undefined, next: number | undefined): void;
}

// @public
export class BaseSpinner extends FASTElement {
constructor();
// @internal
elementInternals: ElementInternals;
}

// @public
export const borderRadiusCircular = "var(--borderRadiusCircular)";

Expand Down Expand Up @@ -3095,12 +3102,9 @@ export const spacingVerticalXXS = "var(--spacingVerticalXXS)";
export const spacingVerticalXXXL = "var(--spacingVerticalXXXL)";

// @public
export class Spinner extends FASTElement {
constructor();
export class Spinner extends BaseSpinner {
appearance?: SpinnerAppearance;
appearanceChanged(prev: SpinnerAppearance | undefined, next: SpinnerAppearance | undefined): void;
// @internal
elementInternals: ElementInternals;
size?: SpinnerSize;
sizeChanged(prev: SpinnerSize | undefined, next: SpinnerSize | undefined): void;
}
Expand Down
1 change: 1 addition & 0 deletions packages/web-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export {
} from './slider/index.js';
export type { SliderConfiguration, SliderOptions } from './slider/index.js';
export {
BaseSpinner,
Spinner,
SpinnerAppearance,
SpinnerDefinition,
Expand Down
2 changes: 1 addition & 1 deletion packages/web-components/src/spinner/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { Spinner } from './spinner.js';
export { BaseSpinner, Spinner } from './spinner.js';
export { SpinnerAppearance, SpinnerSize } from './spinner.options.js';
export { template as SpinnerTemplate } from './spinner.template.js';
export { styles as SpinnerStyles } from './spinner.styles.js';
Expand Down
20 changes: 14 additions & 6 deletions packages/web-components/src/spinner/spinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,27 @@ import type { SpinnerAppearance, SpinnerSize } from './spinner.options.js';
* The base class used for constructing a fluent-spinner custom element
* @public
*/
export class Spinner extends FASTElement {
export class BaseSpinner extends FASTElement {
/**
* The internal {@link https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
*
* @internal
*/
public elementInternals: ElementInternals = this.attachInternals();

constructor() {
super();
this.elementInternals.role = 'progressbar';
}
}

/**
* A Spinner Custom HTML Element.
* Based on BaseSpinner and includes style and layout specific attributes
*
* @public
*/
export class Spinner extends BaseSpinner {
/**
* The size of the spinner
*
Expand Down Expand Up @@ -60,9 +73,4 @@ export class Spinner extends FASTElement {
toggleState(this.elementInternals, `${next}`, true);
}
}

constructor() {
super();
this.elementInternals.role = 'progressbar';
}
}

0 comments on commit 970bf5c

Please sign in to comment.