Skip to content

Commit

Permalink
remove component enums in favor of const objects (#5930)
Browse files Browse the repository at this point in the history
* convert enums to const objects

* convert component class enums to const objects and add supported types

* Change files

* convert orientation enum to const object with corresponding type

* Change files

* Fixed variable type formatting (#5931)

Co-authored-by: William Wagner <[email protected]>
  • Loading branch information
chrisdholt and williamw2 authored May 3, 2022
1 parent 1b07260 commit d392841
Show file tree
Hide file tree
Showing 46 changed files with 656 additions and 405 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "convert enums to const objects and add supported typings",
"packageName": "@microsoft/fast-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "convert enums to const objects and add supported typings",
"packageName": "@microsoft/fast-foundation",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "convert orientation enum to const object with corresponding type",
"packageName": "@microsoft/fast-web-utilities",
"email": "[email protected]",
"dependentChangeType": "patch"
}
16 changes: 12 additions & 4 deletions packages/utilities/fast-web-utilities/src/aria.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
export enum Orientation {
horizontal = "horizontal",
vertical = "vertical",
}
/**
* Standard orientation values
*/
export const Orientation = {
horizontal: "horizontal",
vertical: "vertical",
} as const;

/**
* The orientation type
*/
export type Orientation = typeof Orientation[keyof typeof Orientation];
13 changes: 7 additions & 6 deletions packages/web-components/fast-components/docs/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -1756,12 +1756,13 @@ export const sliderLabelStyles: FoundationElementTemplate<ElementStyles>;
export const sliderStyles: FoundationElementTemplate<ElementStyles, SliderOptions>;

// @public
export enum StandardLuminance {
// (undocumented)
DarkMode = 0.23,
// (undocumented)
LightMode = 1
}
export const StandardLuminance: {
readonly LightMode: 1;
readonly DarkMode: 0.23;
};

// @public
export type StandardLuminance = typeof StandardLuminance[keyof typeof StandardLuminance];

// @public (undocumented)
export const strokeWidth: CSSDesignToken<number>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ export function baseLayerLuminanceSwatch(luminance: number) {
*
* @public
*/
export enum StandardLuminance {
LightMode = 1,
DarkMode = 0.23,
}
export const StandardLuminance = {
LightMode: 1,
DarkMode: 0.23,
} as const;

/**
* Types of recommended values for light and dark mode for {@link @microsoft/fast-components#baseLayerLuminance}.
*
* @public
*/
export type StandardLuminance = typeof StandardLuminance[keyof typeof StandardLuminance];
32 changes: 20 additions & 12 deletions packages/web-components/fast-foundation/CEMToMarkdown.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ for(var i = 0, modulesLength = modules.length; i < modulesLength; i++)
{
dec.default = replaceJSDOCLinksWithMDLinks(fixTagsInText(dec.default.replaceAll(LF, ' ')));
}
if(dec.type)
{
dec.type.text = replaceJSDOCLinksWithMDLinks(fixTagsInText(dec.type.text.replaceAll(LF, ' ')));
}
dec.members?.forEach(member=>{
if(member.description)
{
Expand Down Expand Up @@ -197,18 +201,22 @@ function replaceJSDOCLinksWithMDLinks(text)
let startIndex = text.indexOf('{@link');
if(startIndex < 0) return text;

let endIndex = text.indexOf("}", startIndex);
if(endIndex < 0) return text;

const jsdocLink = text.slice(startIndex, endIndex + 1);
let linkParts = jsdocLink.replace("{@link ", "").replace("}", "").split('|');
if(linkParts.length === 1)
while(startIndex>=0)
{
return text.replace(jsdocLink, linkParts[0]);
}
else
{
return text.replace(jsdocLink, "[" + linkParts[1].trim() + "](" + linkParts[0].trim() + ")");
}
let endIndex = text.indexOf("}", startIndex);
if(endIndex < 0) return text;

const jsdocLink = text.slice(startIndex, endIndex + 1);
let linkParts = jsdocLink.replace("{@link ", "").replace("}", "").split('|');
if(linkParts.length === 1)
{
text = text.replace(jsdocLink, linkParts[0]);
}
else
{
text = text.replace(jsdocLink, "[" + linkParts[1].trim() + "](" + linkParts[0].trim() + ")");
}
startIndex = text.indexOf('{@link',endIndex);
}
return text;
}
Loading

0 comments on commit d392841

Please sign in to comment.