-
Notifications
You must be signed in to change notification settings - Fork 21
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(xds)!: avoid overriding consumers theme by xds #1658
Conversation
0a2634f
to
f53ac96
Compare
@@ -27,7 +26,9 @@ export default plugin.withOptions( | |||
* @internal | |||
*/ | |||
return function (helpers: TailwindHelpers) { | |||
helpers.addComponents(deepMerge({}, components(helpers), options?.components?.(helpers))); | |||
helpers.addComponents(deepMerge({}, components(helpers), options?.components?.(helpers)), { | |||
respectPrefix: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, if the consumer wants to have a prefix
on their classes, like 'mm', x classes won't add 'mm' on their class set.
x will have allways 'x-' manually prefixed
content: ['./index.html', './**/*.vue'], | ||
prefix: 'x-', | ||
important: true, | ||
theme: { | ||
extend: {} | ||
}, | ||
plugins: [ | ||
xTailwindCss({ | ||
components() { | ||
return {}; | ||
}, | ||
utilities() { | ||
return {}; | ||
}, | ||
dynamicUtilities() { | ||
return {}; | ||
}, | ||
dynamicComponents() { | ||
return {}; | ||
}, | ||
theme: {} | ||
}) | ||
] | ||
plugins: [xTailwindCss({})] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly how we want to use xPlugin on motive-market project, we don't want to prefix our classes with 'x-' because we are using xds.. we use other plugins and we don't need to prefix anything to make them work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invocation not needed. plugins: [xTailwindCss]
) | ||
} as Config; | ||
theme: { | ||
x: deepMerge( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now we will have a 'x' property on the theme, so we are able there to customize the theme provided by x.
Only x classes will be affected when manipulating styles within the theme.x
block.
isolation++ 👍🏽
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to reference the default theme
of the plugin to allow Tailwind generates the property identifiers like bg
, text
, etc. with the default theme
. The theme under x
is only used to generate the custom properties in the plugin.
function (options = {}) {
const customXTheme = deepMerge(
{ colors: { current: 'currentColor', transparent: 'transparent' } },
xTheme,
options.theme
);
return {
theme: {
extend: customXTheme,
x: customXTheme
}
};
}
Remember to replace all x-bg-...
for bg-...
(some are still pending)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we add the customXTheme to the extend field... aren't we still overriding the default values from the theme with the ones from the x plugin? 🤔
plugins: [ | ||
xTailwindCss({ | ||
components() { | ||
return {}; | ||
}, | ||
utilities() { | ||
return {}; | ||
}, | ||
dynamicUtilities() { | ||
return {}; | ||
}, | ||
dynamicComponents() { | ||
return {}; | ||
}, | ||
theme: {} | ||
}) | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, if I am not wrong, maybe we should keep this part to be able to access to components() within the setups 👀 , I mean ok remove prefix, but I would leave the part regarding the plugins section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm out of context and I didn't probably understand that,
You mean you need this block to do setups? for what purpose ? Could you give me an example ? 🙏🏽
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/x-tailwindcss/src/x-tailwind-plugin/components/badge/circle.ts
Outdated
Show resolved
Hide resolved
content: ['./index.html', './**/*.vue'], | ||
prefix: 'x-', | ||
important: true, | ||
theme: { | ||
extend: {} | ||
}, | ||
plugins: [ | ||
xTailwindCss({ | ||
components() { | ||
return {}; | ||
}, | ||
utilities() { | ||
return {}; | ||
}, | ||
dynamicUtilities() { | ||
return {}; | ||
}, | ||
dynamicComponents() { | ||
return {}; | ||
}, | ||
theme: {} | ||
}) | ||
] | ||
plugins: [xTailwindCss({})] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invocation not needed. plugins: [xTailwindCss]
a091841
to
c330593
Compare
c330593
to
35bfb5e
Compare
35bfb5e
to
39282e5
Compare
39282e5
to
7397219
Compare
Pull request template
Describe the purpose of the change, the specific changes done in detail, and the issue you have fixed.
Motivation and context
Type of change
What is the destination branch of this PR?
Main
How has this been tested?
Tests performed according to testing guidelines:
Checklist: