esinergia-card 0.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.
@@ -0,0 +1,25 @@
1
+ name: card
2
+ version: 1.0.0
3
+ renderer: web_component
4
+ custom_element: esidcm-card
5
+ props:
6
+ field_title:
7
+ type: string
8
+ required: true
9
+ field_summary:
10
+ type: string
11
+ required: false
12
+ field_image:
13
+ type: image
14
+ required: false
15
+ field_image_alt:
16
+ type: string
17
+ required: false
18
+ field_link:
19
+ type: url
20
+ required: false
21
+ field_target:
22
+ type: target
23
+ required: false
24
+ slots: []
25
+ dependencies: []
package/dist/card.css ADDED
@@ -0,0 +1,36 @@
1
+ .esidcm-card {
2
+ border: 1px solid #e5e7eb;
3
+ border-radius: 0.75rem;
4
+ overflow: hidden;
5
+ max-width: 90vw;
6
+ background: #ffffff;
7
+ box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
8
+ }
9
+
10
+ .esidcm-card__media img {
11
+ display: block;
12
+ width: 100%;
13
+ height: 200px;
14
+ object-fit: cover;
15
+ background: #f3f4f6;
16
+ }
17
+
18
+ .esidcm-card__content {
19
+ padding: 1rem;
20
+ }
21
+
22
+ .esidcm-card__title {
23
+ margin: 0 0 0.5rem;
24
+ font-size: 1.125rem;
25
+ }
26
+
27
+ .esidcm-card__description {
28
+ margin: 0 0 0.75rem;
29
+ color: #4b5563;
30
+ }
31
+
32
+ .esidcm-card__link {
33
+ color: #1d4ed8;
34
+ text-decoration: none;
35
+ font-weight: 600;
36
+ }
package/dist/card.html ADDED
@@ -0,0 +1,10 @@
1
+ <article class="esidcm-card">
2
+ <div class="esidcm-card__media">
3
+ <img src="{{field_image}}" alt="{{field_image_alt}}">
4
+ </div>
5
+ <div class="esidcm-card__content">
6
+ <h3 class="esidcm-card__title">{{field_title}}</h3>
7
+ <p class="esidcm-card__description">{{field_summary}}</p>
8
+ <a class="esidcm-card__link" href="{{field_link}}" target="{{field_target}}">Ver más</a>
9
+ </div>
10
+ </article>
package/dist/card.js ADDED
@@ -0,0 +1,61 @@
1
+ (function () {
2
+ if (customElements.get("esidcm-card")) {
3
+ return;
4
+ }
5
+
6
+ class ESIDCMCard extends HTMLElement {
7
+ static get observedAttributes() {
8
+ return ["field_title", "field_summary", "field_image", "field_image_alt", "field_link", "field_target"];
9
+ }
10
+
11
+ connectedCallback() {
12
+ this.render();
13
+ }
14
+
15
+ attributeChangedCallback() {
16
+ this.render();
17
+ }
18
+
19
+ render() {
20
+ const title = this.getAttribute("field_title") || "Título de la card";
21
+ const summary = this.getAttribute("field_summary") || "Descripción de la card";
22
+ const image = this.getAttribute("field_image") || "";
23
+ const imageAlt = this.getAttribute("field_image_alt") || "";
24
+ const linkUrl = (this.getAttribute("field_link") || "").trim();
25
+ const linkTarget = this.normalizeTarget(this.getAttribute("field_target") || "_self");
26
+ const linkMarkup = linkUrl
27
+ ? `<a class="esidcm-card__link" href="${this.escapeAttr(linkUrl)}" target="${this.escapeAttr(linkTarget)}">Ver más</a>`
28
+ : "";
29
+
30
+ this.innerHTML = `
31
+ <article class="esidcm-card">
32
+ <div class="esidcm-card__media">
33
+ <img src="${this.escapeAttr(image)}" alt="${this.escapeAttr(imageAlt)}">
34
+ </div>
35
+ <div class="esidcm-card__content">
36
+ <h3 class="esidcm-card__title">${this.escapeHtml(title)}</h3>
37
+ <p class="esidcm-card__description">${this.escapeHtml(summary)}</p>
38
+ ${linkMarkup}
39
+ </div>
40
+ </article>
41
+ `;
42
+ }
43
+
44
+ escapeHtml(value) {
45
+ return String(value)
46
+ .replace(/&/g, "&amp;")
47
+ .replace(/</g, "&lt;")
48
+ .replace(/>/g, "&gt;");
49
+ }
50
+
51
+ escapeAttr(value) {
52
+ return this.escapeHtml(value).replace(/"/g, "&quot;");
53
+ }
54
+
55
+ normalizeTarget(value) {
56
+ return value === "_blank" ? "_blank" : "_self";
57
+ }
58
+ }
59
+
60
+ customElements.define("esidcm-card", ESIDCMCard);
61
+ })();
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import "./card.js";
2
+ import "./card.css";
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "esinergia-card",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "Componente web card de ESIDCM",
6
+ "main": "./dist/index.js",
7
+ "exports": {
8
+ ".": "./dist/index.js",
9
+ "./card.js": "./dist/card.js",
10
+ "./card.css": "./dist/card.css",
11
+ "./card.component.yml": "./dist/card.component.yml",
12
+ "./card.html": "./dist/card.html"
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "node ../../scripts/build-card.mjs",
19
+ "test": "echo \"test pendiente para @esidcm/card\""
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "license": "UNLICENSED"
25
+ }