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 🙏

© 2026 – Pkg Stats / Ryan Hefner

antd-dual-theme-manager

v0.0.2

Published

基于Ant Design的多版本主题管理库,轻松实现主题切换与定制;A multi-version theme management library for Ant Design, enabling easy theme switching and customization.

Readme

Antd Dual Theme Manager

一个用于统一管理 antd@4 与 antd@5 主题风格的方案。

安装

pnpm add ntd-dual-theme-manager

使用

import React from 'react'
import ReactDOM from 'react-dom/client'
import { ThemeManager } from 'antd-dual-theme-manager'
import { StyleProvider, legacyLogicalPropertiesTransformer } from '@ant-design/cssinjs'
import { App } from 'antd'
import zhCN from 'antd/locale/zh_CN'
import zhCN4 from 'antd4/es/locale/zh_CN'
import 'dayjs/locale/zh-cn' // for antd@5 date-picker i18n
import { ThemeManager } from 'lib/index'
import Playground from './Playground'
import moment from 'moment'
import 'moment/dist/locale/zh-cn' // for antd@4
moment.locale('zh-cn')

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
root.render(
  <React.StrictMode>
    <ThemeManager
      locale={zhCN}
      prefixCls='asd'
      iconPrefixCls='zxc'
      seedToken={{
        colorPrimary: '#3f51b5',
        colorInfo: '#0288d1',
        colorSuccess: '#2fad35',
        colorWarning: '#ed6c02',
        colorError: '#d32f2f',
        borderRadius: 8,
      }}
      configProviderProps4={{ locale: zhCN4 }}
    >
      <StyleProvider hashPriority='high' transformers={[legacyLogicalPropertiesTransformer]}>
        <App component={false}>
          <Playground />
          <div id='portal-root'></div>
        </App>
      </StyleProvider>
    </ThemeManager>
  </React.StrictMode>
)

更改主题

import { UpdaterContext } from 'lib/index'

export default function App() {
  const themeUpdater = useContext(UpdaterContext)

  return (
    <div>
      <button onClick={() => themeUpdater.updateThemeMode('dark')}>暗色模式</button>
      <button onClick={() => themeUpdater.updatePrefix({ prefixCls: 'custom' })}>更改class前缀</button>
      <button onClick={() => themeUpdater.updateSeedToken({ colorPrimary: '#409EFF' })}>更改主题色</button>
    </div>
  )
}

使用 antd-style 编写样式,以使用主题变量

在大屏业务组件中,可以通过 ResponsiveScalecontext 获取必要尺寸参数和尺寸计算方法。

// styles.ts
import { createGlobalStyle, createStyles, css } from 'antd-style'

export const useStyles = createStyles(utils => {
  const { token, css } = utils // cx, appearance, isDarkMode, prefixCls, iconPrefixCls 等

  const commonCard = css`
    border-radius: ${token.borderRadiusLG}px;
    padding: ${token.paddingLG}px;
  `

  // 支持对象和模版字符串两种写法
  return {
    container: {
      backgroundColor: token.colorBgLayout,
      padding: token.paddingMD,
      border: `1px solid ${token.colorBorder}`,
    },

    baseCard: commonCard,

    primaryCard: css`
      background: ${token.colorPrimary};
      color: ${token.colorTextLightSolid};
    `,

    defaultCard: css`
      ${commonCard};
      background: ${token.colorBgContainer};
      color: ${token.colorText};
    `,
  }
})
// CustomCard.tsx
import { useStyles } from './styles'

const CustomCard: React.FC = () => {
  const { styles } = useStyles()

  return (
    <div className={styles.container}>
      <Space direction='vertical' style={{ width: '100%' }} size={16}>
        <div className={styles.defaultCard}>普通卡片</div>
        <div className={cx(styles.baseCard, styles.primaryCard)}>主要卡片</div>
      </Space>
    </div>
  )
}