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: slot provider #835

Merged
merged 1 commit into from
Nov 19, 2024
Merged

feat: slot provider #835

merged 1 commit into from
Nov 19, 2024

Conversation

geokaralis
Copy link
Contributor

@geokaralis geokaralis commented Oct 7, 2024

Description

<SlotProvider /> manages and provides slot props to its descendants. It allows for the definition and inheritance of props for named slots in a component tree.

Example

// Register component with the useSlotProps() hook
function Button(props) {
  props = useSlotProps(props, 'button');

  return (
    <button {...props}>{props.children}</button>
  );
}

function ButtonsWithPadding(props) {
  return (
    <SlotProvider slots={{ button: { style: { padding: '1rem' } } }}>
      {props.children}
    </SlotProvider>
  )
}

// Somewhere in the app
<ButtonsWithPadding>
  <Button>Button 1</Button> // Gets 1rem padding
  <Button>Button 2</Button> // Gets 1rem padding
</ButtonsWithPadding>

Copy link

sonarqubecloud bot commented Oct 7, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@geokaralis geokaralis mentioned this pull request Oct 7, 2024
@geokaralis geokaralis marked this pull request as ready for review October 10, 2024 14:09
@geokaralis geokaralis requested a review from a team as a code owner October 10, 2024 14:09
@geokaralis geokaralis force-pushed the feat/CDP-308-slot-provider branch from 06bed9f to fa1fa3f Compare November 19, 2024 11:11
@geokaralis geokaralis merged commit cf56542 into master Nov 19, 2024
15 checks passed
@geokaralis geokaralis deleted the feat/CDP-308-slot-provider branch November 19, 2024 11:17
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.

2 participants