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(DrawerContent): removed no-background colorVariant #629

Merged

Conversation

thatblindgeye
Copy link
Collaborator

Closes #624

Also types findVariableDeclaration helper and adds some other helpers.


The "no-background" value of the `colorVariant` prop on DrawerContent has been removed, and a new "primary" value has been added.

Additionally, a new DrawerContentColorVariant enum has been added and should be used instead of the DrawerColorVariant enum. The fix when the DrawerColorVariant enum is being used will replace the `colorVariant` prop value with a string.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just a note, the logic in the rule for this part will cause the drawerReplaceColorVariantLight200 rule output file to be updated further because of this (current output has the second DrawerContent updated to colorVariant={DrawerColorVariant.secondary}, this rule will cause the output to be updated to colorVariant="secondary". I can remove this logic if we want to avoid that, or I can update the input/output files to prevent the update from happening every time.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am OK with this rule updating the drawerReplaceColorVariantLight200 output example. Something similar happens with the chipReplaceWithLabel updating the output of chipDeprecated. We just should be careful of which files are we adding to commits, so we accidentally don't change these output files on the "production" branch.

Copy link
Contributor

@adamviktora adamviktora left a comment

Choose a reason for hiding this comment

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

Great job on this!

Few comments below, the most important to me is to add an option to getAttributeValue and then the possible refactoring of getVariableValue so it does not return any (but this change would require some type checking in the rule then).

}

const variableInit = variableDeclaration.defs.length
? variableDeclaration.defs[0].node.init
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we check that the type of variableDeclaration.defs[0] equals to "Variable" here? It will then also make the type of variableInit not being any, because the node will be treated as node: VariableDeclarator.

EDIT: after checking it further, it will create some type problems when accessing colorVariantValue.object or colorVariantValue.property, because the colorVariantValue won't have the value of any anymore. So some additional functionality for checking if the return value is of type MemberExpression would be needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can open a followup to address this if you'd like.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure. It probably won't cause any problems for now, since I cannot imagine someone would be passing a function name (or anything other than a variable name) as an attribute value.

Opened a followup issue: #630

Copy link
Collaborator

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

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

🔥

@wise-king-sullyman wise-king-sullyman merged commit fb7076c into patternfly:main Apr 23, 2024
3 checks passed
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.

Drawer - DrawerContent colorVariant
3 participants