File tree Expand file tree Collapse file tree 14 files changed +268
-37
lines changed Expand file tree Collapse file tree 14 files changed +268
-37
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ jspm_packages/
26
26
.next
27
27
.nuxt
28
28
dist
29
+ build
29
30
.cache /
30
31
.vuepress /dist
31
32
.serverless /
Original file line number Diff line number Diff line change 1
1
{
2
- "eslint.experimental. useFlatConfig" : true ,
2
+ "eslint.useFlatConfig" : true ,
3
3
"eslint.options" : { "overrideConfigFile" : " ./config/eslint.config.mjs" },
4
4
}
Original file line number Diff line number Diff line change @@ -9,4 +9,11 @@ npm install
9
9
Development mode,
10
10
11
11
``` bash
12
- npm run dev
12
+ npm run dev
13
+ ```
14
+
15
+ Build,
16
+
17
+ ``` bash
18
+ npm run build
19
+ ```
Original file line number Diff line number Diff line change
1
+ import esbuild from 'esbuild' ;
2
+
3
+ const commonOptions = {
4
+ outdir : 'dist' ,
5
+ format : 'esm' ,
6
+ bundle : true ,
7
+ loader : {
8
+ '.svg' : 'file' ,
9
+ '.woff' : 'file' ,
10
+ '.woff2' : 'file' ,
11
+ '.ttf' : 'file' ,
12
+ '.otf' : 'file' ,
13
+ '.html' : 'copy' ,
14
+ '.json' : 'copy' ,
15
+ } ,
16
+ logLevel : 'info' ,
17
+ entryPoints : [ ] ,
18
+ } ;
19
+
20
+ // Add the table
21
+ commonOptions . entryPoints . push ( 'example/table/index.js' , 'example/table/index.html' ) ;
22
+
23
+ // Build the table, and optionally serve it in development
24
+ if ( process . env . NODE_ENV === 'production' ) {
25
+ await esbuild . build ( {
26
+ ...commonOptions ,
27
+ minify : true ,
28
+ sourcemap : false ,
29
+ } ) . catch ( ( ) => process . exit ( 1 ) ) ;
30
+ } else if ( process . env . NODE_ENV === 'development' ) {
31
+ let ctx = await esbuild . context ( {
32
+ ...commonOptions ,
33
+ minify : false ,
34
+ sourcemap : true ,
35
+ } )
36
+ let { host, port } = await ctx . serve ( {
37
+ servedir : commonOptions . outdir ,
38
+ } ) ;
39
+ await ctx . watch ( ) ;
40
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+
4
+ < head >
5
+ < meta charset ="utf-8 ">
6
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7
+ < title > Nanoradio</ title >
8
+ < script type ="module " src ="index.js " defer > </ script >
9
+ < link href ="index.css " rel ="stylesheet ">
10
+ < style type ="text/css ">
11
+ .content-scroll {
12
+ overflow-y : scroll;
13
+ }
14
+ body {
15
+ overflow : hidden;
16
+ }
17
+ </ style >
18
+ </ head >
19
+
20
+ < body >
21
+ < js-canvas >
22
+ < js-nav >
23
+ < js-navitem > Home</ js-navitem >
24
+ </ js-nav >
25
+ < js-content class ="content-scroll ">
26
+ < js-table id ="items-table " data ="#items-data ">
27
+ <!-- Table columns -->
28
+ < js-itemcol name ="title "> </ js-itemcol >
29
+
30
+ <!-- Hide other columns by default -->
31
+ < js-tablecol hidden > </ js-tablecol >
32
+ </ js-table >
33
+ </ js-content >
34
+ < js-nav >
35
+ <!-- data source and model for items -->
36
+ < js-provider id ="items-provider " path ="http://cm5.lan:8000/feed/v1/document?limit=50 "> </ js-provider >
37
+ < js-array id ="items-data " provider ="#items-provider " select ="body "> </ js-array >
38
+ </ js-nav >
39
+ </ js-canvas >
40
+ </ body >
41
+
42
+ </ html >
Original file line number Diff line number Diff line change
1
+ // This file defines all the styles and elements used for the web components
2
+ import '../../src/index' ;
3
+ import './item.js'
4
+
5
+ /* Code to reload in the esbuild serve development environment */
6
+ window . addEventListener ( 'load' , ( ) => {
7
+ // eslint-disable-next-line no-restricted-globals
8
+ new EventSource ( '/esbuild' ) . addEventListener ( 'change' , ( ) => location . reload ( ) ) ;
9
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { html } from 'lit' ;
2
+ import { TableColumnElement } from '../../src/element/TableColumnElement' ;
3
+
4
+ export class ItemColumn extends TableColumnElement {
5
+ static get localName ( ) {
6
+ return 'js-itemcol' ;
7
+ }
8
+
9
+ // eslint-disable-next-line class-methods-use-this
10
+ #text( value , key ) {
11
+ return value instanceof Object ? value [ key ] : value ;
12
+ }
13
+
14
+ render ( value , key ) {
15
+ const cell = value instanceof Object ? value [ key ] : value ;
16
+ switch ( key ) {
17
+ case 'title' :
18
+ return html `
19
+ < div style ="padding: 5px; ">
20
+ < js-tag size ="small "> ${ this . #text( value , 'author' ) } </ js-tag >
21
+ < h4 > ${ this . #text( value , 'title' ) } </ h4 >
22
+ < small > < strong > ${ this . #text( value , 'pubdate' ) } </ strong > </ small >
23
+ < p > ${ this . #text( value , 'desc' ) } </ p >
24
+ ${ value . media ? this . #renderAudio( value . media [ 0 ] ) : '' }
25
+ </ div >
26
+ ` ;
27
+ default :
28
+ }
29
+ return html `${ cell } ` ;
30
+ }
31
+
32
+ // eslint-disable-next-line class-methods-use-this
33
+ #renderAudio( media ) {
34
+ return html `
35
+ < audio controls >
36
+ < source src ="${ media . url } " type ="${ media . type } ">
37
+ Your browser does not support the audio element.
38
+ </ audio >
39
+ ` ;
40
+ }
41
+ }
42
+
43
+ customElements . define ( ItemColumn . localName , ItemColumn ) ; // js-itemcol
Original file line number Diff line number Diff line change 4
4
"description" : " Javascript Framework" ,
5
5
"main" : " dist/index.js" ,
6
6
"scripts" : {
7
- "geojson- dev" : " rm -fr dist && install -d dist && NODE_ENV=development node config/esbuild.geojson .mjs" ,
8
- "build" : " rm -fr dist && install -d dist && NODE_ENV=production node config/ esbuild.geojson .mjs" ,
7
+ "dev" : " NODE_ENV=development node config/esbuild.table .mjs" ,
8
+ "build" : " rm -fr dist && install -d dist && NODE_ENV=production node esbuild.table .mjs" ,
9
9
"lint" : " ESLINT_USE_FLAT_CONFIG=true eslint -c config/eslint.config.mjs --cache --fix ./src/**/*.js" ,
10
10
"docs" : " jsdoc -c config/jsdoc.config.json"
11
11
},
Original file line number Diff line number Diff line change
1
+ import { LitElement , html } from 'lit' ;
2
+
3
+ /**
4
+ * @class TableColumnElement
5
+ *
6
+ * This class provides a table column element, for rendering
7
+ * a table cell. It also provides properties for the column.
8
+ * The name property is used to identify the column in the
9
+ * table, and the hidden property is used to hide the column.
10
+ *
11
+ * @example
12
+ * <js-tablecol name="id">ID</js-tablecol>
13
+ */
14
+ export class TableColumnElement extends LitElement {
15
+ static get localName ( ) {
16
+ return 'js-tablecol' ;
17
+ }
18
+
19
+ static get properties ( ) {
20
+ return {
21
+ name : { type : String , reflect : true } ,
22
+ hidden : { type : Boolean , reflect : true } ,
23
+ } ;
24
+ }
25
+
26
+ /**
27
+ * Get the column title.
28
+ *
29
+ * @returns {string }
30
+ */
31
+ get title ( ) {
32
+ return this . textContent ;
33
+ }
34
+
35
+ // eslint-disable-next-line class-methods-use-this
36
+ render ( value , key ) {
37
+ const cell = value instanceof Object ? value [ key ] : value ;
38
+ if ( cell instanceof Object ) {
39
+ return html `< code > ${ JSON . stringify ( cell ) } </ code > ` ;
40
+ }
41
+ return html `${ cell } ` ;
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments