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

@douyinfe/semi-site-banner

v0.1.5

Published

semi site banner

Downloads

763

Readme

安装

npm i @douyinfe/semi-site-banner

使用

UMD 版本由于 SSR 原因,没有将样式内联进去,因此 CSS 需要单独引入。

import React from 'react';
import SemiSiteReactBanner from '@douyinfe/semi-site-banner';
import '@douyinfe/semi-site-banner/dist/index.css';

class App extends React.Component {
  render() {
    const data = {
      zh: {
            "title": "抖音系企业应用设计系统 Semi Design 开源啦 🎉",
            "href": "https://bytedance.feishu.cn/docx/doxcnuCrjVb0zQEnqpzYzsisXkc#doxcnCaqWgw0oOgGumcwu58G47f"
      },
      en: {
            "title": "Build sensible web app with Semi Design, now is open-sourced 🎉",
            "href": "https://bytedance.feishu.cn/docx/doxcnuCrjVb0zQEnqpzYzsisXkc#doxcnCaqWgw0oOgGumcwu58G47f"
      },
    };
  
    return (
      <div style={{ backgroundColor: '#FFF', padding: 20 }}>
        <SemiSiteReactBanner type="default" />
        <br />
        <SemiSiteReactBanner type="default" icon={null} />
        <br />
        <SemiSiteReactBanner data={data} icon={<IconGift style={{ color: '#FBCD2C' }} />} />
        <br />
        <SemiSiteReactBanner type="blue" />
        <br />
        <SemiSiteReactBanner type="colour" />
        <br />
        <SemiSiteReactBanner type="black" />
      </div>
    );
  }
}

Data 配置

data 用于配置 banner 显示内容,可以选择直接通过 prop 配置和通过 TCC 配置。推荐使用 TCC 配置,可以动态更新。

  • 通过 TCC 进行配置可以动态更新banner内容,用户点击关闭后如果 TCC 数据没有更新则不再打开;
  • 通过 data prop 直接进行配置,用户关闭后 7 日内不会再显示。

API 参考

| 参数名 | 说明 | 类型 | 默认值 | | --------- | --------------------------------------------------- | ---------------------------------------------------- | ------------- | | data | 通过 data prop 配置 banner | BannerData | null | | type | 预设的几种背景色,可选 default、blue、colour、black | string | default | | icon | 自定义通知icon,type 为default有默认icon | ReactNode | - | | closeIcon | 自定义关闭按钮 | ReactNode | <IconClose /> | | className | 自定义类名 | string | - | | style | 自定义样式 | CSSProperties | - | | onClose | 点击关闭按钮时的回调 | Function | () => {} |

type BannerData = 
    BaseBannerData | // 直接通过 prop 配置
    ({ [x: string]: BaseBannerData;}); // 通过 TCC 配置

interface BaseBannerData {
  zh?: DataItem;
  en?: DataItem;
  style?: React.CSSProperties;
}

interface DataItem {
  title?: string;
  href?: string; // 完整的 url 链接
  path?: string; // 没有域名的 url 链接,用于站内跳转
}