-
Notifications
You must be signed in to change notification settings - Fork 77
Styled attribute styles with multiple entries #33
Comments
Hi @dpoerschke! 'Tak' for showing interest in Direflow and creating this issue 🙂 This is not a bug. The <Styled styles={[ styles, semanticui ]}> However, that is not currently supported either, but could be a nice feature. SolutionTo get a solution going at the moment, try stringifying both styles and concatenating them. <Styled styles={`${styles} ${semanticui}`}> It's not quite as pretty as the array-solution, but it should work. Update 1:Yes, the external-loader can partially solve this problem, however, it is best to import the .css as a module which will be built into the bundle at compile-time, rather than loaded at runtime. Update 2:Under normal circumstances, this would work, yes. I hope this clears things up a bit 😊 |
Thank you very much for your explanations @silind and for changing this to a feature-request 🙂 Your solution
worked (the result is the same as with the external-loader approach). The only thing left which gives me a headache now is the problem regarding semanticui's missing icons. Since you wrote..
..I added semantic.min.css and icon.min.css now directly to my project instead of using a npm-package (I hope I did not misunderstood you):
... after that I got compile errors because the font-files where missing (sure, I expected that). I added those fonts as well to the project and the error-messages dissapeared. But after reloading the page in the browser the icons are still missing (that surprised me). Is it possible that direflow ignores font-files referenced by css-sheets? At least the given info in the doc makes me guess so (I know, it's about external-loader but maybe the styles-attribute of Styled works similar.. I don't know):
When I build my project, the direflowBundle.js is about 3.086 KB. If I remove the imports from above and change Styled back to Any ideas how to make icons work? Not sure if I'm doing something wrong here or if what I'm trying to do is just not supported. |
Ok, I see. Is your project public? If yes, would you mind pasting a link to the project here, so I can have a closer look? - Otherwise, I will try to use your reproduction steps above. |
Sure, thank you very much for having a look into it :-) |
Thanks a lot for creating a problem demo 👍 I've been investigating this problem, and it turns out, that it is a well know problem with webfonts (which are used for the icons) and the shadow DOM implementation. Currently, the best fix for this problem is to disable the shadow root for your component. On another note, you can now use the icon pack from material design. On a whole other note, the initial request of this issue is now included in the newest version of Direflow. <Styled styles={[ styles, semanticui ]}> I will close this issue since it was originally about providing multiple styles, but I'll open another issue regarding the icon issue. |
At first 'mange tak!' for this cool project @silind :-) I'm not sure if this is a bug - just in case that it is not can you please consider it as feature request? Otherwise: what could be a solution to this problem?
Describe the bug
When using multiple entries for styles-attribute of Styled-Element only the last one is used, the first will be ignored:
<Styled styles={styles, semanticui}>
To reproduce
Steps to reproduce the behavior:
Expected behavior
Both styles, 'styles' and 'semanticui', should take effect.
Package Manager:
To install Direflow, I used npm
Update 1:
As a workaround I'm currently using the external-loader (https://direflow.io/plugins#external-loader) to load semantic via CDN instead of packaging it with my react-component. The only problem is that with this workaround no icons (semantic includes fontawesome) are displayed.
Update 2:
Just adding
import 'semantic-ui-css/semantic.min.css';
at the top of App.js is not working as well when using direflow. In my original react-app it is working that way.
The text was updated successfully, but these errors were encountered: