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: allow users to set styles on icons in Vue #4786

Merged

Conversation

lee-chase
Copy link
Member

Closes #4785

Allows user to specify styles dynamically in a Vue template, including overriding individual styles such as 'will-change' where set by default in getAttributes.

Changelog

M packages/icons-vue/tasks/tests/createIconComponent-test.js
M packages/icons-vue/tasks/createIconComponent.js

@lee-chase lee-chase requested a review from a team as a code owner November 27, 2019 15:22
@ghost ghost requested review from asudoh and joshblack November 27, 2019 15:23
@netlify
Copy link

netlify bot commented Nov 27, 2019

Deploy preview for the-carbon-components ready!

Built with commit d606533

https://deploy-preview-4786--the-carbon-components.netlify.com

@netlify
Copy link

netlify bot commented Nov 27, 2019

Deploy preview for carbon-elements ready!

Built with commit d606533

https://deploy-preview-4786--carbon-elements.netlify.com

@netlify
Copy link

netlify bot commented Nov 27, 2019

Deploy preview for carbon-components-react ready!

Built with commit d606533

https://deploy-preview-4786--carbon-components-react.netlify.com

Copy link
Member

@emyarod emyarod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the merge conflict is due to your previous PR, would you mind resolving that conflict?

@lee-chase
Copy link
Member Author

I believe the merge conflict is due to your previous PR, would you mind resolving that conflict?

Merged

@joshblack joshblack requested a review from a team December 5, 2019 00:38
@ghost ghost requested review from dakahn and removed request for a team December 5, 2019 00:38

// convert incoming style attr to object form.
const styleArray = style.split(';').filter(item => item.trim().length > 0);
const styleObj = styleArray.reduce((acc, styleString) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you want to do this at build time versus compile time? In our base component for React we end up just building the object in scope:

https://github.com/carbon-design-system/carbon/blob/master/packages/icon-build-helpers/src/builders/react/components/Icon.js#L12-L14

This value used to derive from the value coming from icon-helpers (e.g. we parsed the string value) but now we just inline it to make things easier.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what you were suggesting @joshblack ?

Copy link
Contributor

@dakahn dakahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do the bit of refactoring @joshblack mentioned and this looks good to me 👍

@joshblack joshblack merged commit 75986f0 into carbon-design-system:master Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User cannot set dynamic styles on an icon in Vue template.
5 participants