conversionxl / aybolit

Lightweight web components library built with LitElement.
https://conversionxl.github.io/aybolit/
MIT License
7 stars 8 forks source link

[cxl-notification] #218

Closed anoblet closed 2 years ago

anoblet commented 2 years ago

https://app.clickup.com/t/3d9ttgy

github-actions[bot] commented 2 years ago

size-limit report 📦

Path Size
packages/cxl-ui/pkg/dist-web/cxl-ui-jwplayer.js, packages/cxl-ui/pkg/dist-web/cxl-ui-playbooks.js, packages/cxl-ui/pkg/dist-web/cxl-ui.js 59.3 KB (+0.69% 🔺)
saas786 commented 2 years ago

@anoblet

I will review & test it one last time.

Looks good for now.

saas786 commented 2 years ago

I looked at netlify preview and noticed that x is not aligned correctly in close button. I checked new notification but also GF.

Screenshot 2022-09-22 at 05 47 49 Screenshot 2022-09-22 at 05 48 06 Screenshot 2022-09-22 at 05 48 15

@pawelkmpt its not a part of cxl-notification itself, but rather focused on Gravity Forms styles...

You can see in screenshot below, that margin-top is applied, also it could use smaller font size as well.

chrome_dbothXKzSi

saas786 commented 2 years ago

Issue created for Gravity Forms styles in notification: https://github.com/conversionxl/aybolit/issues/225

pawelkmpt commented 2 years ago

@pawelkmpt its not a part of cxl-notification itself, but rather focused on Gravity Forms styles...

But this part is about notification. x inside the red box is not in the middle.

I looked at netlify preview and noticed that x is not aligned correctly in close button. I checked new notification but also GF.

Screenshot 2022-09-22 at 05 47 49

You can see in screenshot below, that margin-top is applied, also it could use smaller font size as well.

I don't think top margin should have impact on centering x inside the button.

saas786 commented 2 years ago

@pawelkmpt its not a part of cxl-notification itself, but rather focused on Gravity Forms styles...

But this part is about notification. x inside the red box is not in the middle.

I looked at netlify preview and noticed that x is not aligned correctly in close button. I checked new notification but also GF.

Screenshot 2022-09-22 at 05 47 49

You can see in screenshot below, that margin-top is applied, also it could use smaller font size as well.

I don't think top margin should have impact on centering x inside the button.

Close icon is usually at top right, not middle aligned.

We can center align it, but it would only look nice for single line notifications, multiline it would not good aligned or good. chrome_io3kKYHykq

pawelkmpt commented 2 years ago

Close icon is usually at top right, not middle aligned.

We can center align it, but it would only look nice for single line notifications, multiline it would not good aligned or good.

You don't get what I mean by "x inside the red box is not in the middle".

BAD

Screenshot 2022-09-22 at 14 03 51

GOOD Screenshot 2022-09-22 at 14 04 40

saas786 commented 2 years ago

Close icon is usually at top right, not middle aligned. We can center align it, but it would only look nice for single line notifications, multiline it would not good aligned or good.

You don't get what I mean by "x inside the red box is not in the middle".

BAD

Screenshot 2022-09-22 at 14 03 51

GOOD Screenshot 2022-09-22 at 14 04 40

Correct, I didn't understood it :), thanks for re-explaining.

But it still only applicable to GravityForms styles...

See un-paid order notification button, centered.

chrome_tIEVYklaQu

See Gravity Forms notification, and un-paid notifcation buttons, but have same styles applied, only calculated width is different, which is causing it to look mis-aligned.

chrome_YDaUqFatR4


chrome_YykNrP3qHr

So can delegate it to https://github.com/conversionxl/aybolit/issues/225

pawelkmpt commented 2 years ago

Correct, I didn't understood it :), thanks for re-explaining.

But it still only applicable to GravityForms styles...

See un-paid order notification button, centered.

Issue is present for notification as well on mobile screens. I should've mentioned that in the beginning. Tablet and desktop indeed look good.

So can delegate it to https://github.com/conversionxl/aybolit/issues/225

It has to be done here.

Screenshot 2022-09-28 at 10 04 13

Screenshot 2022-09-28 at 10 03 58

anoblet commented 2 years ago

I'm not sure why our styles differ from the Vaadin demo (https://vaadin.com/docs/latest/components/button). It seems to only happen on the gravity forms stories, and not the default one. Applying this rule to the gravity forms stories gives us a button with a centered icon:

vaadin-button {
  min-width: initial;
}
anoblet commented 2 years ago

I found the culprit. This h2 is stretching the button somehow: https://github.com/conversionxl/aybolit/blob/6de178f17450a6a2e868b9c8d994cea14943e4fb/packages/storybook/cxl-ui/cxl-notification/gravity-form.story.js#L17-L20

If you replace this with a simple div, the icon is centered.

anoblet commented 2 years ago

This should be fixed by wrapping the button in a div.

lkraav commented 2 years ago

I found the culprit. This h2 is stretching the button somehow

Why would the button be inside heading? Super weird structure.

anoblet commented 2 years ago

@lkraav

For the default story, I took the structure from the Vaadin demo (https://vaadin.com/docs/latest/components/notification/#error).

Vaadin doesn't recommend long content for notifications (https://vaadin.com/docs/latest/components/notification/#limit-content-length). The Gravity Form story content is pretty large, and I don't believe the demo structure supports it.

saas786 commented 2 years ago

I found the culprit. This h2 is stretching the button somehow

Why would the button be inside heading? Super weird structure.

Its not inside <h2> but rather alongside it, as sibling.

saas786 commented 2 years ago

This should be fixed by wrapping the button in a div.

@anoblet

Patched the <vaadin-button>, I added it to global styles, couldn't find proper selector to make it specific for <cxl-notification>, can you please look into making it so it applies this style when <cxl-notification><vaadin-button>.. its wrapped inside <cxl-notification>.

Inspired from:

firefox_jV57o3dm6p

anoblet commented 2 years ago

@saas786 I had it fixed in the commit I pushed.

The h2 stretches the content so that it spans multiple lines. This affects the dimensions of the button. The reason the default story doesn't have this issue is because it only spans one line. Multiple line notifications are discouraged by Vaadin (https://vaadin.com/docs/latest/components/notification/#limit-content-length) and should probably be replaced with a dialog.

If you really want a multiple line notification, there is no CSS necessary. Wrap the button in a div.

<cxl-notification>
  <h2>...</h2>
  <div>
    <vaadin-button>...</vaadin-button>
  </div>
</cxl-notification>

We should also be using vaadin-icon not iron-icon. iron-icon is deprecated. This was also fixed in my commit.

saas786 commented 2 years ago

@saas786 I had it fixed in the commit I pushed.

I understand the h2 is a sibling of vaadin-button. The h2 stretches the content so that it spans multiple lines. This affects the dimensions of the button. The reason the default story doesn't have this issue is because it only spans one line. Multiple line notifications are discouraged by Vaadin (vaadin.com/docs/latest/components/notification/#limit-content-length) and should probably be replaced with a dialog.

If you really want a multiple line notification, there is no CSS necessary. Wrap the button in a div.

<vaadin-notification>
  <h2>...</h2>
  <div>
    <vaadin-button>...</vaadin-button>
  </div>
</vaadin-notification>

I understood your reasoning, and it was working as well, but markup change is not the solution here, so I discarded it. Please work on css change I pushed to branch, and make it Shadow Dom specific selector for <cxl-notification> so vaadin-notification-card should be target.

We should also be using vaadin-icon not iron-icon. iron-icon is deprecated. This was also fixed in my commit.

iron-icon is from live website, its not hard code, so once we swap out iron-icon with vaadin-icon we can update this story.

anoblet commented 2 years ago

Vaadin appends the notification to the document root. There's no way to specify it came from cxl-notification unless we override https://github.com/vaadin/web-components/blob/ae61027c62ffa7f7d70cfc50e43f333addfc74b6/packages/notification/src/vaadin-notification.js#L123.

The closest rule/selector we can get is:

vaadin-notification-card vaadin-button[theme~="icon"]:not([theme~="tertiary-inline"]) {
  flex: none;
}
pawelkmpt commented 2 years ago

@anoblet can we squash a895dd266f26c9fcd49945232c18256ee6ad2918 and 7420f4489120fdebc6f1bb227f1676c734c02498 ?