Comments (17)
@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.
OK,我检查下
from antd-style.
@arvinxx 感谢修复,但虽然这个版本确实是修复了在createInstance时指定container的场景,styleProvider传container也确实影响了Antd的组件。
但是如果我未在createInstance时指定container。而是在StyleProvider中指定container,这样antd-style做的组件还是没有被影响到。就是问题里贴的demo的那个场景
demo链接
from antd-style.
@taiyangzaitianshang 的确,这个还是个 edge case,我再看下怎么修复下
from antd-style.
@taiyangzaitianshang @basala 久等了,再试下 3.1.0-beta.1
,应该支持好了
from antd-style.
还有一个场景下有问题,同一个组件想在同一个页面的两个不同地方使用,一处是正常引用,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.
遇到了这个问题 +1,用createInstance创建的styleProvider直接包住antd里的组件,样式还是会被加在header里,如果是直接用
@ant-design/cssinjs里的styleProvider可以成功指定container
from antd-style.
🎉 This issue has been resolved in version 3.0.1-beta.1 🎉
The release is available on:
Your semantic-release bot 📦🚀
from antd-style.
@taiyangzaitianshang 来试试这个版本。
Demo:https://codesandbox.io/s/practical-benz-mhcxse?file=/src/Demo.tsx
from antd-style.
试了下最新的,在createInstance时指定可以了。但是有一个场景无法满足,组件库里用createInstance暴露出的createStyles定义好了样式,想在不同的业务场景下指定不同的插入位置,能否像@ant-design/cssinjs一样,业务上在组件外部包一层StyleProvider并设置container来实现?
from antd-style.
非常感谢!本地验证了已经可以正确配置插入位置了,还有一个小问题,类型丢了,看了下node_modules里没有.d.ts文件了
from antd-style.
@taiyangzaitianshang @basala 久等了,再试下
3.1.0-beta.1
,应该支持好了
歪瑞古德,辛苦了
from antd-style.
还有一个场景下有问题,同一个组件想在同一个页面的两个不同地方使用,一处是正常引用,style标签插在header中,另一处是在页面中的iframe里去引入这个组件,通过styleProvider来配置插入位置,同时传了cache来放置样式插入的缓存,但是设置的cache貌似不生效,当在header中有样式之后iframe就不会在重复插入了,demo链接:
https://codesandbox.io/s/awesome-buck-248nu1?file=/src/Demo.tsx
from antd-style.
非常感谢!本地验证了已经可以正确配置插入位置了,还有一个小问题,类型丢了,看了下node_modules里没有.d.ts文件了
father 最新版 4.2.0 的版本导致类型丢失了,我先锁了 4.1.9。重新发一个:afd06b3
from antd-style.
@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 来获得动态性。
确实,按照文档做的话,应该都是用的createStyles,不会去用cx
from antd-style.
@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.
🎉 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)
- 🐛[BUG]createStyles的responsive和useResponsive里的断点值好像不一样? HOT 1
- 🐛[BUG]umijs4中增加antd-style报错 HOT 7
- 🐛[BUG] 在 qiankun 中使用 StyleProvider 会导致 antd 组件样式插入位置不正确 HOT 10
- 🐛[BUG] umijs 配置自定义 prefixCls antd-style 无法获取到自定义 prefixCls HOT 5
- 👑 [需求] 能否不依赖 antd HOT 1
- 🧐[问题] 求问怎么使用媒体查询 @media screen HOT 1
- 🧐[问题]createInstance里面的customToken有没有办法从antd token 里面获取值? HOT 1
- 🧐[问题]在nextjs中使用 ConfigProvider 配置的主题token在服务端和客户端值不一致 HOT 2
- 👑 [需求] 是否可以导出umd格式的版本 这样可以和umd版本的antd一起使用 HOT 1
- 🐛[BUG] StyleProvider stylisPlugins 在nextjs中不生效
- 👑 [需求] 是否可以有继承的机制 HOT 1
- 🐛[BUG] createStyles token ts 提示有问题 HOT 5
- 👑 [需求] createStyles传入的函数里面的参数能不能增加antdPrefixCls HOT 1
- Typography.Text 样式闪烁 HOT 2
- 🧐[问题] Antd 被应用于外部库
- 🐛[BUG]nextjs app router,createStyles在服务端未生成style标签导致页面闪烁。 HOT 6
- 👑 [需求]在nextjs中样式提取到静态文件 HOT 1
- 👑 [需求] 运行时有没有办法把css里面的px自动转换为vw? HOT 1
- 🧐[问题]Cannot read properties of null (reading 'useContext') HOT 6
- 🧐[问题] antd-style对不同浏览器的兼容性如何?浏览器版本有要求吗? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from antd-style.