Giter Club home page Giter Club logo

antd-style's Issues

🐛[BUG] 开启 babel-plugin-antd-style 插件后内部 cx 生成的类名和导出的不一致

🐛 bug 描述

控制台输出:
cx(label): acss-17f3slo
styles.label: acss-1o3nxki-pages-Home-label

💻 复现代码

const useStyles = createStyles(({ css, cx }) => {
  const label = css`
    color: red;
  `;

  const box1 = css`
    &:hover {
      font-weight: 600;

      .${cx(label)} {
        color: green;
      }
    }
  `;

  const box2 = css`
    &:hover {
      font-weight: 600;

      .${cx(label)} {
        color: blue;
      }
    }
  `;

  console.log('cx(label):', cx(label));

  return {
    box1,
    box2,
    label,
  };
});

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

  console.log('styles.label:', styles.label);

  return (
    <>
      <div className={styles.box1}>
        <span className={styles.label}>box1-lable</span>
      </div>
      <div className={styles.box2}>
        <span className={styles.label}>box2-lable</span>
      </div>
    </>
  );
};

© 版本信息

  • antd-style 版本: 3.4.3
  • babel-plugin-antd-style 版本: 1.0.4

👑 [需求] 提供全局的 cx 工具方法

🥰 需求描述

可以从全局导入 cx 方法:

import { cx } from 'antd-style'

场景

有些组件里面用到了全局的 原子类 但又不需要使用 createStyles 创建额外的样式

解决的问题

这样的话我就可以把 classnames 去掉让代码看着舒服一点

🐛[BUG] Vscode报 “ThemeProvider”不能用作 JSX 组件 & 控制台报 Cannot read properties of undefined (reading 'useToken')

🐛 bug 描述

image

image

📷 复现步骤

🏞 期望结果

💻 复现代码

import { createStyles, ThemeProvider } from 'antd-style';

const useStyles = createStyles(({ stylish, cx, css, token }) => {
    return {
        btn: {
            color: 'red'
        }
    };
});


const App = () => {
    const { styles } = useStyles();
    return (
        <div className={styles.btn}>
            按钮
        </div>
    );
};
export default () => {
    return (
        <ThemeProvider>
            <App />
        </ThemeProvider>
    );
};

© 版本信息

  • antd-style 版本: 3.3.0
  • 浏览器环境 chrome
  • 开发环境 Macos

🚑 其他信息

umi4框架 & antd4

🧐[问题] 如何在Gatsby内使用ssr

🧐 问题描述

请问在Gatsby内如何使用ssr, 是否有类似emotion/ssr的api

💻 示例代码

gatsby-ssr.jsx

import * as React from "react";
import { renderToString } from "react-dom/server";
import { extractCritical } from "@emotion/server";
import { cache } from "@emotion/css";
import { CacheProvider } from "@emotion/react";

export const replaceRenderer = ({
  replaceBodyHTMLString,
  bodyComponent,
  setHeadComponents,
}) => {
  const { html, ids, css } = extractCritical(
    renderToString(<CacheProvider value={cache}>{bodyComponent}</CacheProvider>)
  );
  setHeadComponents([
    <style
      key="emotion"
      data-emotion={`css ${ids.join(" ")}`}
      dangerouslySetInnerHTML={{
        __html: css,
      }}
    />,
  ]);
  replaceBodyHTMLString(html);
};

🚑 其他信息

The automated release is failing 🚨

🚨 The automated release from the rc branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the rc branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


No npm token specified.

An npm token must be created and set in the NPM_TOKEN environment variable on your CI environment.

Please make sure to create an npm token and to set it in the NPM_TOKEN environment variable on your CI environment. The token must allow to publish to the registry https://registry.npmjs.org.


Good luck with your project ✨

Your semantic-release bot 📦🚀

🐛[BUG] 编译报错

🐛 bug 描述


ERROR in ./node_modules/core-util-is/lib/util.js 86:0-52
Module not found: Error: Can't resolve 'buffer' in '/projects/node_modules/core-util-is/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "buffer": require.resolve("buffer/") }'
        - install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "buffer": false }

ERROR in ./node_modules/duplexer2/node_modules/safe-buffer/index.js 2:13-30
Module not found: Error: Can't resolve 'buffer' in '/projects/node_modules/duplexer2/node_modules/safe-buffer'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "buffer": require.resolve("buffer/") }'
        - install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "buffer": false }

ERROR in ./node_modules/multipipe/index.js 6:18-47
Module not found: Error: Can't resolve 'stream' in '/projects/node_modules/multipipe'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }

ERROR in ./node_modules/readable-stream/lib/_stream_readable.js 29:13-37
Module not found: Error: Can't resolve 'buffer' in '/projects/node_modules/readable-stream/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "buffer": require.resolve("buffer/") }'
        - install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "buffer": false }

ERROR in ./node_modules/readable-stream/lib/_stream_readable.js 41:13-30
Module not found: Error: Can't resolve 'stream' in '/projects/node_modules/readable-stream/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }

ERROR in ./node_modules/readable-stream/lib/_stream_writable.js 29:13-37
Module not found: Error: Can't resolve 'buffer' in '/projects/node_modules/readable-stream/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "buffer": require.resolve("buffer/") }'
        - install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "buffer": false }

ERROR in ./node_modules/readable-stream/lib/_stream_writable.js 39:13-30
Module not found: Error: Can't resolve 'stream' in '/projects/node_modules/readable-stream/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }

ERROR in ./node_modules/readable-stream/readable.js 1:13-30
Module not found: Error: Can't resolve 'stream' in '/projects/node_modules/readable-stream'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }

ERROR in ./node_modules/readable-stream/readable.js 10:2-36
Module not found: Error: Can't resolve 'stream' in '/projects/node_modules/readable-stream'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }

ERROR in ./node_modules/string_decoder/index.js 22:13-37
Module not found: Error: Can't resolve 'buffer' in '/projects/node_modules/string_decoder'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "buffer": require.resolve("buffer/") }'
        - install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "buffer": false }

ERROR in ./node_modules/through/index.js 1:13-30
Module not found: Error: Can't resolve 'stream' in '/projects/node_modules/through'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }

© 版本信息

  • antd-style 版本: [e.g. 3.4.4]
  • 浏览器环境
  • 开发环境 [e.g. mac OS]

🚑 其他信息

添加antd-style就会报错,移除就恢复正常

🧐[问题]通过ThemeProvider传入customToken,再获取的时有时候为空,请问是什么原因?

🧐 问题描述

通过ThemeProvider传入customToken,内容为compValue为50,在ASDiv组件内,通过createStyles创建useStyles,而函数参数token内,获取的token['compValue']有时候为空。下面有截图

💻 AS-demo

import React from 'react';
import ASDiv from '@/components/ASDiv';
import { ThemeProvider } from 'antd-style';
export default () => {
  return (
    <>
      <ThemeProvider customToken={{ 'compValue': 50 }}>
        <ASDiv/>
      </ThemeProvider>
      <hr />
      <ASDiv/>
    </>
  );
};

💻 ASDiv/index

import React from 'react';
import { createStyles } from 'antd-style';
const useStyles = createStyles(({css, token}) => {
  console.log('token', token['compValue']);
  return {
    myFont: css`
      height: var(--custom-height, 32px);
      font-size: var(--custom-font, 32px);
    `
  }
});
interface IProps {
}
const ASDiv: React.FC<IProps> = () => {
  const {styles } = useStyles();
  
  return (
      <div className={styles.myFont}>
        myFont
      </div>);
};
export default ASDiv;

🚑 其他信息

image

🧐[问题] 样式怎么嵌套呢

🧐 问题描述

const useStyles = createStyles(({ token }) => ({
  resizeHandleOuter: {
    position: 'relative',
    flex: 1,
    marginInline: token.paddingMD,
    backgroundColor: token.colorBgLayout,
    borderRadius: token.borderRadius,
    transition: 'background-color .2s linear',
    [`&[data-resize-handle-active]`]: {
      backgroundColor: token.colorFill
    }
  },
  icon: {
    position: 'absolute',
    width: '1em',
    height: '1em',
    left: 'calc(50% - 0.5rem)',
    top: 'calc(50% - 0.5rem)',
    color: token.colorTextQuaternary,
    fontSize: token.fontSize
  }
}))

我怎么实现 resizeHandleOuter active 时改变 icon 的样式:

  [`&[data-resize-handle-active]`]: {
      backgroundColor: token.colorFill,
      // 这里怎么写呢,还是只能单独用一个 className?
      [`& .icon`]: {
           color: 'red'
       }
    }

🐛[BUG] lint跑不过了

🐛 bug 描述

仓库没有锁版本,CI里自动安装的依赖都是最新的,ant deisign在5.8.0版本的一个改动,把config-provider/context里export出来的MappingAlgorithm这个类型给干掉了,导致lint一直跑不过
image

具体PR见 https://github.com/ant-design/ant-design/pull/43810/files

📷 复现步骤

🏞 期望结果

lint可以跑过,锁版本

💻 复现代码

删掉依赖重新装一次,跑一下pnpm run ci就能复现

© 版本信息

  • antd-style 版本: [e.g. 1.0.0]
  • 浏览器环境
  • 开发环境 [e.g. mac OS]

🚑 其他信息

🧐[问题] appearance 和 themeMode 有什么不同吗?

🧐 问题描述

appearance 和 themeMode 有什么不同吗?为什么不要一个设置就好,什么时候该用 appearance 什么时候该用 themeMode ,感觉全用 themeMode 也可以满足所有场景?

💻 示例代码

🚑 其他信息

🧐[问题] @ant-design/cssinjs 怎么移到 peerDependencies 里面去了?

🧐 问题描述

vite 构建报错:

Failed to resolve import "@ant-design/cssinjs" from "..\..\node_modules\.pnpm\[email protected]_gvtcr5js3etfbgihn2dqh7o57u\node_modules\antd-style\es\index.js". Does the file exist?
13:45:18 [vite] Internal server error: Failed to resolve import "@ant-design/cssinjs" from "..\..\node_modules\.pnpm\[email protected]_gvtcr5js3etfbgihn2dqh7o57u\node_modules\antd-style\es\index.js". Does the file exist?

@ant-design/cssinjs 对用户来讲不应该是透明的吗?

💻 示例代码

🚑 其他信息

5d0d10c

为什么我这么写没起作用, 哪里写错了?

🧐 问题描述

写了一段测试代码, 但是为什么字没有变红?

import React, { useEffect, useRef, useState } from 'react'

import { Layout, Menu, Button } from 'antd';



// style
import { createStyles, css } from 'antd-style'
const useStyles = createStyles({
    head: css`
        color: 'red';
    `
})
// style

const { Content, Sider, Header } = Layout;

export default function MyLayout() {
    const { styles } = useStyles();
    return (
        <Layout>
            <Layout>
                <Sider theme='light'>
                    aaaaa
                </Sider>
                <Layout>
                    <div ><b className={styles.head} >123</b></div>
                    <Content style={{minHeight: '100%', backgroundColor: '#fff'}}>
                        <Button type="primary">11</Button>
                    </Content>
                </Layout>
            </Layout>
        </Layout>
    )
}

123始终是黑色, 打开控制台这个样式是不起作用的
image

🚑 其他信息

👑 className精准定位

🥰 需求描述

当我写完一个样式,我去dom节点查找的时候,无法精准的知道样式加在那个元素上了。全部都是class=“ant-css-XXXX”

🐛[BUG] StyleProvider的container属性不起作用

🐛 bug 描述

StyleProvider的container属性不起作用,主要是iframe中使用组件的场景样式会丢失的问题

📷 复现步骤

1、使用createInstance创建新的样式实例
2、样式实例的API做一个组件,然后用StyleProvider包裹这个组件,并指定container为document.body

🏞 期望结果

组件对应的style标签被插入到document.body中,但是实际上仍然在head中

💻 复现代码

可复现 demo

© 版本信息

  • antd-style 版本: 3.0.0
  • 浏览器环境 chrome
  • 开发环境 windows

🚑 其他信息

image

👑 [需求] 紧凑主题

🥰 需求描述

从代码中看出,主题只支持系统 暗黑和亮色的 假如我想增加紧凑主题是没办法实现的 我想暗黑和紧凑一起使用

🧐 解决方案

是否可以开放algorithm参数给使用者自行增加

🚑 其他信息

🧐 Using with class components

Any chance of using this library with class components?
I tried to make HOC that passes useStyle hook properties to the class component, but now it's not possible to pass classname like className={styles.name} because antd-style generates random class name.

🧐[问题] 迁移过程中 less语法中使用到的 :global 怎么处理

🧐 问题描述

迁移过程中 less语法中使用到的 :global 怎么处理,之前有部分场景需要通过:global 去覆盖组件样式,迁移过程中这部分代码如何处理。

💻 示例代码

:global(.ant-btn-link) {
padding: 0px;
font-size: 12px;
}

🚑 其他信息

antd4 & umi4

👑 [需求] 支持vue版

🥰 需求描述

现在 ant-design-vue 也已经跟上v5的版本了, 希望支持一下vue

🧐 解决方案

🚑 其他信息

🐛[BUG] unmet peer [email protected]: found 18.2.0

🐛 bug 描述

安装依赖时提示:

pnpm add antd-style@beta -w
Packages: +41
+++++++++++++++++++++++++++++++++++++++++
Progress: resolved 276, reused 264, downloaded 12, added 25, done

dependencies:
+ antd-style 3.0.0-beta.8

 WARN  Issues with peer dependencies found
.
└─┬ antd-style 3.0.0-beta.8
  └─┬ use-merge-value 1.0.2
    └── ✕ unmet peer [email protected]: found 18.2.0

📷 复现步骤

🏞 期望结果

💻 复现代码

可复现 demo

© 版本信息

  • antd-style 版本: [e.g. 1.0.0]
  • 浏览器环境
  • 开发环境 [e.g. mac OS]

🚑 其他信息

🧐[使用ThemeProvider方法报错]

🧐 问题描述

使用【create-react-app antd-demo --template typescript】命令安装"antd": "^5.3.2","antd-style": "3.0.0-beta.19",这两个版本依赖包后,想要用【import { ThemeProvider } from "antd-style";】的ThemeProvider方法修改全局样式,但是yarn start后直接提示webpack插件报错,试过很多次,也换过浏览器都不行。没有动过其他地方代码。yarn,pnpm都试过还是没办法。求解决

💻 示例代码

image

🚑 报错截图

微信截图_20230324193131

🧐[问题] css方案 不支持变量嵌套?

🐛 bug 描述

class变量 嵌套生成的css会合并成一个class

.button-wrapper {
  margin-top: 24px;

  ${buttonClass} {
    font-size: 20px;
  }
}

buttonClass 的 样式 会合并到 .button-wrapper里

💻 复现代码

const useStyles = createStyles(({ css }) => {
  const buttonClass = css`
    background-color: #3498db;
    border: none;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    padding: 12px 24px;

    &:hover {
      background-color: #2980b9;
    }
  `

  const containerClass = css`
    display: flex;
    flex-direction: column;
    align-items: center;

    .button-wrapper {
      margin-top: 24px;

      ${buttonClass} {
        font-size: 20px;
      }
    }
  `
  return {
    buttonClass,
    containerClass,
  }
})

function MyComponent() {
 const { styles } = useStyles()

  return (
    <div className={styles.containerClass}>
        <p>Some content here</p>
        <div className="button-wrapper">
          <button className={styles.buttonClass}>Click me</button>
        </div>
      </div>
  );
}

image

© 版本信息

  • antd-style 版本: [e.g. 3.0.0]
  • 浏览器环境
  • 开发环境 [e.g. mac OS]

🐛[BUG] createInstance创建的StyleProvider的props类型不对

🐛 bug 描述

使用createInstance创建的styleProvider的props类型不对

📷 复现步骤

import { legacyLogicalPropertiesTransformer } from "@ant-design/cssinjs";

<StyleProvider transformers={[legacyLogicalPropertiesTransformer]}}></StyleProvider>

transformers提示类型不匹配
image

🏞 期望结果

不会提示类型错误

💻 复现代码

可复现 demo

© 版本信息

  • antd-style 版本: [3.1.0]
  • 浏览器环境 [Chrome]
  • 开发环境 [mac OS]

🚑 其他信息

🧐[问题]组件里面通过createInstance创建的customToken和包在最外层的ThemeProvider的customToken可以融合吗?

🧐 问题描述

1、同时定义ThemeProvider的customToken,内容为a="ThemeProvider.custom"。
2、组件内部定义通过createInstance定义了customToken,内容为a="createInstance.custom"
3、组件在使用时
3.1 如果外部没有包ThemeProvider的话,在组件中createStyles里面获取到的a内容为a="createInstance.custom"。
3.2 如果外部有包ThemeProvider的话,在组件中createStyles里面获取到的a内容为a="ThemeProvider.custom"。
3.3 如果外部有包ThemeProvider的话,但ThemeProvider没有传递a="ThemeProvider.custom",则在组件中createStyles里面获取到的a内容为undefined,请问ThemeProvider的customToken和组件内容的createInstance里面的customToken可以融合吗?这样看起来是互斥的。

💻 示例代码

export default () => {
  return (
    <>
      <ThemeProvider customToken={{ 'a': 'ThemeProvider.custom' }}>
        <ASDiv/>
      </ThemeProvider>
      <hr />
    </>
  );
};
interface LogoListToken {

}

const { createStyles } = createInstance<LogoListToken>({
  customToken: {
    'a': 'createInstance.custom',
  },
});

const useStyles = createStyles(({css, cx, token}) => {
  console.log('a', token['a']);

  return {
     container: css`
          height: 300px;
      `
 }
}

🚑 其他信息

外部有ThemeProvider时
image

外部没有ThemeProvider时
image

外部有ThemeProvider时,但缺少customToken
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.