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

Move platform theming logic from button component into theme #3627

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

acoates-ms
Copy link
Contributor

Currently there is a lot of hidden platform checks in many of our components, which control the appearance outside of the theme. This essentially means that our themes only work on their specific platform.

This change starts to move logic out of internal platform checks and into the theme objects. Eventually this will allow themes to work better across platforms. It also ensures that themes have maximum capabilities. Internally we will need this as we will want to use the win32-theme on the windows platform when we move to fabric.

@Saadnajmi
Copy link
Collaborator

Eventually this will allow themes to work better across platforms.

With some platform specific Platform Colors, I think that was explicitly not a goal when I touched this last. as an fyi

@Saadnajmi
Copy link
Collaborator

Second comment. Moving files from platform specific to not platform specific will mean increased bundle size since metro won't filter them out. I'm not sure that's an issue anymore, but it was the reason we went for platform specific files for tokens everywhere.

@acoates-ms
Copy link
Contributor Author

Second comment. Moving files from platform specific to not platform specific will mean increased bundle size since metro won't filter them out. I'm not sure that's an issue anymore, but it was the reason we went for platform specific files for tokens everywhere.

I dont think any production bundles are going to be including the android theme on win32 for example. However, there will potentially be a larger bundle for users that are only using one component, which will now get a bundle including the theme for all components.


// grab the styled slots
const Slots = useSlots(userProps, (layer) => buttonLookup(layer, toggleButton.state, userProps));
const Slots = useSlots(userProps, (layer) => buttonLookup(layer, toggleButton.state, userProps, theme));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Huh. I'm surprised this needed to be manually added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Surprised that it wasn't already there.. or surprised / questioning the need for the change?

export const defaultButtonTheme = (theme: Theme) =>
({
components: {
Button: immutableMerge<object>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you can, you should probably pull the names here from the exported buttonName, etc. from the component

Copy link
Contributor Author

Choose a reason for hiding this comment

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

default-theme cannot depend on Button, because Button depends on framework which depends on default-theme. :(


export const defaultButtonTheme = (theme: Theme) =>
({
components: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the thinking for the older version of the Button? Although it's marked as deprecated we haven;t been able to force everyone off of it yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think we have users outside of win32?
I had to move GDPR to the new button because the older version was relying on some layout behavior we have in win32 that isn't in the other RN platforms. So, the older button would layout incorrectly when I switched to fabric.

So, I guess I'm suggesting forcing people to upgrade before they can move to fabric.

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.

3 participants