Skip to content

Commit

Permalink
Compiler: Add amp-carousel-0.1 to the builder map (#37308)
Browse files Browse the repository at this point in the history
* Compiler: Add amp-carousel-0.1 to the builder map

* typefixes

* ryan is always right.
  • Loading branch information
samouri authored Jan 7, 2022
1 parent bfa2191 commit 85353c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 8 additions & 7 deletions extensions/amp-carousel/0.1/build-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,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 +218,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 @@ -287,9 +288,9 @@ export function buildDom(element) {
/**
* @param {Element} element
* @return {string} The default title to use for the next button.
* @param {{index?: string, total?: string}} options - The default title to use for the previous button.
* @param {{index: string, total: string}} options - The default title to use for the previous button.
*/
export function getNextButtonTitle(element, options = {}) {
export function getNextButtonTitle(element, options) {
const prefix =
element.getAttribute('data-next-button-aria-label') ||
'Next item in carousel';
Expand All @@ -299,10 +300,10 @@ export function getNextButtonTitle(element, options = {}) {

/**
* @param {Element} element
* @param {{index?: string, total?: string}} options - The default title to use for the previous button.
* @param {{index: string, total: string}} options - The default title to use for the previous button.
* @return {string} The default title to use for the previous button.
*/
export function getPrevButtonTitle(element, options = {}) {
export function getPrevButtonTitle(element, options) {
const prefix =
element.getAttribute('data-prev-button-aria-label') ||
'Previous item in carousel';
Expand All @@ -316,8 +317,8 @@ export function getPrevButtonTitle(element, options = {}) {
* - Scrollable: "Next item in carousel"
* - Slides : "Next item in carousel (X of Y)"
*
* @param {*} element
* @param {{prefix: string, index: string, total:string}} param1
* @param {Element} element
* @param {{prefix: string, index: string, total:string}} opts
* @return {string}
*/
function getButtonTitle(element, {index, prefix, total}) {
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,
},
};

Expand Down

0 comments on commit 85353c9

Please sign in to comment.