77import { html , css } from 'lit' ;
88import { customElement , property } from 'lit/decorators.js' ;
99import { unsafeHTML } from 'lit/directives/unsafe-html.js' ;
10- import { WCOPage } from './wco-page.js' ;
1110
1211import type { Package , Reference } from 'custom-elements-manifest/schema.js' ;
1312import {
@@ -16,6 +15,7 @@ import {
1615 resolveReference ,
1716 normalizeModulePath ,
1817} from '@webcomponents/custom-elements-manifest-tools' ;
18+ import { WCOPage } from './wco-page.js' ;
1919
2020export interface ElementData {
2121 packageName : string ;
@@ -31,11 +31,6 @@ export class WCOElementPage extends WCOPage {
3131 static styles = [
3232 WCOPage . styles ,
3333 css `
34- :host {
35- display: flex;
36- flex-direction: column;
37- }
38-
3934 .full-screen-error {
4035 display: flex;
4136 flex: 1;
@@ -44,15 +39,56 @@ export class WCOElementPage extends WCOPage {
4439 }
4540
4641 main {
42+ display: grid;
43+ max-width: var(--content-width);
4744 padding: 25px;
45+ gap: 1em;
46+ grid-template-areas:
47+ 'a a'
48+ 'b c';
49+ }
50+
51+ main > * {
52+ border: solid 1px gray;
53+ border-radius: 9px;
54+ }
55+
56+ header {
57+ display: flex;
58+ grid-area: a;
59+ gap: 1em;
60+ padding: 1em;
61+ }
62+
63+ #logo {
64+ aspect-ratio: 4/3;
65+ height: 160px;
66+ background: blue;
67+ border-radius: 5px;
68+ }
69+
70+ header h3 {
71+ text-overflow: ellipsis;
72+ height: 1em;
73+ }
74+
75+ #side-bar {
76+ grid-area: b;
77+ min-width: 200px;
78+ padding: 1em;
79+ }
80+
81+ #content {
82+ grid-area: c;
83+ padding: 1em;
4884 }
4985 ` ,
5086 ] ;
5187
5288 @property ( { attribute : false } )
5389 elementData ?: ElementData ;
5490
55- renderMain ( ) {
91+ renderContent ( ) {
5692 if ( this . elementData === undefined ) {
5793 return html `< div class ="full-screen-error "> No element to display</ div > ` ;
5894 }
@@ -84,26 +120,50 @@ export class WCOElementPage extends WCOPage {
84120 const fields = declaration . members ?. filter ( ( m ) => m . kind === 'field' ) ;
85121 const methods = declaration . members ?. filter ( ( m ) => m . kind === 'method' ) ;
86122
87- return html `
88- < h1 > ${ packageName } /${ elementName } </ h1 >
89- < h3 > ${ declaration . summary } </ h3 >
90-
91- < p > ${ unsafeHTML ( elementDescriptionHtml ) } </ p >
92-
93- < h2 > Usage</ h2 >
94- < pre > < code >
95- import '${ getElementImportSpecifier ( packageName , ceExportRef ) } ';
96- </ code > </ pre >
123+ // TODO (justinfagnani): We need a better way to make a summary from a
124+ // description, that's possibly markdown, word, and sentence boundary
125+ // aware.
126+ const summary =
127+ declaration . summary ?? declaration . description ?. substring ( 0 , 140 ) ?? '' ;
97128
98- < h2 > Fields</ h2 >
99- < ul >
100- ${ fields ?. map ( ( f ) => html `< li > ${ f . name } : ${ f . description } </ li > ` ) }
101- </ ul >
102-
103- < h2 > Methods</ h2 >
104- < ul >
105- ${ methods ?. map ( ( m ) => html `< li > ${ m . name } : ${ m . description } </ li > ` ) }
106- </ ul >
129+ return html `
130+ < header >
131+ < div id ="logo-container "> < div id ="logo "> </ div > </ div >
132+ < div id ="meta-container ">
133+ < span id ="package-meta "
134+ > ${ packageName } < select >
135+ <!-- TODO (justinfagnani): get actual version and dist tag data -->
136+ < option > x.x.x</ option >
137+ </ select > </ span
138+ >
139+ < h1 > <${ elementName } ></ h1 >
140+ < h3 > ${ summary } </ h3 >
141+ </ div >
142+ </ header >
143+ < div id ="side-bar ">
144+ < h3 id ="author "> [Author]</ h3 >
145+ < div > [Package Stats]</ div >
146+ < h3 > Install</ h3 >
147+ < code > npm install ${ packageName } </ code >
148+ </ div >
149+ < div id ="content ">
150+ < p > ${ unsafeHTML ( elementDescriptionHtml ) } </ p >
151+
152+ < h2 > Usage</ h2 >
153+ < pre > < code >
154+ import '${ getElementImportSpecifier ( packageName , ceExportRef ) } ';
155+ </ code > </ pre >
156+
157+ < h2 > Fields</ h2 >
158+ < ul >
159+ ${ fields ?. map ( ( f ) => html `< li > ${ f . name } : ${ f . description } </ li > ` ) }
160+ </ ul >
161+
162+ < h2 > Methods</ h2 >
163+ < ul >
164+ ${ methods ?. map ( ( m ) => html `< li > ${ m . name } : ${ m . description } </ li > ` ) }
165+ </ ul >
166+ </ div >
107167 ` ;
108168 }
109169}
0 commit comments