booary 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{scripts/add-book.ts → dist/cli.js} +28 -32
- package/dist/index.css +1 -0
- package/dist/index.global.js +2 -0
- package/package.json +4 -1
- package/index.html +0 -13
- package/public/library/card.json +0 -21
- package/public/test.html +0 -16
- package/public/vite.svg +0 -1
- package/src/app.css +0 -0
- package/src/app.tsx +0 -11
- package/src/assets/preact.svg +0 -1
- package/src/index.css +0 -0
- package/src/lib/libraryCard.css +0 -116
- package/src/lib/libraryCard.tsx +0 -125
- package/src/main.tsx +0 -5
- package/tsconfig.app.json +0 -33
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -26
- package/tsup.config.ts +0 -33
- package/vite.config.ts +0 -7
|
@@ -1,73 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// scripts/add-book.ts
|
|
1
4
|
import inquirer from "inquirer";
|
|
2
5
|
import axios from "axios";
|
|
3
6
|
import fs from "fs-extra";
|
|
4
7
|
import path from "path";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const FILE_PATH = path.join(process.cwd(), "public/library/card.json");
|
|
8
|
+
var DIR_PATH = path.join(process.cwd(), "public/library");
|
|
9
|
+
var FILE_PATH = path.join(process.cwd(), "public/library/card.json");
|
|
8
10
|
async function runCli() {
|
|
11
|
+
var _a;
|
|
9
12
|
await fs.ensureDir(DIR_PATH);
|
|
10
|
-
|
|
11
13
|
if (!fs.existsSync(FILE_PATH)) {
|
|
12
14
|
const profile = await inquirer.prompt([
|
|
13
15
|
{
|
|
14
16
|
type: "input",
|
|
15
17
|
name: "borrower",
|
|
16
|
-
message: "Enter borrower name"
|
|
18
|
+
message: "Enter borrower name"
|
|
17
19
|
},
|
|
18
20
|
{
|
|
19
21
|
type: "input",
|
|
20
22
|
name: "libName",
|
|
21
23
|
message: "Enter library name",
|
|
22
|
-
default: "Boo Library"
|
|
23
|
-
}
|
|
24
|
+
default: "Boo Library"
|
|
25
|
+
}
|
|
24
26
|
]);
|
|
25
27
|
const initialData = {
|
|
26
28
|
borrower: profile.borrower,
|
|
27
|
-
library: { name: profile.libName, signature: "
|
|
28
|
-
books: []
|
|
29
|
+
library: { name: profile.libName, signature: "\u{1F43E}" },
|
|
30
|
+
books: []
|
|
29
31
|
};
|
|
30
32
|
await fs.writeJson(FILE_PATH, initialData, { spaces: 2 });
|
|
31
|
-
console.log("
|
|
33
|
+
console.log("\u2728 Library card created!");
|
|
32
34
|
}
|
|
33
35
|
const { query } = await inquirer.prompt([
|
|
34
|
-
{ type: "input", name: "query", message: "Search for a book:" }
|
|
36
|
+
{ type: "input", name: "query", message: "Search for a book:" }
|
|
35
37
|
]);
|
|
36
38
|
const { data } = await axios.get(
|
|
37
|
-
`https://openlibrary.org/search.json?q=${encodeURIComponent(query)}
|
|
39
|
+
`https://openlibrary.org/search.json?q=${encodeURIComponent(query)}`
|
|
38
40
|
);
|
|
39
|
-
if (!data.docs
|
|
41
|
+
if (!((_a = data.docs) == null ? void 0 : _a.length)) {
|
|
40
42
|
console.log("No books found.");
|
|
41
43
|
return;
|
|
42
44
|
}
|
|
43
|
-
|
|
44
|
-
interface IBook {
|
|
45
|
-
key: string;
|
|
46
|
-
title: string;
|
|
47
|
-
author_name: string[];
|
|
48
|
-
finishedDate: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
45
|
const { selectedBook } = await inquirer.prompt([
|
|
52
46
|
{
|
|
53
47
|
type: "select",
|
|
54
48
|
name: "selectedBook",
|
|
55
49
|
message: "Select a book:",
|
|
56
|
-
choices: data.docs.map((book
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
50
|
+
choices: data.docs.map((book) => {
|
|
51
|
+
var _a2, _b;
|
|
52
|
+
return {
|
|
53
|
+
name: `${book.title} (${((_a2 = book.author_name) == null ? void 0 : _a2[0]) || "Unknown"})`,
|
|
54
|
+
value: {
|
|
55
|
+
key: book.key,
|
|
56
|
+
name: book.title,
|
|
57
|
+
author: ((_b = book.author_name) == null ? void 0 : _b[0]) || "Unknown",
|
|
58
|
+
finishedDate: (/* @__PURE__ */ new Date()).toLocaleDateString("en-IN")
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
})
|
|
62
|
+
}
|
|
66
63
|
]);
|
|
67
64
|
const cardData = await fs.readJson(FILE_PATH);
|
|
68
65
|
cardData.books.push(selectedBook);
|
|
69
66
|
await fs.writeJson(FILE_PATH, cardData, { spaces: 2 });
|
|
70
|
-
|
|
71
67
|
console.log(`Added ${selectedBook.name}`);
|
|
72
68
|
}
|
|
73
69
|
runCli();
|
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.card{position:relative;max-width:384px;border:2px solid #1f2937;background-color:#fff;padding:1.5rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;box-shadow:0 1px 2px #0000000d}.inner{transform:rotate(-1deg)}.header{display:flex;justify-content:space-between;border-bottom:2px solid #1f2937;padding-bottom:.5rem;margin-bottom:1rem}.year{font-size:.75rem;text-transform:uppercase;font-weight:700}.libraryTitle{font-size:1.25rem;font-weight:900;letter-spacing:.1em;text-transform:uppercase;font-style:italic;margin:0}.fieldGroup{margin-bottom:1rem}.fieldValue{margin:0;line-height:1.2}.nameValue{font-size:1.125rem}.signatureValue{font-size:1.5rem}.label{display:block;font-size:10px;text-transform:uppercase;color:#6b7280;text-decoration:underline dotted}.bookSection{border-top:2px solid #1f2937;padding-top:.5rem}.bookList{list-style:none;padding:0;margin:0}.bookRow{position:relative;display:grid;grid-template-cols:1fr 1fr;align-items:flex-end;border-bottom:1px solid #f3f4f6;padding-bottom:.25rem;margin-bottom:.5rem}.bookName{font-size:.875rem;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-right:.5rem}.bookDate{font-size:10px;text-align:right;color:#9ca3af;font-style:italic}.friendSignatures{position:absolute;right:16px;display:flex;top:-4px}.signatureLink{font-size:1.125rem;transition:transform .2s;text-decoration:none;color:inherit}.signatureLink:hover{transform:scale(1.25);z-index:10}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(exports){'use strict';var U,d,fe,H,se,pe,de,he,Z,J,K,F={},me=[],We=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,$=Array.isArray;function C(e,t){for(var n in t)e[n]=t[n];return e}function X(e){e&&e.parentNode&&e.parentNode.removeChild(e);}function P(e,t,n){var o,_,r,i={};for(r in t)r=="key"?o=t[r]:r=="ref"?_=t[r]:i[r]=t[r];if(arguments.length>2&&(i.children=arguments.length>3?U.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(r in e.defaultProps)i[r]===void 0&&(i[r]=e.defaultProps[r]);return j(e,i,o,_,null)}function j(e,t,n,o,_){var r={type:e,props:t,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:_??++fe,__i:-1,__u:0};return _==null&&d.vnode!=null&&d.vnode(r),r}function S(e){return e.children}function V(e,t){this.props=e,this.context=t;}function T(e,t){if(t==null)return e.__?T(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?T(e):null}function ve(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return ve(e)}}function le(e){(!e.__d&&(e.__d=true)&&H.push(e)&&!W.__r++||se!=d.debounceRendering)&&((se=d.debounceRendering)||pe)(W);}function W(){for(var e,t,n,o,_,r,i,l=1;H.length;)H.length>l&&H.sort(de),e=H.shift(),l=H.length,e.__d&&(n=void 0,o=void 0,_=(o=(t=e).__v).__e,r=[],i=[],t.__P&&((n=C({},o)).__v=o.__v+1,d.vnode&&d.vnode(n),Y(t.__P,n,o,t.__n,t.__P.namespaceURI,32&o.__u?[_]:null,r,_??T(o),!!(32&o.__u),i),n.__v=o.__v,n.__.__k[n.__i]=n,be(r,n,i),o.__e=o.__=null,n.__e!=_&&ve(n)));W.__r=0;}function ye(e,t,n,o,_,r,i,l,u,s,c){var a,p,f,b,x,k,m,h=o&&o.__k||me,N=t.length;for(u=$e(n,t,h,u,N),a=0;a<N;a++)(f=n.__k[a])!=null&&(p=f.__i==-1?F:h[f.__i]||F,f.__i=a,k=Y(e,f,p,_,r,i,l,u,s,c),b=f.__e,f.ref&&p.ref!=f.ref&&(p.ref&&ee(p.ref,null,f),c.push(f.ref,f.__c||b,f)),x==null&&b!=null&&(x=b),(m=!!(4&f.__u))||p.__k===f.__k?u=ge(f,u,e,m):typeof f.type=="function"&&k!==void 0?u=k:b&&(u=b.nextSibling),f.__u&=-7);return n.__e=x,u}function $e(e,t,n,o,_){var r,i,l,u,s,c=n.length,a=c,p=0;for(e.__k=new Array(_),r=0;r<_;r++)(i=t[r])!=null&&typeof i!="boolean"&&typeof i!="function"?(typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?i=e.__k[r]=j(null,i,null,null,null):$(i)?i=e.__k[r]=j(S,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?i=e.__k[r]=j(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):e.__k[r]=i,u=r+p,i.__=e,i.__b=e.__b+1,l=null,(s=i.__i=Be(i,n,u,a))!=-1&&(a--,(l=n[s])&&(l.__u|=2)),l==null||l.__v==null?(s==-1&&(_>c?p--:_<c&&p++),typeof i.type!="function"&&(i.__u|=4)):s!=u&&(s==u-1?p--:s==u+1?p++:(s>u?p--:p++,i.__u|=4))):e.__k[r]=null;if(a)for(r=0;r<c;r++)(l=n[r])!=null&&(2&l.__u)==0&&(l.__e==o&&(o=T(l)),xe(l,l));return o}function ge(e,t,n,o){var _,r;if(typeof e.type=="function"){for(_=e.__k,r=0;_&&r<_.length;r++)_[r]&&(_[r].__=e,t=ge(_[r],t,n,o));return t}e.__e!=t&&(o&&(t&&e.type&&!t.parentNode&&(t=T(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Be(e,t,n,o){var _,r,i,l=e.key,u=e.type,s=t[n],c=s!=null&&(2&s.__u)==0;if(s===null&&l==null||c&&l==s.key&&u==s.type)return n;if(o>(c?1:0)){for(_=n-1,r=n+1;_>=0||r<t.length;)if((s=t[i=_>=0?_--:r++])!=null&&(2&s.__u)==0&&l==s.key&&u==s.type)return i}return -1}function ue(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||We.test(t)?n:n+"px";}function R(e,t,n,o,_){var r,i;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else {if(typeof o=="string"&&(e.style.cssText=o=""),o)for(t in o)n&&t in n||ue(e.style,t,"");if(n)for(t in n)o&&n[t]==o[t]||ue(e.style,t,n[t]);}else if(t[0]=="o"&&t[1]=="n")r=t!=(t=t.replace(he,"$1")),i=t.toLowerCase(),t=i in e||t=="onFocusOut"||t=="onFocusIn"?i.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=n,n?o?n.u=o.u:(n.u=Z,e.addEventListener(t,r?K:J,r)):e.removeEventListener(t,r?K:J,r);else {if(_=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===false&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n));}}function ce(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Z++;else if(t.t<n.u)return;return n(d.event?d.event(t):t)}}}function Y(e,t,n,o,_,r,i,l,u,s){var c,a,p,f,b,x,k,m,h,N,E,O,A,ae,z,L,G,w=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),r=[l=t.__e=n.__e]),(c=d.__b)&&c(t);e:if(typeof w=="function")try{if(m=t.props,h="prototype"in w&&w.prototype.render,N=(c=w.contextType)&&o[c.__c],E=c?N?N.props.value:c.__:o,n.__c?k=(a=t.__c=n.__c).__=a.__E:(h?t.__c=a=new w(m,E):(t.__c=a=new V(m,E),a.constructor=w,a.render=qe),N&&N.sub(a),a.state||(a.state={}),a.__n=o,p=a.__d=!0,a.__h=[],a._sb=[]),h&&a.__s==null&&(a.__s=a.state),h&&w.getDerivedStateFromProps!=null&&(a.__s==a.state&&(a.__s=C({},a.__s)),C(a.__s,w.getDerivedStateFromProps(m,a.__s))),f=a.props,b=a.state,a.__v=t,p)h&&w.getDerivedStateFromProps==null&&a.componentWillMount!=null&&a.componentWillMount(),h&&a.componentDidMount!=null&&a.__h.push(a.componentDidMount);else {if(h&&w.getDerivedStateFromProps==null&&m!==f&&a.componentWillReceiveProps!=null&&a.componentWillReceiveProps(m,E),t.__v==n.__v||!a.__e&&a.shouldComponentUpdate!=null&&a.shouldComponentUpdate(m,a.__s,E)===!1){for(t.__v!=n.__v&&(a.props=m,a.state=a.__s,a.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(D){D&&(D.__=t);}),O=0;O<a._sb.length;O++)a.__h.push(a._sb[O]);a._sb=[],a.__h.length&&i.push(a);break e}a.componentWillUpdate!=null&&a.componentWillUpdate(m,a.__s,E),h&&a.componentDidUpdate!=null&&a.__h.push(function(){a.componentDidUpdate(f,b,x);});}if(a.context=E,a.props=m,a.__P=e,a.__e=!1,A=d.__r,ae=0,h){for(a.state=a.__s,a.__d=!1,A&&A(t),c=a.render(a.props,a.state,a.context),z=0;z<a._sb.length;z++)a.__h.push(a._sb[z]);a._sb=[];}else do a.__d=!1,A&&A(t),c=a.render(a.props,a.state,a.context),a.state=a.__s;while(a.__d&&++ae<25);a.state=a.__s,a.getChildContext!=null&&(o=C(C({},o),a.getChildContext())),h&&!p&&a.getSnapshotBeforeUpdate!=null&&(x=a.getSnapshotBeforeUpdate(f,b)),L=c,c!=null&&c.type===S&&c.key==null&&(L=ke(c.props.children)),l=ye(e,$(L)?L:[L],t,n,o,_,r,i,l,u,s),a.base=t.__e,t.__u&=-161,a.__h.length&&i.push(a),k&&(a.__E=a.__=null);}catch(D){if(t.__v=null,u||r!=null)if(D.then){for(t.__u|=u?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;r[r.indexOf(l)]=null,t.__e=l;}else {for(G=r.length;G--;)X(r[G]);Q(t);}else t.__e=n.__e,t.__k=n.__k,D.then||Q(t);d.__e(D,t,n);}else r==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):l=t.__e=Ie(n.__e,t,n,o,_,r,i,u,s);return (c=d.diffed)&&c(t),128&t.__u?void 0:l}function Q(e){e&&e.__c&&(e.__c.__e=true),e&&e.__k&&e.__k.forEach(Q);}function be(e,t,n){for(var o=0;o<n.length;o++)ee(n[o],n[++o],n[++o]);d.__c&&d.__c(t,e),e.some(function(_){try{e=_.__h,_.__h=[],e.some(function(r){r.call(_);});}catch(r){d.__e(r,_.__v);}});}function ke(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:$(e)?e.map(ke):C({},e)}function Ie(e,t,n,o,_,r,i,l,u){var s,c,a,p,f,b,x,k=n.props||F,m=t.props,h=t.type;if(h=="svg"?_="http://www.w3.org/2000/svg":h=="math"?_="http://www.w3.org/1998/Math/MathML":_||(_="http://www.w3.org/1999/xhtml"),r!=null){for(s=0;s<r.length;s++)if((f=r[s])&&"setAttribute"in f==!!h&&(h?f.localName==h:f.nodeType==3)){e=f,r[s]=null;break}}if(e==null){if(h==null)return document.createTextNode(m);e=document.createElementNS(_,h,m.is&&m),l&&(d.__m&&d.__m(t,r),l=false),r=null;}if(h==null)k===m||l&&e.data==m||(e.data=m);else {if(r=r&&U.call(e.childNodes),!l&&r!=null)for(k={},s=0;s<e.attributes.length;s++)k[(f=e.attributes[s]).name]=f.value;for(s in k)if(f=k[s],s!="children"){if(s=="dangerouslySetInnerHTML")a=f;else if(!(s in m)){if(s=="value"&&"defaultValue"in m||s=="checked"&&"defaultChecked"in m)continue;R(e,s,null,f,_);}}for(s in m)f=m[s],s=="children"?p=f:s=="dangerouslySetInnerHTML"?c=f:s=="value"?b=f:s=="checked"?x=f:l&&typeof f!="function"||k[s]===f||R(e,s,f,k[s],_);if(c)l||a&&(c.__html==a.__html||c.__html==e.innerHTML)||(e.innerHTML=c.__html),t.__k=[];else if(a&&(e.innerHTML=""),ye(t.type=="template"?e.content:e,$(p)?p:[p],t,n,o,h=="foreignObject"?"http://www.w3.org/1999/xhtml":_,r,i,r?r[0]:n.__k&&T(n,0),l,u),r!=null)for(s=r.length;s--;)X(r[s]);l||(s="value",h=="progress"&&b==null?e.removeAttribute("value"):b!=null&&(b!==e[s]||h=="progress"&&!b||h=="option"&&b!=k[s])&&R(e,s,b,k[s],_),s="checked",x!=null&&x!=e[s]&&R(e,s,x,k[s],_));}return e}function ee(e,t,n){try{if(typeof e=="function"){var o=typeof e.__u=="function";o&&e.__u(),o&&t==null||(e.__u=e(t));}else e.current=t;}catch(_){d.__e(_,n);}}function xe(e,t,n){var o,_;if(d.unmount&&d.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||ee(o,null,t)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount();}catch(r){d.__e(r,t);}o.base=o.__P=null;}if(o=e.__k)for(_=0;_<o.length;_++)o[_]&&xe(o[_],t,n||typeof e.type!="function");n||X(e.__e),e.__c=e.__=e.__e=void 0;}function qe(e,t,n){return this.constructor(e,n)}function M(e,t,n){var o,_,r,i;t==document&&(t=document.documentElement),d.__&&d.__(e,t),_=(o=typeof n=="function")?null:n&&n.__k||t.__k,r=[],i=[],Y(t,e=(!o&&n||t).__k=P(S,null,[e]),_||F,F,t.namespaceURI,!o&&n?[n]:_?null:t.firstChild?U.call(t.childNodes):null,r,!o&&n?n:_?_.__e:t.firstChild,o,i),be(r,e,i);}function te(e,t){M(e,t,te);}function ne(e,t,n){var o,_,r,i,l=C({},e.props);for(r in e.type&&e.type.defaultProps&&(i=e.type.defaultProps),t)r=="key"?o=t[r]:r=="ref"?_=t[r]:l[r]=t[r]===void 0&&i!=null?i[r]:t[r];return arguments.length>2&&(l.children=arguments.length>3?U.call(arguments,2):n),j(e.type,l,o||e.key,_||e.ref,null)}U=me.slice,d={__e:function(e,t,n,o){for(var _,r,i;t=t.__;)if((_=t.__c)&&!_.__)try{if((r=_.constructor)&&r.getDerivedStateFromError!=null&&(_.setState(r.getDerivedStateFromError(e)),i=_.__d),_.componentDidCatch!=null&&(_.componentDidCatch(e,o||{}),i=_.__d),i)return _.__E=_}catch(l){e=l;}throw e}},fe=0,V.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=C({},this.state),typeof e=="function"&&(e=e(C({},n),this.props)),e&&C(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),le(this));},V.prototype.forceUpdate=function(e){this.__v&&(this.__e=true,e&&this.__h.push(e),le(this));},V.prototype.render=S,H=[],pe=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,de=function(e,t){return e.__v.__b-t.__v.__b},W.__r=0,he=/(PointerCapture)$|Capture$/i,Z=0,J=ce(false),K=ce(true);var I,y,re,we,oe=0,Te=[],g=d,Ce=g.__b,Ne=g.__r,Se=g.diffed,Ee=g.__c,He=g.unmount,Pe=g.__;function Ae(e,t){g.__h&&g.__h(y,e,oe||t),oe=0;var n=y.__H||(y.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function ie(e){return oe=1,Ge(je,e)}function Ge(e,t,n){var o=Ae(I++,2);if(o.t=e,!o.__c&&(o.__=[je(void 0,t),function(l){var u=o.__N?o.__N[0]:o.__[0],s=o.t(u,l);u!==s&&(o.__N=[s,o.__[1]],o.__c.setState({}));}],o.__c=y,!y.__f)){var _=function(l,u,s){if(!o.__c.__H)return true;var c=o.__c.__H.__.filter(function(p){return !!p.__c});if(c.every(function(p){return !p.__N}))return !r||r.call(this,l,u,s);var a=o.__c.props!==l;return c.forEach(function(p){if(p.__N){var f=p.__[0];p.__=p.__N,p.__N=void 0,f!==p.__[0]&&(a=true);}}),r&&r.call(this,l,u,s)||a};y.__f=true;var r=y.shouldComponentUpdate,i=y.componentWillUpdate;y.componentWillUpdate=function(l,u,s){if(this.__e){var c=r;r=void 0,_(l,u,s),r=c;}i&&i.call(this,l,u,s);},y.shouldComponentUpdate=_;}return o.__N||o.__}function Le(e,t){var n=Ae(I++,3);!g.__s&&Qe(n.__H,t)&&(n.__=e,n.u=t,y.__H.__h.push(n));}function Je(){for(var e;e=Te.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(B),e.__H.__h.forEach(_e),e.__H.__h=[];}catch(t){e.__H.__h=[],g.__e(t,e.__v);}}g.__b=function(e){y=null,Ce&&Ce(e);},g.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Pe&&Pe(e,t);},g.__r=function(e){Ne&&Ne(e),I=0;var t=(y=e.__c).__H;t&&(re===y?(t.__h=[],y.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0;})):(t.__h.forEach(B),t.__h.forEach(_e),t.__h=[],I=0)),re=y;},g.diffed=function(e){Se&&Se(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Te.push(t)!==1&&we===g.requestAnimationFrame||((we=g.requestAnimationFrame)||Ke)(Je)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0;})),re=y=null;},g.__c=function(e,t){t.some(function(n){try{n.__h.forEach(B),n.__h=n.__h.filter(function(o){return !o.__||_e(o)});}catch(o){t.some(function(_){_.__h&&(_.__h=[]);}),t=[],g.__e(o,n.__v);}}),Ee&&Ee(e,t);},g.unmount=function(e){He&&He(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{B(o);}catch(_){t=_;}}),n.__H=void 0,t&&g.__e(t,n.__v));};var De=typeof requestAnimationFrame=="function";function Ke(e){var t,n=function(){clearTimeout(o),De&&cancelAnimationFrame(t),setTimeout(e);},o=setTimeout(n,35);De&&(t=requestAnimationFrame(n));}function B(e){var t=y,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),y=t;}function _e(e){var t=y;e.__c=e.__(),y=t;}function Qe(e,t){return !e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function je(e,t){return typeof t=="function"?t(e):t}function q(){return q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);}return e},q.apply(this,arguments)}function Ue(e,t){if(e==null)return {};var n,o,_={},r=Object.keys(e);for(o=0;o<r.length;o++)t.indexOf(n=r[o])>=0||(_[n]=e[n]);return _}var Ze=["context","children"],Xe=["useFragment"];function Me(e,t,n,o){function _(){var r,i=Reflect.construct(HTMLElement,[],_);return i._vdomComponent=e,o&&o.shadow?(i._root=i.attachShadow({mode:o.mode||"open",serializable:(r=o.serializable)!=null&&r}),o.adoptedStyleSheets&&(i._root.adoptedStyleSheets=o.adoptedStyleSheets)):i._root=i,i}return (_.prototype=Object.create(HTMLElement.prototype)).constructor=_,_.prototype.connectedCallback=function(){et.call(this,o);},_.prototype.attributeChangedCallback=tt,_.prototype.disconnectedCallback=nt,n=n||e.observedAttributes||Object.keys(e.propTypes||{}),_.observedAttributes=n,e.formAssociated&&(_.formAssociated=true),n.forEach(function(r){Object.defineProperty(_.prototype,r,{get:function(){return this._vdom?this._vdom.props[r]:this._props[r]},set:function(i){this._vdom?this.attributeChangedCallback(r,null,i):(this._props||(this._props={}),this._props[r]=i);var l=typeof i;i!=null&&l!=="string"&&l!=="boolean"&&l!=="number"||this.setAttribute(r,i);}});}),customElements.define(t,_),_}function Ye(e){this.getChildContext=function(){return e.context};var t=e.children,n=Ue(e,Ze);return ne(t,n)}function et(e){var t=new CustomEvent("_preact",{detail:{},bubbles:true,cancelable:true});this.dispatchEvent(t),this._vdom=P(Ye,q({},this._props,{context:t.detail.context}),ze(this,this._vdomComponent,e)),(this.hasAttribute("hydrate")?te:M)(this._vdom,this._root);}function Oe(e){return e.replace(/-(\w)/g,function(t,n){return n?n.toUpperCase():""})}function tt(e,t,n){if(this._vdom){var o={};o[e]=n=n??void 0,o[Oe(e)]=n,this._vdom=ne(this._vdom,o),M(this._vdom,this._root);}}function nt(){M(this._vdom=null,this._root);}function Fe(e,t){var n=this,o=e.useFragment,_=Ue(e,Xe);return P(o?S:"slot",q({},_,{ref:function(r){r?(n.ref=r,n._listener||(n._listener=function(i){i.stopPropagation(),i.detail.context=t;},r.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener);}}))}function ze(e,t,n){if(e.nodeType===3)return e.data;if(e.nodeType!==1)return null;var o=[],_={},r=0,i=e.attributes,l=e.childNodes;for(r=i.length;r--;)i[r].name!=="slot"&&(_[i[r].name]=i[r].value,_[Oe(i[r].name)]=i[r].value);for(r=l.length;r--;){var u=ze(l[r],null,n),s=l[r].slot;s?_[s]=P(Fe,{name:s},u):o[r]=u;}var c=!(!n||!n.shadow),a=t?P(Fe,{useFragment:!c},o):o;return !c&&t&&(e.innerHTML=""),P(t||e.nodeName.toLowerCase(),_,a)}var rt=0;function v(e,t,n,o,_,r){t||(t={});var i,l,u=t;if("ref"in u)for(l in u={},t)l=="ref"?i=t[l]:u[l]=t[l];var s={type:e,props:u,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--rt,__i:-1,__u:0,__source:_,__self:r};if(typeof e=="function"&&(i=e.defaultProps))for(l in i)u[l]===void 0&&(u[l]=i[l]);return d.vnode&&d.vnode(s),s}var ot=({cardlink:e,friends:t=[]})=>{let[n,o]=ie(null),[_,r]=ie([]);return Le(()=>{let i=typeof t=="string"?JSON.parse(t):t;fetch(e).then(l=>l.json()).then(o),Array.isArray(i)&&i.length>0&&Promise.all(i.map(l=>fetch(l).then(u=>u.json()).then(u=>({...u,url:l})))).then(r);},[e,t]),n?v("div",{className:"card",children:v("div",{className:"inner",children:[v("div",{className:"header",children:[v("span",{className:"year",children:"20"}),v("span",{className:"year",children:"26"})]}),v("div",{className:"header",children:v("h2",{className:"libraryTitle",children:n.library.name})}),v("div",{className:"fieldGroup",children:[v("p",{className:"fieldValue nameValue",children:n.borrower}),v("label",{className:"label",children:"Borrower's Name"})]}),v("div",{className:"fieldGroup",children:[v("p",{className:"fieldValue signatureValue",children:n.library.signature}),v("label",{className:"label",children:"Librarian's Signature"})]}),v("div",{className:"bookSection",children:v("ul",{className:"bookList",children:n.books.map((i,l)=>{console.log("friendsData",_,n);let u=_.filter(s=>s.books.some(c=>c.key===i.key));return console.log("readersOfThisBook",u),v("li",{className:"bookRow",children:[v("span",{className:"bookName",children:[i.name," by ",i.author]}),v("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:[v("span",{className:"bookDate",children:i.finishedDate}),v("div",{className:"friendSignatures",children:u.length>0&&v("div",{className:"friendSignatures",children:u.map((s,c)=>v("a",{href:s.url?new URL(s.url).origin:"#",className:"signatureLink",title:`${s.borrower} also read this`,target:"_blank",rel:"noopener noreferrer",children:s.library.signature},c))})})]})]},l)})})})]})}):v("div",{className:"loading",children:"Loading library card..."})};Me(ot,"x-library-card",["cardlink","friends"],{shadow:false});
|
|
2
|
+
exports.LibraryCard=ot;return exports;})({});
|
package/package.json
CHANGED
package/index.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>testpreact</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="app"></div>
|
|
11
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
package/public/library/card.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"borrower": "Joshua",
|
|
3
|
-
"library": {
|
|
4
|
-
"name": "Boo Library",
|
|
5
|
-
"signature": "🐾"
|
|
6
|
-
},
|
|
7
|
-
"books": [
|
|
8
|
-
{
|
|
9
|
-
"key": "/works/OL27448W",
|
|
10
|
-
"name": "The Lord of the Rings",
|
|
11
|
-
"author": "J.R.R. Tolkien",
|
|
12
|
-
"finishedDate": "18/2/2026"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"key": "/works/OL266178W",
|
|
16
|
-
"name": "Het Achterhuis",
|
|
17
|
-
"author": "Anne Frank",
|
|
18
|
-
"finishedDate": "18/2/2026"
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}
|
package/public/test.html
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<title>Web Component Test</title>
|
|
6
|
-
<script src="./dist/index.global.js"></script>
|
|
7
|
-
<link rel="stylesheet" href="./dist/index.css" />
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<x-library-card
|
|
11
|
-
cardlink="/library/card.json"
|
|
12
|
-
friends='["http://localhost:5174/library/card.json"]'
|
|
13
|
-
>
|
|
14
|
-
</x-library-card>
|
|
15
|
-
</body>
|
|
16
|
-
</html>
|
package/public/vite.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/src/app.css
DELETED
|
File without changes
|
package/src/app.tsx
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import "./app.css";
|
|
2
|
-
import { LibraryCard } from "./lib/libraryCard";
|
|
3
|
-
const myLibrary = "/library/card.json";
|
|
4
|
-
const friendsList = ["http://localhost:4321/library/card.json"];
|
|
5
|
-
export function App() {
|
|
6
|
-
return (
|
|
7
|
-
<>
|
|
8
|
-
<LibraryCard cardlink={myLibrary} friends={friendsList} />
|
|
9
|
-
</>
|
|
10
|
-
);
|
|
11
|
-
}
|
package/src/assets/preact.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="27.68" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 296"><path fill="#673AB8" d="m128 0l128 73.9v147.8l-128 73.9L0 221.7V73.9z"></path><path fill="#FFF" d="M34.865 220.478c17.016 21.78 71.095 5.185 122.15-34.704c51.055-39.888 80.24-88.345 63.224-110.126c-17.017-21.78-71.095-5.184-122.15 34.704c-51.055 39.89-80.24 88.346-63.224 110.126Zm7.27-5.68c-5.644-7.222-3.178-21.402 7.573-39.253c11.322-18.797 30.541-39.548 54.06-57.923c23.52-18.375 48.303-32.004 69.281-38.442c19.922-6.113 34.277-5.075 39.92 2.148c5.644 7.223 3.178 21.403-7.573 39.254c-11.322 18.797-30.541 39.547-54.06 57.923c-23.52 18.375-48.304 32.004-69.281 38.441c-19.922 6.114-34.277 5.076-39.92-2.147Z"></path><path fill="#FFF" d="M220.239 220.478c17.017-21.78-12.169-70.237-63.224-110.126C105.96 70.464 51.88 53.868 34.865 75.648c-17.017 21.78 12.169 70.238 63.224 110.126c51.055 39.889 105.133 56.485 122.15 34.704Zm-7.27-5.68c-5.643 7.224-19.998 8.262-39.92 2.148c-20.978-6.437-45.761-20.066-69.28-38.441c-23.52-18.376-42.74-39.126-54.06-57.923c-10.752-17.851-13.218-32.03-7.575-39.254c5.644-7.223 19.999-8.261 39.92-2.148c20.978 6.438 45.762 20.067 69.281 38.442c23.52 18.375 42.739 39.126 54.06 57.923c10.752 17.85 13.218 32.03 7.574 39.254Z"></path><path fill="#FFF" d="M127.552 167.667c10.827 0 19.603-8.777 19.603-19.604c0-10.826-8.776-19.603-19.603-19.603c-10.827 0-19.604 8.777-19.604 19.603c0 10.827 8.777 19.604 19.604 19.604Z"></path></svg>
|
package/src/index.css
DELETED
|
File without changes
|
package/src/lib/libraryCard.css
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
.card {
|
|
2
|
-
position: relative;
|
|
3
|
-
max-width: 384px;
|
|
4
|
-
border: 2px solid #1f2937;
|
|
5
|
-
background-color: #ffffff;
|
|
6
|
-
padding: 1.5rem;
|
|
7
|
-
font-family:
|
|
8
|
-
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
9
|
-
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.inner {
|
|
13
|
-
transform: rotate(-1deg);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.header {
|
|
17
|
-
display: flex;
|
|
18
|
-
justify-content: space-between;
|
|
19
|
-
border-bottom: 2px solid #1f2937;
|
|
20
|
-
padding-bottom: 0.5rem;
|
|
21
|
-
margin-bottom: 1rem;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.year {
|
|
25
|
-
font-size: 0.75rem;
|
|
26
|
-
text-transform: uppercase;
|
|
27
|
-
font-weight: 700;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.libraryTitle {
|
|
31
|
-
font-size: 1.25rem;
|
|
32
|
-
font-weight: 900;
|
|
33
|
-
letter-spacing: 0.1em;
|
|
34
|
-
text-transform: uppercase;
|
|
35
|
-
font-style: italic;
|
|
36
|
-
margin: 0;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.fieldGroup {
|
|
40
|
-
margin-bottom: 1rem;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.fieldValue {
|
|
44
|
-
margin: 0;
|
|
45
|
-
line-height: 1.2;
|
|
46
|
-
}
|
|
47
|
-
.nameValue {
|
|
48
|
-
font-size: 1.125rem;
|
|
49
|
-
}
|
|
50
|
-
.signatureValue {
|
|
51
|
-
font-size: 1.5rem;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.label {
|
|
55
|
-
display: block;
|
|
56
|
-
font-size: 10px;
|
|
57
|
-
text-transform: uppercase;
|
|
58
|
-
color: #6b7280;
|
|
59
|
-
text-decoration: underline dotted;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.bookSection {
|
|
63
|
-
border-top: 2px solid #1f2937;
|
|
64
|
-
padding-top: 0.5rem;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.bookList {
|
|
68
|
-
list-style: none;
|
|
69
|
-
padding: 0;
|
|
70
|
-
margin: 0;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.bookRow {
|
|
74
|
-
position: relative;
|
|
75
|
-
display: grid;
|
|
76
|
-
grid-template-cols: 1fr 1fr;
|
|
77
|
-
align-items: flex-end;
|
|
78
|
-
border-bottom: 1px solid #f3f4f6;
|
|
79
|
-
padding-bottom: 0.25rem;
|
|
80
|
-
margin-bottom: 0.5rem;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.bookName {
|
|
84
|
-
font-size: 0.875rem;
|
|
85
|
-
font-weight: 500;
|
|
86
|
-
white-space: nowrap;
|
|
87
|
-
overflow: hidden;
|
|
88
|
-
text-overflow: ellipsis;
|
|
89
|
-
padding-right: 0.5rem;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.bookDate {
|
|
93
|
-
font-size: 10px;
|
|
94
|
-
text-align: right;
|
|
95
|
-
color: #9ca3af;
|
|
96
|
-
font-style: italic;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.friendSignatures {
|
|
100
|
-
position: absolute;
|
|
101
|
-
right: 16px;
|
|
102
|
-
display: flex;
|
|
103
|
-
top: -4px;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.signatureLink {
|
|
107
|
-
font-size: 1.125rem;
|
|
108
|
-
transition: transform 0.2s;
|
|
109
|
-
text-decoration: none;
|
|
110
|
-
color: inherit;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.signatureLink:hover {
|
|
114
|
-
transform: scale(1.25);
|
|
115
|
-
z-index: 10;
|
|
116
|
-
}
|
package/src/lib/libraryCard.tsx
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from "preact/hooks";
|
|
2
|
-
import "./libraryCard.css";
|
|
3
|
-
import register from "preact-custom-element";
|
|
4
|
-
|
|
5
|
-
interface Book {
|
|
6
|
-
key: string;
|
|
7
|
-
name: string;
|
|
8
|
-
finishedDate: string;
|
|
9
|
-
author: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface CardData {
|
|
13
|
-
borrower: string;
|
|
14
|
-
library: { name: string; signature: string };
|
|
15
|
-
books: Book[];
|
|
16
|
-
url?: string; // Optional URL for the card
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface Props {
|
|
20
|
-
cardlink: string;
|
|
21
|
-
friends?: string[]; // Array of URLs
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const LibraryCard = ({ cardlink, friends = [] }: Props) => {
|
|
25
|
-
const [data, setData] = useState<CardData | null>(null);
|
|
26
|
-
const [friendsData, setFriendsData] = useState<CardData[]>([]);
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const friendsArray =
|
|
30
|
-
typeof friends === "string" ? JSON.parse(friends) : friends;
|
|
31
|
-
|
|
32
|
-
fetch(cardlink)
|
|
33
|
-
.then((res) => res.json())
|
|
34
|
-
.then(setData);
|
|
35
|
-
if (Array.isArray(friendsArray) && friendsArray.length > 0) {
|
|
36
|
-
Promise.all(
|
|
37
|
-
friendsArray.map((url) =>
|
|
38
|
-
fetch(url)
|
|
39
|
-
.then((res) => res.json())
|
|
40
|
-
.then((json) => ({ ...json, url })),
|
|
41
|
-
),
|
|
42
|
-
).then(setFriendsData);
|
|
43
|
-
}
|
|
44
|
-
}, [cardlink, friends]);
|
|
45
|
-
|
|
46
|
-
if (!data) return <div className={"loading"}>Loading library card...</div>;
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<div className={"card"}>
|
|
50
|
-
<div className={"inner"}>
|
|
51
|
-
<div className={"header"}>
|
|
52
|
-
<span className={"year"}>20</span>
|
|
53
|
-
<span className={"year"}>26</span>
|
|
54
|
-
</div>
|
|
55
|
-
|
|
56
|
-
<div className={"header"}>
|
|
57
|
-
<h2 className={"libraryTitle"}>{data.library.name}</h2>
|
|
58
|
-
</div>
|
|
59
|
-
|
|
60
|
-
<div className={"fieldGroup"}>
|
|
61
|
-
<p className={`${"fieldValue"} ${"nameValue"}`}>{data.borrower}</p>
|
|
62
|
-
<label className={"label"}>Borrower's Name</label>
|
|
63
|
-
</div>
|
|
64
|
-
|
|
65
|
-
<div className={"fieldGroup"}>
|
|
66
|
-
<p className={`${"fieldValue"} ${"signatureValue"}`}>
|
|
67
|
-
{data.library.signature}
|
|
68
|
-
</p>
|
|
69
|
-
<label className={"label"}>Librarian's Signature</label>
|
|
70
|
-
</div>
|
|
71
|
-
|
|
72
|
-
<div className={"bookSection"}>
|
|
73
|
-
<ul className={"bookList"}>
|
|
74
|
-
{data.books.map((book, idx) => {
|
|
75
|
-
console.log("friendsData", friendsData, data);
|
|
76
|
-
const readersOfThisBook = friendsData.filter((friend) =>
|
|
77
|
-
friend.books.some((friendBook) => friendBook.key === book.key),
|
|
78
|
-
);
|
|
79
|
-
console.log("readersOfThisBook", readersOfThisBook);
|
|
80
|
-
return (
|
|
81
|
-
<li key={idx} className={"bookRow"}>
|
|
82
|
-
<span className={"bookName"}>
|
|
83
|
-
{book.name} by {book.author}
|
|
84
|
-
</span>
|
|
85
|
-
<div
|
|
86
|
-
style={{
|
|
87
|
-
display: "flex",
|
|
88
|
-
justifyContent: "flex-end",
|
|
89
|
-
alignItems: "center",
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
<span className={"bookDate"}>{book.finishedDate}</span>
|
|
93
|
-
<div className={"friendSignatures"}>
|
|
94
|
-
{readersOfThisBook.length > 0 && (
|
|
95
|
-
<div className="friendSignatures">
|
|
96
|
-
{readersOfThisBook.map((friend, fIdx) => (
|
|
97
|
-
<a
|
|
98
|
-
key={fIdx}
|
|
99
|
-
href={
|
|
100
|
-
friend.url ? new URL(friend.url).origin : "#"
|
|
101
|
-
}
|
|
102
|
-
className="signatureLink"
|
|
103
|
-
title={`${friend.borrower} also read this`}
|
|
104
|
-
target="_blank"
|
|
105
|
-
rel="noopener noreferrer"
|
|
106
|
-
>
|
|
107
|
-
{friend.library.signature}
|
|
108
|
-
</a>
|
|
109
|
-
))}
|
|
110
|
-
</div>
|
|
111
|
-
)}
|
|
112
|
-
</div>
|
|
113
|
-
</div>
|
|
114
|
-
</li>
|
|
115
|
-
);
|
|
116
|
-
})}
|
|
117
|
-
</ul>
|
|
118
|
-
</div>
|
|
119
|
-
</div>
|
|
120
|
-
</div>
|
|
121
|
-
);
|
|
122
|
-
};
|
|
123
|
-
register(LibraryCard, "x-library-card", ["cardlink", "friends"], {
|
|
124
|
-
shadow: false,
|
|
125
|
-
});
|
package/src/main.tsx
DELETED
package/tsconfig.app.json
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
4
|
-
"target": "ES2022",
|
|
5
|
-
"useDefineForClassFields": true,
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
8
|
-
"types": ["vite/client"],
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"paths": {
|
|
11
|
-
"react": ["./node_modules/preact/compat/"],
|
|
12
|
-
"react-dom": ["./node_modules/preact/compat/"]
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
/* Bundler mode */
|
|
16
|
-
"moduleResolution": "bundler",
|
|
17
|
-
"allowImportingTsExtensions": true,
|
|
18
|
-
"verbatimModuleSyntax": true,
|
|
19
|
-
"moduleDetection": "force",
|
|
20
|
-
"noEmit": true,
|
|
21
|
-
"jsx": "react-jsx",
|
|
22
|
-
"jsxImportSource": "preact",
|
|
23
|
-
|
|
24
|
-
/* Linting */
|
|
25
|
-
"strict": true,
|
|
26
|
-
"noUnusedLocals": true,
|
|
27
|
-
"noUnusedParameters": true,
|
|
28
|
-
"erasableSyntaxOnly": true,
|
|
29
|
-
"noFallthroughCasesInSwitch": true,
|
|
30
|
-
"noUncheckedSideEffectImports": true
|
|
31
|
-
},
|
|
32
|
-
"include": ["src"]
|
|
33
|
-
}
|
package/tsconfig.json
DELETED
package/tsconfig.node.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
4
|
-
"target": "ES2023",
|
|
5
|
-
"lib": ["ES2023"],
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"types": ["node"],
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
|
|
10
|
-
/* Bundler mode */
|
|
11
|
-
"moduleResolution": "bundler",
|
|
12
|
-
"allowImportingTsExtensions": true,
|
|
13
|
-
"verbatimModuleSyntax": true,
|
|
14
|
-
"moduleDetection": "force",
|
|
15
|
-
"noEmit": true,
|
|
16
|
-
|
|
17
|
-
/* Linting */
|
|
18
|
-
"strict": true,
|
|
19
|
-
"noUnusedLocals": true,
|
|
20
|
-
"noUnusedParameters": true,
|
|
21
|
-
"erasableSyntaxOnly": true,
|
|
22
|
-
"noFallthroughCasesInSwitch": true,
|
|
23
|
-
"noUncheckedSideEffectImports": true
|
|
24
|
-
},
|
|
25
|
-
"include": ["vite.config.ts"]
|
|
26
|
-
}
|
package/tsup.config.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsup";
|
|
2
|
-
|
|
3
|
-
export default defineConfig([
|
|
4
|
-
{
|
|
5
|
-
entry: {
|
|
6
|
-
cli: "scripts/add-book.ts",
|
|
7
|
-
},
|
|
8
|
-
format: ["esm"],
|
|
9
|
-
splitting: false,
|
|
10
|
-
sourcemap: false,
|
|
11
|
-
clean: true,
|
|
12
|
-
dts: false,
|
|
13
|
-
banner: {
|
|
14
|
-
js: "#!/usr/bin/env node",
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
entry: {
|
|
19
|
-
index: "src/lib/libraryCard.tsx",
|
|
20
|
-
},
|
|
21
|
-
format: ["iife"],
|
|
22
|
-
minify: true,
|
|
23
|
-
splitting: false,
|
|
24
|
-
sourcemap: false,
|
|
25
|
-
clean: true,
|
|
26
|
-
dts: false,
|
|
27
|
-
treeshake: true,
|
|
28
|
-
esbuildOptions(options) {
|
|
29
|
-
options.jsx = "automatic";
|
|
30
|
-
options.jsxImportSource = "preact"; // Tells it to get h and Fragment from preact
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
]);
|