Skip to content

Customizable styles update#5134

Merged
dzearing merged 2 commits intomicrosoft:masterfrom
bennettclark:customizable-styles-update
Jun 7, 2018
Merged

Customizable styles update#5134
dzearing merged 2 commits intomicrosoft:masterfrom
bennettclark:customizable-styles-update

Conversation

@bennettclark
Copy link
Copy Markdown
Contributor

@bennettclark bennettclark commented Jun 7, 2018

Pull request checklist

[ ] Include a change request file using $ npm run change

Description of changes

Add style argument to @Customizable decorator

Microsoft Reviewers: Open in CodeFlow

@phkuo
Copy link
Copy Markdown
Contributor

phkuo commented Jun 7, 2018

What's the intention here? I don't think this is correct. The @Customizable is for global state, like the theme, which is generally the same across the entire page. The 'style' is different though, and unique per component.

@mikewheaton
Copy link
Copy Markdown
Contributor

mikewheaton commented Jun 7, 2018

@phkuo: This is to enable us to distribute a set of Fluent component styles, which would be passed into Customizer and then apply to all child components. The idea is for teams to be able to opt-in to the styles and test them easily, before those styles are the new defaults.

See Peter's experiment branch for a closer look at how we're wanting to approach this.

@Jahnp
Copy link
Copy Markdown
Member

Jahnp commented Jun 7, 2018

@phkuo @mikewheaton hit it head-on. This is really to allow deeper, scoped customizations beyond what themes can provide, and pairs with <Customizer>'s scopedSettings.

So for example, we might do something like this to round button corners in a scoped region:

const PrimaryButtonStyles = {
  root: {
    borderRadius: 2,
    boxShadow: '0 2px 4px -0.75px rgba(0, 0, 0, 0.1)'
  }
};


const CompoundButtonStyles = {
  root: {
    borderRadius: 2,
    boxShadow: '0 2px 4px -0.75px rgba(0, 0, 0, 0.1)'
  }
};

const DefaultButtonStyles = {
  root: {
    borderRadius: 2,
    boxShadow: '0 2px 4px -0.75px rgba(0, 0, 0, 0.1)'
  }
};


const NewStyles = {
  PrimaryButton: {
    // Target 'styles' enabled by @customizable('PrimaryButton', ['styles'])
    styles: PrimaryButtonStyles
  },
  DefaultButton: {
    styles: DefaultButtonStyles
  },
  CompoundButton: {
    styles: CompoundButtonStyles
  }
}

export class NewStyledComponent extends React.Component<any, any> {
  public render(): JSX.Element {
    return (
      // Components targeted by NewStyles receive style updates in this region
      <Customizer scopedSettings={ NewStyles }>
        <DefaultButton />
      </Customizer>
    )
  }
}

@mikewheaton
Copy link
Copy Markdown
Contributor

@dzearing or @Jahnp: Can we merge this without getting approval from all of the code reviewers?

@micahgodbolt
Copy link
Copy Markdown
Member

yeah, as long as @dzearing is on board, this doesn't change any of the functionality, so wouldn't affect codeowners

@Jahnp
Copy link
Copy Markdown
Member

Jahnp commented Jun 7, 2018

@mikewheaton -- Yup, we can do that, just want to make sure there isn't any harm with changing the examples as well. I don't see how that'd be a problem though.

@phkuo
Copy link
Copy Markdown
Contributor

phkuo commented Jun 7, 2018

@mikewheaton @Jahnp It is my understanding that the 'styles' param was meant to be passed in directly to an INSTANCE of a component. Won't adding it to @Customizable cause any specifically-passed-in 'styles' to be overridden by the 'styles' in the current context, or vice versa? To phrase it more generically, should parameters controlled by @Customizable only be passed in by the Customizer framework? How does it interact with params directly passed into the instance of the component?

const getClassNames = classNamesFunction<ITooltipStyleProps, ITooltipStyles>();

@customizable('Tooltip', ['theme'])
@customizable('Tooltip', ['theme', 'styles'])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This change is the least intrusive, but it's also very repetitive. Would it make sense to default the customizable props to them and styles?

@dzearing
Copy link
Copy Markdown
Member

dzearing commented Jun 7, 2018

@phkuo If you pass in custom styling as a prop, your value will stomp on injected styling. It certainly is a weakness. Let's tackle the "deep merge" scenario separately.

@dzearing dzearing merged commit 790c1da into microsoft:master Jun 7, 2018
oengusmacinog-zz added a commit that referenced this pull request Jun 11, 2018
* TeachingBubble/Coachmark:  Fix TeachingBubble content wrapping to next line unnecessarily  (#5121)

* Fix teaching  bubble breaking text into next line.

* Add change file

* Fix isWide variation of teaching bubble not inheriting max-width.

* Customizable styles update (#5134)

* @Customizable add styles to args

* change log

* Adds webpack-utils package; a fabric-optimized async loader  (#5122)

* adding a new fabric webpack plugin

* adds fabric webpack-utils package

* adds a peer dep definition

* revert office-ui-fabric-react changes and adds a change file

* addressing PR comments

* moving down versions

* api-extractor isn't needed

* added some documentation for the loader

* make sure not to publish for now, will publish after an initial manual push

* adding some non-consequential prettier changes

* Updated README.md so that the instruction is correct

* Update npm version to 5.4.0 (#5137)

* Website: Fix sideEffects for website tree shaking and add notes about testing (#5133)

* Fix sideEffects

* Update readme and add comments for testing minified files process

* Added change files

* Adding built in  local check for index and removing webpack.config bits.

* Fix example app base (#5139)

* Fixing example app base.

* updating change file

* ContextualMenu: fix hover click submenu behavior (#5141)

* ContextualMenu: Remove the ability for click to close a submenu. This aligns with windows behavior

* rush change

* Dropdown accessibility (#5138)

* add listener in Callout for blur

* Revert "add listener in Callout for blur"

This reverts commit bb9c01a.

* add option to active descendant and aria-label to option

* change request file

* update Dropdown snapshot tests after adding aria-label

* Shimmer: adding new component to OUFR (#5067)

* Brings an initial full copy of Shimmer from experiments.

* Fix all imports.
Remove ShimmerTile.

* Rename IStyleFunction to IStyleFunctonOrObject

* Renames getStyles to styles

* Removes all deprecated props and warnings inherited from experiments package.

* Adds markdown documentation.
Adds 1 snapshot test.

* Updates snapshot tests.

* Adds a functional test to Shimmer

* Write a test story-book

* Story-book.

* Adds more stories to the screener tests.

* Adds one more story for custom elements.

* Adds Shimmer to Fabric-website

* Rush change logs.

* Fixes a visual bug noticed in Fabric website.

* Upsss... updates snapshots.

* Formats everything according to new prettier rules.

* More fixes for prettier formating rules.

* Removes enum for verticalAlign prop and replaces it with strings.

* Refactor the width prop to adress feedback.

* Updates the snapshots.

* Removes global styles for examples.

* Fixes screener story for Shimmer.

* Adds native props to the outer container.

* Updates snapshots.

* Fixes CI release job that passes --production flag to webpack-utils' tsc call (#5147)

* adding a build script for webpack-utils because it builds differently than all other packages

* adding change file

* Revert back to npm 5.3.0

* basic setup for Fluent Styles page
@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants