Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support link css from shadow dom #12526

Merged
merged 1 commit into from Dec 25, 2023

Conversation

yoyo837
Copy link
Contributor

@yoyo837 yoyo837 commented Dec 23, 2023

All :root css variables are also added under :host to support using link tags to get css vars from Shadow DOM.

If we can take all css variables extracted to a separate single css file and publish, it seems to be an another solution that can be considered.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6bab89f) 89.85% compared to head (89b4dd1) 89.84%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12526      +/-   ##
==========================================
- Coverage   89.85%   89.84%   -0.02%     
==========================================
  Files         257      257              
  Lines        6802     6802              
  Branches     1647     1647              
==========================================
- Hits         6112     6111       -1     
  Misses        366      366              
- Partials      324      325       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chenjiahan
Copy link
Member

Can you provide some example code of using link tags to get css vars?

@yoyo837
Copy link
Contributor Author

yoyo837 commented Dec 24, 2023

Can you provide some example code of using link tags to get css vars?

https://codesandbox.io/p/sandbox/vant-4-issue-template-forked-jk5tdd?file=%2Fsrc%2FApp.vue%3A44%2C18

@yoyo837
Copy link
Contributor Author

yoyo837 commented Dec 24, 2023

Ask a question: Why does each component's css file not include the css of other components it depends on?

For example:
image

@chenjiahan
Copy link
Member

Why does each component's css file not include the css of other components it depends on?

The dependency graph of CSS is automatically generated, which means that we don't need to manually maintain the import order of CSS.

@chenjiahan
Copy link
Member

This is not a documented approach, can we just import the vant/lib/index.css or vant/lib/tabs/style?

<link rel="stylesheet" href="https://unpkg.com/vant@4.8.1/es/tabs/index.css" />

@yoyo837
Copy link
Contributor Author

yoyo837 commented Dec 25, 2023

This is not a documented approach

Yes, I know this.

Can we just import the vant/lib/index.css ?

No, vant/lib/index.css only provides :root css variables, It should to provide :host css variables. This is exactly what the current PR wants to do.

or vant/lib/tabs/style?

No, The link tag cannot use js resources.


Finally, the reason why I asked the question at the above,it is to consider import on demand.

@chenjiahan
Copy link
Member

On-demand importing should not be achieved through the use of the link tag, as the link tag is unable to deduplicate modules or manage the order of the module graph.

@chenjiahan chenjiahan merged commit 562184d into youzan:main Dec 25, 2023
5 checks passed
@yoyo837
Copy link
Contributor Author

yoyo837 commented Dec 25, 2023

On-demand importing should not be achieved through the use of the link tag, as the link tag is unable to deduplicate modules or manage the order of the module graph.

So what are your thoughts on using vant for Shadow DOM? Even if the solution is not perfect, thank you very much.

Although vant has stated that it will not compatible to Shadow DOM, it still hopes to accept this PR. I will write the other build tools or plugins myself to achieve the goal.

@yoyo837
Copy link
Contributor Author

yoyo837 commented Dec 25, 2023

Thanks for merging this.

@yoyo837 yoyo837 deleted the support-shadow-dom-link branch December 25, 2023 02:33
@chenjiahan
Copy link
Member

chenjiahan commented Dec 25, 2023

So what are your thoughts on using vant for Shadow DOM?

I have no idea at the moment as I have no experience with web components, but PRs are welcome for the improvement of Vant's support for web components. 😄

@yoyo837
Copy link
Contributor Author

yoyo837 commented Dec 25, 2023

I will. Thanks for accepting this point.

@yoyo837
Copy link
Contributor Author

yoyo837 commented Jan 3, 2024

Excuse me, when is the next release date?

@chenjiahan
Copy link
Member

I'm going to release a new version this week.

CatsAndMice pushed a commit to CatsAndMice/vant that referenced this pull request Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants