Skip to content

Commit

Permalink
Merge pull request #122 from aarondrabeck/css-property-types
Browse files Browse the repository at this point in the history
Adds parsing of type in js doc css property declaration.
  • Loading branch information
runem authored Nov 20, 2019
2 parents c3fe025 + 14feeb5 commit 4c91ba1
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion dev/src/custom-element/my-custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* @fires change - Dispatched when this element changes
* @slot - Default content placed in the body of this element
* @slot header - Content placed in the header of this element
* @cssprop --my-element-color - Controls the color of this element
* @cssprop {Color} --my-element-color - Controls the color of this element
* @cssprop {Length} --my-element-font-size - Controls the font-size in this element
*/
export class MyCustomElement extends HTMLElement {
/**
Expand Down
3 changes: 2 additions & 1 deletion src/analyze/flavors/js-doc/parse-declaration-css-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export function parseDeclarationCSSProps(node: Node, context: ParseComponentMemb
if (parsed.name != null) {
return {
name: parsed.name,
jsDoc: parsed.comment != null ? { comment: parsed.comment } : undefined
jsDoc: parsed.comment != null ? { comment: parsed.comment } : undefined,
type: parsed.type
} as ComponentCSSProperty;
}
},
Expand Down
1 change: 1 addition & 0 deletions src/analyze/types/component-css-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { JsDoc } from "./js-doc";
export interface ComponentCSSProperty {
name: string;
jsDoc?: JsDoc;
type?: string;
}
5 changes: 4 additions & 1 deletion src/cli/transformer/json/custom-elements-json-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export interface HtmlDataSlot extends HtmlDataMember {}

export interface HtmlDataEvent extends HtmlDataMember {}

export interface HtmlDataCssProperty extends HtmlDataMember {}
export interface HtmlDataCssProperty extends HtmlDataMember {
// Suggested fields:
type?: string;
}

export interface HtmlDataCssPart extends HtmlDataMember {}

Expand Down
3 changes: 2 additions & 1 deletion src/cli/transformer/json/json-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ function componentCssPropToHtmlCssProp(prop: ComponentCSSProperty, checker: Type
return {
name: prop.name || "",
description: getDescriptionFromJsDoc(prop.jsDoc),
jsDoc: getJsDocTextFromJsDoc(prop.jsDoc)
jsDoc: getJsDocTextFromJsDoc(prop.jsDoc),
type: prop.type
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Generated by [AVA](https://ava.li).
comment: 'Transition of an item.',
},
name: '--masonry-layout-item-transition',
type: undefined,
},
],
events: [],
Expand Down Expand Up @@ -243,6 +244,7 @@ Generated by [AVA](https://ava.li).
comment: 'Transition of an item.',
},
name: '--masonry-layout-item-transition',
type: undefined,
},
],
events: [],
Expand Down
Binary file not shown.

0 comments on commit 4c91ba1

Please sign in to comment.