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

Compiler: Add amp-carousel-0.1 to the builder map #37308

Merged
merged 3 commits into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 7 additions & 2 deletions extensions/amp-carousel/0.1/build-dom.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {devAssert} from '#core/assert';
import {isAmp4Email} from '#core/document/format';
import {isServerRendered} from '#core/dom';
import {escapeCssSelectorIdent} from '#core/dom/css-selectors';
Expand Down Expand Up @@ -43,7 +44,7 @@ function assertDomQueryResults() {
* Builds a carousel button for next/prev.
* @param {Element} element
* @param {{className: string, title: string, enabled: boolean}} options
* @return {?HTMLDivElement}
* @return {HTMLDivElement}
*/
function buildButton(element, {className, enabled, title}) {
/*
Expand Down Expand Up @@ -218,6 +219,7 @@ function buildSlideScrollCarousel(element) {
slidesContainer.setAttribute('aria-live', 'polite');
element.appendChild(slidesContainer);

/** @type {HTMLDivElement[]} */
const slideWrappers = [];
slides.forEach((slide) => {
slide.classList.add(ClassNames.SLIDE);
Expand Down Expand Up @@ -317,13 +319,16 @@ export function getPrevButtonTitle(element, options = {}) {
* - Slides : "Next item in carousel (X of Y)"
*
* @param {*} element
* @param {{prefix: string, index: string, total:string}} param1
* @param {{prefix: string, index?: string, total?:string}} param1
samouri marked this conversation as resolved.
Show resolved Hide resolved
* @return {string}
*/
function getButtonTitle(element, {index, prefix, total}) {
if (isScrollable(element)) {
return prefix;
}
// Slides carousel should always have index/total provided.
devAssert(index);
devAssert(total);
samouri marked this conversation as resolved.
Show resolved Hide resolved

/**
* A format string for the button label. Should be a string, containing two
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/builders.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {buildDom as ampLayoutClassic} from '#builtins/amp-layout/build-dom';

import {applyStaticLayout} from '#core/static-layout';

import {buildDom as ampCarouselClassic1} from '../../extensions/amp-carousel/0.1/build-dom';
import {buildDom as ampFitTextClassic} from '../../extensions/amp-fit-text/0.1/build-dom';

const versionedBuilderMap = {
Expand All @@ -10,6 +11,7 @@ const versionedBuilderMap = {
},
'0.1': {
'amp-fit-text': ampFitTextClassic,
'amp-carousel': ampCarouselClassic1,
Copy link
Contributor

Choose a reason for hiding this comment

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

ampCarouselClassic1 thanks I hate it 😆

},
};

Expand Down