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

Add Custom Icons for Message Bar #10294

Merged
merged 13 commits into from
Sep 13, 2019

Conversation

chang47
Copy link
Contributor

@chang47 chang47 commented Aug 28, 2019

Pull request checklist

Description of changes

Currently the Message Bar uses predefined icons from Fabric. However users might want to customize the icons to be something else. This change adds the ability for the user to pass in a string to override the existing icons with another icon that they have created an icon mapping to

Focus areas to test

Message Bar Page. I specifically checked if adding a new Icon will override the existing ones used.

Microsoft Reviewers: Open in CodeFlow

@chang47
Copy link
Contributor Author

chang47 commented Aug 28, 2019

I have no idea why the extra changelist happened, but I set them all to be none except for the office-oinline-ui one

@chang47
Copy link
Contributor Author

chang47 commented Aug 28, 2019

I pulled from master now and now locally I have a lot of snapshot tests that are failing from things I didn't touch like DetailRows and Nav, any idea on how I can resolve this without updating the snapshot?

Copy link
Member

@kenotron kenotron left a comment

Choose a reason for hiding this comment

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

Not sure what caused the issue with the extra changelist is. Be sure to get to a clean state before running yarn change & yarn update-snapshots. If you hadn't touched this repo for a while, it has been converted to use yarn. If all else fails, there's this new util @ecraig12345 made called yarn scrub that would nuke everything (not checked in, and not part of our repo).

return (
<div className={this._classNames.iconContainer} aria-hidden>
<Icon iconName={this.ICON_MAP[this.props.messageBarType!]} className={this._classNames.icon} />
<Icon iconName={messageBarIcon ? messageBarIcon : this.ICON_MAP[this.props.messageBarType!]} className={this._classNames.icon} />
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this component already has some kind of mechanism to specify icons based on this map. The only problem is that this map is a private const. Perhaps what you should do is add a more generic prop that allows customization of the icon map (iconMap or something). It could override the defaults where appropriate?

@ecraig12345 - looks like you're the code owner. Mind if you chimed in here?

Copy link
Member

Choose a reason for hiding this comment

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

I think I actually prefer keeping the separate prop because it keeps the MessageBar code simpler while still handling the most common cases (and if the consumer wants to pass a different custom icon based on the MessageBarType, they can handle that in their code).

@@ -81,6 +81,18 @@ export interface IMessageBarProps extends React.HTMLAttributes<HTMLElement> {
* Call to provide customized styling that will layer on top of the variant rules.
*/
styles?: IStyleFunctionOrObject<IMessageBarStyleProps, IMessageBarStyles>;

/**
* Custom icon to replace the dismiss icon.
Copy link
Member

Choose a reason for hiding this comment

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

Do you have a specific scenario where you need to change the dismiss icon to something besides an X? I can see why you might need to change the main icon, but using something besides X to close is a bit odd.

Copy link
Contributor Author

@chang47 chang47 Aug 28, 2019

Choose a reason for hiding this comment

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

The specific scenario (and the real reason why I made this change) is that my specific project has the X icons of varying sizes, as a result we don't call our X button "Clear", we would call it something like Clear_16 as an example.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting, can you not just change the font size with styling? (styles.dismissal)

Copy link
Contributor Author

@chang47 chang47 Aug 29, 2019

Choose a reason for hiding this comment

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

My problem is less of the styles/size of the dismiss button, but more that I'm forced to use a specific icon name for the dismiss button.

That and in our own project Clear is defined to be a different icon, so I would like to not interweave our icon names

Copy link
Member

Choose a reason for hiding this comment

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

Interesting. I'm not so enthusiastic about allowing this because it implies that we should do the same on all the other components with close buttons (not going to ask you to do that, but it opens the possibility), and I'm concerned that it sort of invites bad UX patterns (like using something besides an x for a close button). So I'll have to talk to some people about this tomorrow and get back to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good! My only argument against what we do today is that the component has a dependency on a specific close icon that no one would know about unless they look through the code or happen to map all of Fabric's icon.

I don't actually know much about icon mapping process, but I assume its some extra steps that needs to be taken by the consumer.

@chang47
Copy link
Contributor Author

chang47 commented Aug 29, 2019

I ran yarn scrub, but it only removed any untracked changes and not everything I've checked in. I've made a new branch and applied my change, but I still got a request to make all the change files. I decided to just continue with this specific branch.

@ecraig12345
Copy link
Member

What's the output of git remote -v in your repo?

@chang47
Copy link
Contributor Author

chang47 commented Aug 29, 2019

@ecraig12345
Copy link
Member

Interesting, then how are you getting your changes from your local copy to your fork? (https://github.com/chang47/office-ui-fabric-react)

@chang47
Copy link
Contributor Author

chang47 commented Aug 29, 2019

Oops sorry, I was looking at a clone of the original Fabric repo.

Here's the result of the command on my fork:
origin https://github.com/chang47/office-ui-fabric-react.git (fetch)
origin https://github.com/chang47/office-ui-fabric-react.git (push)

@ecraig12345
Copy link
Member

You might be having issues because you're missing an upstream remote pointing to the main OUFR repo. You can add it like this:

git remote add upstream https://github.com/OfficeDev/office-ui-fabric-react.git
git fetch upstream

After doing that, try deleting and re-generating the change files again and hopefully it will work.

@size-auditor
Copy link

size-auditor bot commented Aug 29, 2019

Asset size changes

Project Bundle Baseline Size New Size Difference
office-ui-fabric-react MessageBar 175.768 kB 175.902 kB ExceedsBaseline     134 bytes

ExceedsTolerance Over Tolerance (1024 B) ExceedsBaseline Over Baseline BelowBaseline Below Baseline New New Deleted  Removed 1 kB = 1000 B

Baseline commit: 899983a2838318f02d45ef2d92c03cb188b736bd (build)

@chang47
Copy link
Contributor Author

chang47 commented Aug 29, 2019

That did the trick! Thanks for the help. I've removed the extra change files.

@ecraig12345
Copy link
Member

Great! @kenotron It would be good to add a case in beachball to handle things like this better, when someone has only one remote which is a fork not the main repo. (I think beachball concluded the change files were needed because the fork's master is out of date with OUFR master.) You could potentially detect it by looking at the repository setting in package.json.

@msft-github-bot
Copy link
Contributor

msft-github-bot commented Aug 29, 2019

Component Perf Analysis

No significant results to display.

All results

Scenario Master Ticks PR Ticks Status
BaseButton 801 781
BaseButton (experiments) 1052 1043
DefaultButton 1081 1078
DefaultButton (experiments) 1997 2028
DetailsRow 3498 3458
DetailsRow (fast icons) 3510 3414
DetailsRow without styles 3148 3363
DocumentCardTitle with truncation 33699 34146
MenuButton 1346 1431
MenuButton (experiments) 3603 3702
PrimaryButton 1315 1299
PrimaryButton (experiments) 2134 2092
SplitButton 2924 2966
SplitButton (experiments) 7306 7362
Stack 518 511
Stack with Intrinsic children 1168 1168
Stack with Text children 4482 4460
Text 393 395
Toggle 895 938
Toggle (experiments) 2389 2390
button 68 54

kenotron
kenotron previously approved these changes Aug 30, 2019
@kenotron
Copy link
Member

This change now looks good, @ecraig12345 - can you confirm that this is okay?

@msft-github-bot
Copy link
Contributor

Hello @kenotron!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msft-github-bot) and give me an instruction to get started! Learn more here.

@ecraig12345
Copy link
Member

@kenotron The code issues have been addressed, but there's still the important question of whether this is really an API we want to add (since once we add it, we're stuck with it). I sent you a link on chat to a discussion about that.

@kenotron kenotron dismissed their stale review September 3, 2019 16:55

Code owner requested to approve. I'm dismissing my review.

@chang47
Copy link
Contributor Author

chang47 commented Sep 3, 2019

@ecraig12345 I was wondering if you have reached any conclusion about this. Thanks!

@chang47
Copy link
Contributor Author

chang47 commented Sep 5, 2019

@ecraig12345 @kenotron is there any update on this? I would like to reach a resolution on this as it's a blocking change that I require.

@kenotron
Copy link
Member

kenotron commented Sep 5, 2019

@ecraig12345 is currently on vacation, and she's really the code owner to ultimately make this call. Sorry, I think she'll be back next week.

@chang47
Copy link
Contributor Author

chang47 commented Sep 13, 2019

@ecraig12345 Hi I was wondering if you had a chance to discuss this? Thanks!

Copy link
Member

@ecraig12345 ecraig12345 left a comment

Choose a reason for hiding this comment

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

Approving since I asked David about this and he's okay with it. Really sorry about the delay!

@ecraig12345 ecraig12345 merged commit 9eb184c into microsoft:master Sep 13, 2019
@msft-github-bot
Copy link
Contributor

🎉office-ui-fabric-react@v7.34.0 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Customizable icons in Message bar
4 participants