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

🐛 amp-story-shopping removes support for different multi-line border radii #37817

Merged
merged 6 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions extensions/amp-story-shopping/0.1/amp-story-shopping-tag.css
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ amp-story-shopping-tag {
.i-amphtml-amp-story-shopping-tag-pill {
--i-amphtml-pill-icon-size: 24px !important;
--i-amphtml-pill-padding-inline-start: 6px !important;
--i-amphtml-pill-transfrom-origin: calc(var(--i-amphtml-pill-padding-inline-start) + var(--i-amphtml-pill-icon-size) * .5) !important;
--i-amphtml-pill-transform-origin: calc(var(--i-amphtml-pill-padding-inline-start) + var(--i-amphtml-pill-icon-size) * .5) !important;
display: flex !important;
align-items: center !important;
border-radius: 18px !important;
Expand All @@ -165,7 +165,7 @@ amp-story-shopping-tag {
background-color: var(--i-amphtml-shopping-tag-bg-color) !important;
padding-inline-start: var(--i-amphtml-pill-padding-inline-start) !important;
padding-inline-end: 12px !important;
transform-origin: var(--i-amphtml-pill-transfrom-origin) !important;
transform-origin: var(--i-amphtml-pill-transform-origin) !important;
}

.i-amphtml-amp-story-shopping-tag-inner[active] .i-amphtml-amp-story-shopping-tag-pill {
Expand All @@ -184,7 +184,7 @@ amp-story-shopping-tag {
--clip-path-inset-offset-supports-rtl: inset(0 0 0 calc(100% - 36px) round 30px) !important;

/* Transform origin from center of icon (right side) in RTL. */
transform-origin: calc(100% - var(--i-amphtml-pill-transfrom-origin)) !important;
transform-origin: calc(100% - var(--i-amphtml-pill-transform-origin)) !important;
}

@keyframes i-amphtml-animate-in-sequence-pill {
Expand Down Expand Up @@ -228,12 +228,6 @@ amp-story-shopping-tag {
}
}

.i-amphtml-story-shopping-tag-pill-multi-line {
border-radius: 10px !important;
margin-inline-start: 9px !important;
margin-inline-end: 4px !important;
}

.i-amphtml-amp-story-shopping-tag-pill-image {
width: var(--i-amphtml-pill-icon-size) !important;
height: var(--i-amphtml-pill-icon-size) !important;
Expand Down
42 changes: 0 additions & 42 deletions extensions/amp-story-shopping/0.1/amp-story-shopping-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
childElementByTag,
closestAncestorElementBySelector,
} from '#core/dom/query';
import {computedStyle} from '#core/dom/style';

import {Services} from '#service';

Expand Down Expand Up @@ -169,46 +168,6 @@ export class AmpStoryShoppingTag extends AMP.BaseElement {
return layout === Layout_Enum.CONTAINER;
}

/**
* This function counts the number of lines in the shopping tag
* and sets the styling properties dynamically based on the number of lines.
* @private
*/
styleTagText_() {
const pillEl = this.element.shadowRoot?.querySelector(
'.amp-story-shopping-tag-pill'
);

const textEl = this.element.shadowRoot?.querySelector(
'.amp-story-shopping-tag-pill-text'
);

if (!pillEl || !textEl) {
return;
}

const fontSize = parseInt(
computedStyle(window, textEl).getPropertyValue('font-size'),
10
);
const ratioOfLineHeightToFontSize = 1.5;
const lineHeight = Math.floor(fontSize * ratioOfLineHeightToFontSize);

let numLines = 1;

this.measureElement(() => {
const height = textEl./*OK*/ clientHeight;
numLines = Math.ceil(height / lineHeight);
});

this.mutateElement(() => {
pillEl.classList.toggle(
'i-amphtml-amp-story-shopping-tag-pill-multi-line',
numLines > 1
);
});
}

/**
* @return {!Element}
* @private
Expand Down Expand Up @@ -297,7 +256,6 @@ export class AmpStoryShoppingTag extends AMP.BaseElement {
shoppingSharedCSS + shoppingTagCSS
);
this.hasAppendedInnerShoppingTagEl_ = true;
this.styleTagText_();
this.initializeTagStateListeners_();
}
}