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

No styles for office-ui-fabric-react #9

Closed
bfanger opened this issue Aug 19, 2022 · 2 comments
Closed

No styles for office-ui-fabric-react #9

bfanger opened this issue Aug 19, 2022 · 2 comments

Comments

@bfanger
Copy link
Owner

bfanger commented Aug 19, 2022

Investigate why the styling doesn't work for the stackoverflow demo:

https://stackblitz.com/edit/sveltejs-kit-template-default-prpe6s?file=src/routes/stackoverflow/+page.svelte

@osmanium
Copy link

👍 +1

@bfanger
Copy link
Owner Author

bfanger commented Oct 22, 2022

Related #8

The styling does work, but not for all components, this is because some of the office-ui-fabric-react components inspect and mutate the child components, and in Svelte you're only able to render a slot as-is, access is restricted by design.

This allows Svelte to guaranty encapsulation, which simplifies reasoning about the code, but this breaks some patterns that React uses, like using children as a function or code like this from <Stack>:

var stackChildren = React.Children.map(props.children, function (child, index) {
  if (!child) {
    return null;
  }
  if (_isStackItem(child)) {
    var defaultItemProps = {
      shrink: !disableShrink,
    };
    return React.cloneElement(child, __assign(__assign({}, defaultItemProps), child.props));
  }
  return child;
});

To work around this:
Write a React component that doesn't accept children (of uses the child as-is) and inside this new component you can use the components in the children inspecting/mutating/calling way React allows.

@bfanger bfanger closed this as completed Oct 22, 2022
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

No branches or pull requests

2 participants