Giter Club home page Giter Club logo

Comments (17)

arvinxx avatar arvinxx commented on May 29, 2024 2

@basala 3.1.0-beta.3 应该可以了,有空可以试下。

另外需要注意的是,使用上需要用 createStyles 创建样式,不要裸着搭配 cx + css 使用,因为 cx 方法将无法感知 StyleProvider ,拿不到 Context,也就无法自定义插入容器与样式前缀。emotion中也有相关讨论(https://github.com/emotion-js/emotion/issues/2409)

相应的 Demo 示例:https://codesandbox.io/s/compassionate-lehmann-klo7ke

因此如果要保证所有样式都能被 StyleProvider 容器管理到,就不要使用 instance 默认导出的 cx 方法来创建样式,只使用 createStyles 即可。

不过从常规使用来说,如果需要消费和使用 antd 的 token 和自定义 token 、主题相关的能力,应该默认都会使用 createStyles 来获得动态性。

from antd-style.

arvinxx avatar arvinxx commented on May 29, 2024 1

OK,我检查下

from antd-style.

taiyangzaitianshang avatar taiyangzaitianshang commented on May 29, 2024 1

@arvinxx 感谢修复,但虽然这个版本确实是修复了在createInstance时指定container的场景,styleProvider传container也确实影响了Antd的组件。
但是如果我未在createInstance时指定container。而是在StyleProvider中指定container,这样antd-style做的组件还是没有被影响到。就是问题里贴的demo的那个场景
image
demo链接

from antd-style.

arvinxx avatar arvinxx commented on May 29, 2024 1

@taiyangzaitianshang 的确,这个还是个 edge case,我再看下怎么修复下

from antd-style.

arvinxx avatar arvinxx commented on May 29, 2024 1

@taiyangzaitianshang @basala 久等了,再试下 3.1.0-beta.1 ,应该支持好了

from antd-style.

arvinxx avatar arvinxx commented on May 29, 2024 1

还有一个场景下有问题,同一个组件想在同一个页面的两个不同地方使用,一处是正常引用,style标签插在header中,另一处是在页面中的iframe里去引入这个组件,通过styleProvider来配置插入位置,同时传了cache来放置样式插入的缓存,但是设置的cache貌似不生效,当在header中有样式之后iframe就不会在重复插入了,demo链接: https://codesandbox.io/s/awesome-buck-248nu1?file=/src/Demo.tsx

这个感觉可能不太好搞,原因是 emotion 的插入方式是通过判断是否有插入过相应 key 下的 hash来做。如果key和hash一致,就不会再插入了。所以 Provider 上应该要改下相应的key 可能才行。不过我不确定现在的版本支不支持。晚些时候我试验下

from antd-style.

basala avatar basala commented on May 29, 2024

遇到了这个问题 +1,用createInstance创建的styleProvider直接包住antd里的组件,样式还是会被加在header里,如果是直接用
@ant-design/cssinjs里的styleProvider可以成功指定container

from antd-style.

github-actions avatar github-actions commented on May 29, 2024

🎉 This issue has been resolved in version 3.0.1-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

from antd-style.

arvinxx avatar arvinxx commented on May 29, 2024

@taiyangzaitianshang 来试试这个版本。

Demo:https://codesandbox.io/s/practical-benz-mhcxse?file=/src/Demo.tsx

from antd-style.

basala avatar basala commented on May 29, 2024

试了下最新的,在createInstance时指定可以了。但是有一个场景无法满足,组件库里用createInstance暴露出的createStyles定义好了样式,想在不同的业务场景下指定不同的插入位置,能否像@ant-design/cssinjs一样,业务上在组件外部包一层StyleProvider并设置container来实现?

from antd-style.

basala avatar basala commented on May 29, 2024

@arvinxx

非常感谢!本地验证了已经可以正确配置插入位置了,还有一个小问题,类型丢了,看了下node_modules里没有.d.ts文件了
image

from antd-style.

taiyangzaitianshang avatar taiyangzaitianshang commented on May 29, 2024

@taiyangzaitianshang @basala 久等了,再试下 3.1.0-beta.1 ,应该支持好了

歪瑞古德,辛苦了

from antd-style.

basala avatar basala commented on May 29, 2024

还有一个场景下有问题,同一个组件想在同一个页面的两个不同地方使用,一处是正常引用,style标签插在header中,另一处是在页面中的iframe里去引入这个组件,通过styleProvider来配置插入位置,同时传了cache来放置样式插入的缓存,但是设置的cache貌似不生效,当在header中有样式之后iframe就不会在重复插入了,demo链接:
https://codesandbox.io/s/awesome-buck-248nu1?file=/src/Demo.tsx

from antd-style.

arvinxx avatar arvinxx commented on May 29, 2024

非常感谢!本地验证了已经可以正确配置插入位置了,还有一个小问题,类型丢了,看了下node_modules里没有.d.ts文件了

father 最新版 4.2.0 的版本导致类型丢失了,我先锁了 4.1.9。重新发一个:afd06b3

from antd-style.

taiyangzaitianshang avatar taiyangzaitianshang commented on May 29, 2024

@basala 试下 3.1.0-beta.3 应该可以了,有空可以试下。

另外需要注意的是,使用上需要用 createStyles 创建样式,不要裸着搭配 cx + css 使用,因为 cx 方法将无法感知 StyleProvider ,拿不到 Context,也就无法自定义插入容器与样式前缀。emotion中也有相关讨论(https://github.com/emotion-js/emotion/issues/2409)

因此如果要保证所有样式都能被 StyleProvider 容器管理到,就不要使用 instance 默认导出的 cx 方法来创建样式,只使用 createStyles 即可。

不过从常规使用来说,如果需要消费和使用 antd 的 token 和自定义 token 、主题相关的能力,应该默认都会使用 createStyles 来获得动态性。

Demo:https://codesandbox.io/s/compassionate-lehmann-klo7ke

确实,按照文档做的话,应该都是用的createStyles,不会去用cx

from antd-style.

basala avatar basala commented on May 29, 2024

@basala 3.1.0-beta.3 应该可以了,有空可以试下。

另外需要注意的是,使用上需要用 createStyles 创建样式,不要裸着搭配 cx + css 使用,因为 cx 方法将无法感知 StyleProvider ,拿不到 Context,也就无法自定义插入容器与样式前缀。emotion中也有相关讨论(https://github.com/emotion-js/emotion/issues/2409)

相应的 Demo 示例:https://codesandbox.io/s/compassionate-lehmann-klo7ke

因此如果要保证所有样式都能被 StyleProvider 容器管理到,就不要使用 instance 默认导出的 cx 方法来创建样式,只使用 createStyles 即可。

不过从常规使用来说,如果需要消费和使用 antd 的 token 和自定义 token 、主题相关的能力,应该默认都会使用 createStyles 来获得动态性。

非常感谢!!!本地验证后可以实现了,感谢大佬👍👍👍

from antd-style.

github-actions avatar github-actions commented on May 29, 2024

🎉 This issue has been resolved in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from antd-style.

Related Issues (20)

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.