npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hf-cart

v0.1.7

Published

yarn add hf-cart

Downloads

3

Readme

install

yarn add hf-cart

component

<Cart>

feature

  • RWD
  • 支援購物車按鈕和購物車下拉式內容。
  • 支援購物車數量顯示。
  • 支援空購物車的顯示。
  • 支援購物車 default 值。

API

  • cartItems : [], 購物車的商品項目。需提供
    • item.imgUrl: 商品圖片。
    • item.collection: 商品系列。
    • item.name:商品名稱。
    • item.options: 商品的選項。
      • 每一個選項包含{name:"",value:""}
    • item.price:商品的價格。
  • totalName: string, 小計的名稱。
  • totalPrice: string, 小計的價格。
  • cartTitle: 購物車 title。
  • cartIcon: 購物車 icon。
  • checkoutBtnText:購物車結帳按鈕文字。需提供,default 值是寫死"結帳 0 件商品"
  • removeCartItem: func, 移除購物車商品。
  • checkout: func, 結帳。
  • emptyCart: {}, 空購物車的內容。
    • row1 : 第一列的內容。
    • row2 : 第二列的內容。
    • buttonText: 空購物車了解最新商品的按鈕。
  • whatsNew: func, 空購物車,了解最新商品按鈕的行為。

CSS

  • .cart-btn : 購物車按鈕
  • .cart-btn .icon-cart: 購物車按鈕中的 icon
  • .cart-btn .cart-btn-number: 購物車按鈕右上方的數量
  • .empty-cart: 空購物車
  • .cart-content: 購物車的內容
  • .cart-subtotal: 購物車小計
  • .cart-subtotal-price: 購物車小計的價格
  • .checkout-btn: 購物車 checkout btn
  • .cartItem-remove-btn : 購物車商品移除按鈕
  • .cart-table : 購物車 table

Demo

import React from "react";
import Cart from "./Cart";

const cartItems = [
  {
    imgUrl:
      "https://cdn.chowsangsang.com/dfs/UAT/ivCssModelImages/90754/44aacc26b80d09543d087d16425d6dc7.jpg",
    collection: "Fingers Play 「指玩」",
    name: "18K黃金戒指",
    options: [
      { name: "數量", value: "1" },
      { name: "材質", value: "18K" },
      { name: "紅色黃金,長度", value: "45厘米" }
    ],
    price: "HK$1,400.00"
  },
  {
    imgUrl:
      "https://cdn.chowsangsang.com/dfs/UAT/ivCssModelImages/91302/759c105974897ccb59dccd6aa5ded818.jpg",
    collection: "Fingers Play 「指玩」",
    name: "18K黃金戒指",
    options: [
      { name: "數量", value: "1" },
      { name: "材質", value: "18K" },
      { name: "紅色黃金,長度", value: "45厘米" }
    ],
    price: "HK$1,500.00"
  }
];
const total = { name: "小計", price: "$9,100.00" };
const emptyCart = {
  row1: "Nothing!",
  row2: "Is everything OK?",
  buttonText: "What's New"
};

class App extends React.Component {
  removeCartItem = cartItem => {
    console.log("/*Action remove cart item Here!*/", cartItem);
  };
  checkout = () => {
    console.log("/*Action checkout Here!*/");
    window.location = `/checkout`;
  };
  whatsNew = () => {
    console.log("/*Action what's New Here!*/");
    window.location = `/whatsNew`;
  };
  get checkoutBtnText() {
    return `結帳${cartItems.length}件商品`;
  }
  render() {
    return (
      <div className="App">
        <div
          style={{
            borderBottom: "1px solid grey",
            height: "80px",
            lineHeight: "80px",
            textAlign: "left",
            paddingRight: "20px"
          }}
        >
          <Cart
            cartItems={cartItems}
            totalName={total.name}
            totalPrice={total.price}
            removeCartItem={this.removeCartItem}
            checkout={this.checkout}
            whatsNew={this.whatsNew}
            checkoutBtnText={this.checkoutBtnText}
          />
        </div>
      </div>
    );
  }
}

export default App;