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: Extensions to makeStrictStyles #310

Merged

Conversation

ling1726
Copy link
Member

@ling1726 ling1726 commented Feb 14, 2025

Updates strict styles API to support component level extensions by leveraging generics throughout all the types. Example of usage

const useStrictStyles = makeStrictStyles<typeof Button>({
  strict: {
    alignSelf: 'center',
    // 👇 `maxWidth` only exists when Button style extensions are used
    maxWidth: '100%',
  },
});

// 👇 This is equally valid usage for the `Button` component without enabling component styling extensions
const useStrictStyles = makeStrictStyles({
  strict: {
    alignSelf: 'center',
  },
});

<Button className={strictStyles.strict}>Button</Button>

@ling1726 ling1726 marked this pull request as ready for review February 14, 2025 16:44
@ling1726 ling1726 requested a review from a team as a code owner February 14, 2025 16:44
/**
* This field is only used to allow style extensions for components
*/
overrideFilter?: TExtension;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you could use a symbol to hide this property

@ling1726 ling1726 merged commit c3f7237 into microsoft:main Feb 17, 2025
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.

3 participants