fix: add action list
This commit is contained in:
31
js/icons/cart-icon.js
Normal file
31
js/icons/cart-icon.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Cart Icon (Lucide style shopping cart)
|
||||
* @param {Object} props - Icon properties
|
||||
* @param {number} props.size - Icon size (default: 20)
|
||||
* @param {string} props.color - Icon color (default: currentColor)
|
||||
* @param {number} props.strokeWidth - Stroke width (default: 2)
|
||||
* @returns {string} SVG string
|
||||
*/
|
||||
export function cartIcon({
|
||||
size = 20,
|
||||
color = "currentColor",
|
||||
strokeWidth = 2,
|
||||
} = {}) {
|
||||
return `
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="${size}"
|
||||
height="${size}"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="${color}"
|
||||
stroke-width="${strokeWidth}"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="8" cy="21" r="1"/>
|
||||
<circle cx="19" cy="21" r="1"/>
|
||||
<path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"/>
|
||||
</svg>
|
||||
`;
|
||||
}
|
||||
29
js/icons/ebook-icon.js
Normal file
29
js/icons/ebook-icon.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* eBook Icon (Open book style)
|
||||
* @param {Object} props - Icon properties
|
||||
* @param {number} props.size - Icon size (default: 20)
|
||||
* @param {string} props.color - Icon color (default: currentColor)
|
||||
* @param {number} props.strokeWidth - Stroke width (default: 2)
|
||||
* @returns {string} SVG string
|
||||
*/
|
||||
export function ebookIcon({
|
||||
size = 20,
|
||||
color = "currentColor",
|
||||
strokeWidth = 2,
|
||||
} = {}) {
|
||||
return `
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="${size}"
|
||||
height="${size}"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="${color}"
|
||||
stroke-width="${strokeWidth}"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M12 6.042A8.967 8.967 0 0 0 6 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 0 1 6 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 0 1 6-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0 0 18 18a8.967 8.967 0 0 0-6 2.292m0-14.25v14.25"/>
|
||||
</svg>
|
||||
`;
|
||||
}
|
||||
31
js/icons/review-icon.js
Normal file
31
js/icons/review-icon.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Review Icon (person with star)
|
||||
* @param {Object} props - Icon properties
|
||||
* @param {number} props.size - Icon size (default: 24)
|
||||
* @param {string} props.color - Icon color (default: currentColor)
|
||||
* @param {number} props.strokeWidth - Stroke width (default: 2)
|
||||
* @returns {string} SVG string
|
||||
*/
|
||||
export function reviewIcon({
|
||||
size = 24,
|
||||
color = "currentColor",
|
||||
strokeWidth = 2,
|
||||
} = {}) {
|
||||
return `
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="${size}"
|
||||
height="${size}"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="${color}"
|
||||
stroke-width="${strokeWidth}"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="9" cy="7" r="4"/>
|
||||
<path d="M3 21v-2a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v2"/>
|
||||
<polygon points="19 8 20.5 11 24 11.5 21.5 14 22 17.5 19 16 16 17.5 16.5 14 14 11.5 17.5 11 19 8"/>
|
||||
</svg>
|
||||
`;
|
||||
}
|
||||
@@ -1,19 +1,49 @@
|
||||
/**
|
||||
* Shopping Bag Icon Web Component
|
||||
* A reusable shopping bag/cart icon element
|
||||
* A reusable shopping bag/cart icon element with optional badge count
|
||||
*/
|
||||
class ShoppingBagIcon extends HTMLElement {
|
||||
static get observedAttributes() {
|
||||
return ["size", "color", "stroke-width"];
|
||||
return ["size", "color", "stroke-width", "count"];
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.attachShadow({ mode: "open" });
|
||||
this.handleCartUpdate = this.handleCartUpdate.bind(this);
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
this.render();
|
||||
// Listen for cart updates
|
||||
window.addEventListener("cart-updated", this.handleCartUpdate);
|
||||
// Initialize count from cart store if available
|
||||
this.initializeCount();
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
window.removeEventListener("cart-updated", this.handleCartUpdate);
|
||||
}
|
||||
|
||||
initializeCount() {
|
||||
// Wait for cart store to be available
|
||||
setTimeout(() => {
|
||||
if (window.cartStore) {
|
||||
const count = window.cartStore.getItemCount();
|
||||
if (count > 0) {
|
||||
this.setAttribute("count", count.toString());
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
handleCartUpdate(event) {
|
||||
const { count } = event.detail;
|
||||
if (count > 0) {
|
||||
this.setAttribute("count", count.toString());
|
||||
} else {
|
||||
this.removeAttribute("count");
|
||||
}
|
||||
}
|
||||
|
||||
attributeChangedCallback() {
|
||||
@@ -32,33 +62,75 @@ class ShoppingBagIcon extends HTMLElement {
|
||||
return this.getAttribute("stroke-width") || "2";
|
||||
}
|
||||
|
||||
get count() {
|
||||
const countAttr = this.getAttribute("count");
|
||||
return countAttr ? parseInt(countAttr, 10) : 0;
|
||||
}
|
||||
|
||||
render() {
|
||||
const showBadge = this.count > 0;
|
||||
const displayCount = this.count > 99 ? "99+" : this.count.toString();
|
||||
|
||||
this.shadowRoot.innerHTML = `
|
||||
<style>
|
||||
:host {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.icon-wrapper {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
svg {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.badge {
|
||||
position: absolute;
|
||||
top: -6px;
|
||||
right: -8px;
|
||||
min-width: 18px;
|
||||
height: 18px;
|
||||
padding: 0 5px;
|
||||
color: var(--color-purple, #951d51);
|
||||
background-color: #ffffff;
|
||||
font-family: var(--font-family-outfit, "Outfit", sans-serif);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
line-height: 18px;
|
||||
text-align: center;
|
||||
border-radius: 9px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.badge.hidden {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="${this.size}"
|
||||
height="${this.size}"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="${this.color}"
|
||||
stroke-width="${this.strokeWidth}"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="8" cy="21" r="1"></circle>
|
||||
<circle cx="19" cy="21" r="1"></circle>
|
||||
<path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"></path>
|
||||
</svg>
|
||||
<div class="icon-wrapper">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="${this.size}"
|
||||
height="${this.size}"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="${this.color}"
|
||||
stroke-width="${this.strokeWidth}"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="8" cy="21" r="1"></circle>
|
||||
<circle cx="19" cy="21" r="1"></circle>
|
||||
<path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"></path>
|
||||
</svg>
|
||||
<span class="badge ${showBadge ? "" : "hidden"}">${displayCount}</span>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
32
js/icons/wishlist-icon.js
Normal file
32
js/icons/wishlist-icon.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Wishlist Icon (tablet with heart)
|
||||
* @param {Object} props - Icon properties
|
||||
* @param {number} props.size - Icon size (default: 24)
|
||||
* @param {string} props.color - Icon color (default: currentColor)
|
||||
* @param {number} props.strokeWidth - Stroke width (default: 2)
|
||||
* @returns {string} SVG string
|
||||
*/
|
||||
export function wishlistIcon({
|
||||
size = 24,
|
||||
color = "currentColor",
|
||||
strokeWidth = 2,
|
||||
} = {}) {
|
||||
return `
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="${size}"
|
||||
height="${size}"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="${color}"
|
||||
stroke-width="${strokeWidth}"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect x="5" y="2" width="14" height="20" rx="2" ry="2"/>
|
||||
<path d="M12 18h.01"/>
|
||||
<path d="M12 8l1.5 1.5L12 11l-1.5-1.5L12 8z" fill="${color}" stroke="none"/>
|
||||
<path d="M12 6.5c-.5-.5-1.5-.5-2 0s-.5 1.5 0 2l2 2 2-2c.5-.5.5-1.5 0-2s-1.5-.5-2 0"/>
|
||||
</svg>
|
||||
`;
|
||||
}
|
||||
Reference in New Issue
Block a user