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

@x-edu/all-theme

v0.2.6

Published

[UI 规范说明](https://www.figma.com/design/lWdVoxs1kfi0SzRXCP1C49/%E8%81%9A%E5%90%88%E5%90%8E%E5%8F%B0%E6%94%B9%E7%89%88%E8%AE%BE%E8%AE%A1-%E5%BC%A0%E8%95%8A?node-id=4408-41026)

Downloads

23

Readme

@x-edu/all-theme

UI 规范说明

安装

npm install @x-edu/all-theme

使用

  1. 在 LESS 样式文件中引入样式:
@import '@x-edu/all-theme/dist/default/index.less';
  1. 在项目文件中引入样式:
import '@x-edu/all-theme/dist/default/index.less'
  1. 引入 JSON 格式的样式变量:
import themeVariable from '@x-edu/all-theme/dist/default/index.js';

目前只有一个主题:default

注意:对于非 Fish 4 实现的部分,在引入 LESS 文件后,请根据 UI 规范使用变量覆盖样式。

下面开始处理 Fish 4 的组件样式:

使用 modifyVars 覆盖 Fish 变量

  1. Toolkit 项目,在 gem-mine.config.js 中设置 css.loaderOptions
// 引入 JSON 格式的样式变量
const themeVars = require('@x-edu/all-theme/dist/default/index.js')

module.exports = {
  css: {
    loaderOptions: {
      less: {
        lessOptions: {
          modifyVars: themeVars,
          javascriptEnabled: true
        }
      }
    }
  }
}
  1. Webpack 项目,在 webpack.config.js 中通过 less-loader 配置:
// 引入 JSON 格式的样式变量
const themeVars = require('@x-edu/all-theme/dist/default/index.js')

module.exports = {
  rules: [{
    test: /\.less$/,
    use: [
      'style-loader',
      'css-loader',
      {
        loader: 'less-loader',
        options: {
          lessOptions: { 
            modifyVars: themeVars,
            javascriptEnabled: true
          }
        }
      }
    ]
  }]
}

Fish 样式覆盖

存在覆盖 Fish 变量后,依然无法达到 UI 预期效果的情况,需要引入主题样式对 Fish 组件进行额外的样式覆写。

使用 applyTheme 设置主题

@x-edu/all-theme 提供了两个 API:

  1. applyTheme(themeName, selector = 'body'):重写指定元素下的 Fish 组件样式
  2. removeTheme(themeName, selector = 'body'):移除指定元素下的重写样式
  • themeName (string): 主题名称,'default'(默认主题)。
  • selector (string, 可选): CSS 选择器字符串,默认为 'body'。
使用示例
import { applyTheme, removeTheme } from '@x-edu/all-theme';

// 默认 'body'
// 应用主题 
applyTheme('default');
// 如果需要移除主题
// removeTheme('default');

// id="root"
// applyTheme('default', '#root');
// removeTheme('default', '#root');

在项目文件或 LESS 样式文件中引入主题样式

保证在期望生效页面正确引入即可。如果希望全局生效,请在项目入口文件或全局生效的 LESS 文件中引入。

  1. 在 LESS 样式文件中引入样式:
@import '@x-edu/all-theme/dist/default/index.less';
  1. 在项目文件中引入样式:
import '@x-edu/all-theme/dist/default/index.less'

覆盖效果

引入 @x-edu/all-theme 对 Fish4 的样式覆盖效果

FAQ

Fish 4 组件样式未生效或部分生效。

  1. 是否正确使用了 applyTheme 设置主题,如果设置成功,对应的元素会有类名 'x-edu-all-theme-default'。
  2. 当前页面是否正确引入了主题样式。
  3. 对照 样式覆盖效果文档 确认组件的使用方式是否一致。
  4. 如果用法一致,仍存在样式和截图不一致的情况,请排查项目中是否存在其他覆写样式。

可能存在某些场景未提供支持的情况,可以通过提供的 反馈表 提交问题,以便后续更新和完善。