7
7
import { html , css } from 'lit' ;
8
8
import { customElement , property } from 'lit/decorators.js' ;
9
9
import { unsafeHTML } from 'lit/directives/unsafe-html.js' ;
10
- import { WCOPage } from './wco-page.js' ;
11
10
12
11
import type { Package , Reference } from 'custom-elements-manifest/schema.js' ;
13
12
import {
@@ -16,6 +15,7 @@ import {
16
15
resolveReference ,
17
16
normalizeModulePath ,
18
17
} from '@webcomponents/custom-elements-manifest-tools' ;
18
+ import { WCOPage } from './wco-page.js' ;
19
19
20
20
export interface ElementData {
21
21
packageName : string ;
@@ -31,11 +31,6 @@ export class WCOElementPage extends WCOPage {
31
31
static styles = [
32
32
WCOPage . styles ,
33
33
css `
34
- :host {
35
- display: flex;
36
- flex-direction: column;
37
- }
38
-
39
34
.full-screen-error {
40
35
display: flex;
41
36
flex: 1;
@@ -44,15 +39,56 @@ export class WCOElementPage extends WCOPage {
44
39
}
45
40
46
41
main {
42
+ display: grid;
43
+ max-width: var(--content-width);
47
44
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;
48
84
}
49
85
` ,
50
86
] ;
51
87
52
88
@property ( { attribute : false } )
53
89
elementData ?: ElementData ;
54
90
55
- renderMain ( ) {
91
+ renderContent ( ) {
56
92
if ( this . elementData === undefined ) {
57
93
return html `< div class ="full-screen-error "> No element to display</ div > ` ;
58
94
}
@@ -84,26 +120,50 @@ export class WCOElementPage extends WCOPage {
84
120
const fields = declaration . members ?. filter ( ( m ) => m . kind === 'field' ) ;
85
121
const methods = declaration . members ?. filter ( ( m ) => m . kind === 'method' ) ;
86
122
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 ) ?? '' ;
97
128
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 >
107
167
` ;
108
168
}
109
169
}
0 commit comments