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

Update styling for empty button and date picker icon #1342

Merged
merged 5 commits into from
Aug 16, 2024

Conversation

ps48
Copy link
Member

@ps48 ps48 commented Aug 13, 2024

Description

Update styling for empty button and date picker icon alignments issues:

to the left of the search bar is the save icon. it feels 1px lower than middle and 1px left of center.

Issues Resolved

  • Enables button icon to be in right line-height based.
  • Reduces the spacing in between calendar button and pop over icon in super date picker

Before:
Screenshot 2024-08-14 at 10 57 40 AM
After:
Screenshot 2024-08-14 at 10 56 39 AM

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • All tests pass
    • yarn lint
    • yarn test-unit
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Collaborator

@virajsanghvi virajsanghvi left a comment

Choose a reason for hiding this comment

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

just some early feedback

.ouiFormControlLayout__prepend{
.ouiQuickSelectPopover__buttonText {
// Override specificity from universal and sibling selectors
margin-right: calc($ouiSizeXS/2) !important;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do you need calc when this will resolve to a value?

Also, how did you determine this size?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, this is how it is done in rest of OUI rather than using constants. This approach may be helpful in making things extensible when a theme comes in and changes the $ouiSizeXS from 4px to 8px. Other places using this:
https://github.com/search?q=repo%3Aopensearch-project%2Foui+calc%28%24ouiSizeXS+%2F+2%29&type=code

Please let me know if this isn't recommended can hard code to margin-right: 2px

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, my point is that calc is a css function, but I believe, maybe wrong, that the expression $ouiSize/2 will be evaluated by sass first, so the resulting css will be margin-right: calc(2px) !important - basically my point is I don't think calc is doing anything here, and not sure how it helps make it extensible unless we had css variables.

@@ -96,6 +96,7 @@ $ouiButtonEmptyTypes: (
// Ghost is unique and ALWAYS sits against a dark background.
color: $color;
} @else if ($name == 'text') {
line-height: inherit;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the goal for empty buttons to be aligned with other text? How does this impact alignment with other buttons?

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, updated to parent class ouiButtonEmpty. Also, this only impacts ouiButtonEmpty which brings this component inline with other button icons:
Screenshot 2024-08-14 at 11 21 46 AM
Screenshot 2024-08-14 at 11 21 53 AM
Screenshot 2024-08-14 at 11 22 05 AM

ps48 added 2 commits August 14, 2024 10:18
Signed-off-by: Shenoy Pratik <[email protected]>
@ps48 ps48 marked this pull request as ready for review August 14, 2024 18:34
Comment on lines 26 to 28
.ouiQuickSelectPopover__buttonText {
// Override specificity from universal and sibling selectors
margin-right: $ouiSizeXS !important;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see that the new rule applies to elements with classname ouiQuickSelectPopover__buttonText when inside a prepend but it removes the rule that applied margin to all other elements with classname ouiQuickSelectPopover__buttonText. Shouldn't we retain that? Are we not breaking anything else by removing this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did check it, every repo in the opensearch-project is using this class for date-picker. It is only dashboards which is using this class for the save button.

Class references: https://github.com/search?q=org%3Aopensearch-project+euiQuickSelectPopover__buttonText&type=code

Copy link
Collaborator

@virajsanghvi virajsanghvi Aug 14, 2024

Choose a reason for hiding this comment

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

is this class only used by explicit classname or is it applied by a component? If by component, I'm not sure if your search is sufficient for usage.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted to original class. Reasoning based on offline discussion with @AMoo-Miki since, OUI is a styling library:

  1. It is expected users can use anything/everything exposed by OUI from components to styling.
  2. We shouldn’t break existing stuff for plugins/core or community partners

.ouiQuickSelectPopover__buttonText {
// Override specificity from universal and sibling selectors
margin-right: $ouiSizeXS !important;
.ouiFormControlLayout__prepend{
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: space before {?

Copy link
Member Author

Choose a reason for hiding this comment

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

removed the prepend class based on Miki's comment

Comment on lines 26 to 28
.ouiQuickSelectPopover__buttonText {
// Override specificity from universal and sibling selectors
margin-right: $ouiSizeXS !important;
Copy link
Collaborator

@virajsanghvi virajsanghvi Aug 14, 2024

Choose a reason for hiding this comment

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

is this class only used by explicit classname or is it applied by a component? If by component, I'm not sure if your search is sufficient for usage.

.ouiFormControlLayout__prepend{
.ouiQuickSelectPopover__buttonText {
// Override specificity from universal and sibling selectors
margin-right: calc($ouiSizeXS/2) !important;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, my point is that calc is a css function, but I believe, maybe wrong, that the expression $ouiSize/2 will be evaluated by sass first, so the resulting css will be margin-right: calc(2px) !important - basically my point is I don't think calc is doing anything here, and not sure how it helps make it extensible unless we had css variables.

@ps48
Copy link
Member Author

ps48 commented Aug 15, 2024

@virajsanghvi Without the calc function I see deprecation warning from Sass:

Deprecation Warning: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div($ouiSizeXS, 2) or calc($ouiSizeXS / 2)

More info and automated migrator: https://sass-lang.com/d/slash-div

   ╷
28 │   margin-right: $ouiSizeXS/2 !important;
   │                 ^^^^^^^^^^^^
   ╵

Signed-off-by: Shenoy Pratik <[email protected]>
Copy link
Collaborator

@virajsanghvi virajsanghvi left a comment

Choose a reason for hiding this comment

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

Approving assuming it passes checks

@AMoo-Miki AMoo-Miki merged commit d2bea6f into opensearch-project:main Aug 16, 2024
16 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 16, 2024
* update styling for empty button and date picker icon

Signed-off-by: Shenoy Pratik <[email protected]>

* move line-height to empty button class

Signed-off-by: Shenoy Pratik <[email protected]>

* update changelog

Signed-off-by: Shenoy Pratik <[email protected]>

* remove specificity for QuickSelectPopover

Signed-off-by: Shenoy Pratik <[email protected]>

* fix formatting in for calc

Signed-off-by: Shenoy Pratik <[email protected]>

---------

Signed-off-by: Shenoy Pratik <[email protected]>
(cherry picked from commit d2bea6f)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
AMoo-Miki pushed a commit that referenced this pull request Aug 16, 2024
* update styling for empty button and date picker icon

Signed-off-by: Shenoy Pratik <[email protected]>

* move line-height to empty button class

Signed-off-by: Shenoy Pratik <[email protected]>

* update changelog

Signed-off-by: Shenoy Pratik <[email protected]>

* remove specificity for QuickSelectPopover

Signed-off-by: Shenoy Pratik <[email protected]>

* fix formatting in for calc

Signed-off-by: Shenoy Pratik <[email protected]>

---------

Signed-off-by: Shenoy Pratik <[email protected]>
(cherry picked from commit d2bea6f)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

3 participants