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

.iui-field handles icon fill #2088

Merged
merged 13 commits into from
Jun 12, 2024
Merged

.iui-field handles icon fill #2088

merged 13 commits into from
Jun 12, 2024

Conversation

FlyersPh9
Copy link
Collaborator

@FlyersPh9 FlyersPh9 commented Jun 4, 2024

Changes

  • Add 3 .iui-field variables:
    • --_iui-field-color-icon
    • --_iui-field-color-icon-hover
    • --_iui-field-color-icon-disabled
  • Colors inherited in button and select.

Testing

  • Ran visual tests.

Docs

n/a

@FlyersPh9 FlyersPh9 marked this pull request as ready for review June 4, 2024 18:23
@FlyersPh9 FlyersPh9 requested review from a team as code owners June 4, 2024 18:23
@FlyersPh9 FlyersPh9 requested review from r100-stack and Ben-Pusey-Bentley and removed request for a team June 4, 2024 18:23
Copy link
Contributor

@Ben-Pusey-Bentley Ben-Pusey-Bentley left a comment

Choose a reason for hiding this comment

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

I am a bit confused about the purpose of this PR. The conversation that this PR is in response to seems to be about adding the icon fill logic into the field file, but this PR only adds a few variables to that file, and leaves all of the logic setting icon fill in the button and select files. Is this what we want?

Copy link
Contributor

@mayank99 mayank99 left a comment

Choose a reason for hiding this comment

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

Adding to @Ben-Pusey-Bentley's comment, this PR looks half-baked. iui-field needs to handle the actual icon fill, most importantly the fact that it changes between default, :hover, and disabled states.

@FlyersPh9
Copy link
Collaborator Author

iui-field needs to handle the actual icon fill

Would it be acceptable to add an .iui-field-icon class? Button uses .iui-button-icon and Select uses .iui-icon, I think we'll need a shared class to apply the fill correctly.

@mayank99
Copy link
Contributor

mayank99 commented Jun 5, 2024

Would it be acceptable to add an .iui-field-icon class?

@FlyersPh9 I don't like the idea of a iui-field-icon class. We already have too many icon classes that need to be consolidated before we add another one.

For this PR, it might be simpler to set the fill in iui-field and inherit it wherever it needs to be used. This way, we get to keep the markup unchanged.

.iui-field {
  //
  fill: var(--_iui-field-state--default, var(--_iui-field-color-icon))
    var(--_iui-field-state--hover, var(--_iui-field-color-icon-hover))
    var(--_iui-field-state--disabled, var(--_iui-field-color-icon-disabled));
}
.iui-button-icon svg {
  fill: inherit;
}

Comment on lines 355 to 372
.iui-button[data-iui-variant='borderless'] {
border-radius: var(--iui-border-radius-round);

> .iui-button-icon {
filter: drop-shadow(0 2px 1px rgba(0, 0, 0, var(--iui-opacity-5)));
}
.iui-tile-thumbnail-picture ~ & {
@include mixins.iui-blur($opacity: 5);
--_iui-field-color-icon: var(--iui-color-white);
--_iui-field-color-icon-hover: var(--iui-color-white);

> .iui-button-icon {
filter: drop-shadow(0 2px 1px rgba(0, 0, 0, var(--iui-opacity-5)));
}

&:hover,
&[data-iui-active='true']:enabled,
&[data-iui-active='true']:enabled:hover,
&[data-iui-active='true']:active {
background-color: rgba(0, 0, 0, var(--iui-opacity-4));
&:hover,
&[data-iui-active='true']:enabled,
&[data-iui-active='true']:enabled:hover,
&[data-iui-active='true']:active {
background-color: rgba(0, 0, 0, var(--iui-opacity-4));
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tile was failing React tests. Looked into it and our CSS demo's HTML structure was not matching React's.

React:

<div class='iui-tile-thumbnail-quick-action'>
  <button class="iui-button iui-button-base iui-field"></button>
</div>

CSS:

<button class="iui-button iui-button-base iui-field iui-tile-thumbnail-quick-action"></button>

Made the changes in CSS demos to match React & had to update the CSS to work properly. The hover state of the buttons overlaying the thumbnail aren't even working properly in prod right now: https://itwin.github.io/iTwinUI/react/?mode=preview&story=tile--all-props

Copy link
Member

Choose a reason for hiding this comment

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

If this is a visual bug fix, we would need css and react changesets for it.

Also, just wondering, since we corrected the css demo page to match what it used to be in react, could that change in the DOM be a breaking change for itwinui-css?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added this to the changesets. Unsure if this warrants a major or not.

@FlyersPh9
Copy link
Collaborator Author

For this PR, it might be simpler to set the fill in iui-field and inherit it wherever it needs to be used. This way, we get to keep the markup unchanged.

This is done. @mayank99 & @Ben-Pusey-Bentley, I think this could use another review now.

packages/itwinui-css/src/button/base.scss Outdated Show resolved Hide resolved
packages/itwinui-css/src/tile/tile.scss Outdated Show resolved Hide resolved
Copy link
Contributor

@Ben-Pusey-Bentley Ben-Pusey-Bentley left a comment

Choose a reason for hiding this comment

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

Looking at your CI output, it looks like the changes that you have made to the CSS tile have also introduced some minor visual changes. It seems to be something with the border of the icon buttons. May want to tweak the CSS tile some more to avoid these visual changes, or you may want to approve some new test images, if you feel that the visual change is fine to keep. Diff:
image

@include mixins.iui-blur($opacity: 5);
--_iui-button-icon-fill: var(--iui-color-white);
.iui-tile-thumbnail-button {
border-radius: 50%;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
border-radius: 50%;
border-radius: var(--iui-border-radius-round);

Feel like this should be changed, but will likely effect visuals tests. If we like this change, I'll make it right at the end to keep image test changes until the last push.

Copy link
Contributor

@mayank99 mayank99 left a comment

Choose a reason for hiding this comment

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

LGTM

.changeset/small-otters-itch.md Outdated Show resolved Hide resolved
@FlyersPh9 FlyersPh9 enabled auto-merge (squash) June 12, 2024 20:30
@FlyersPh9 FlyersPh9 merged commit e131ed7 into main Jun 12, 2024
16 checks passed
@FlyersPh9 FlyersPh9 deleted the jon/field-handles-icon-fill branch June 12, 2024 20:39
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.

4 participants