Skip to content

Commit

Permalink
use AmpPreactBaseElement in amp components
Browse files Browse the repository at this point in the history
  • Loading branch information
kvchari committed Dec 9, 2021
1 parent 6aeafb9 commit f28fdbc
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 52 deletions.
8 changes: 4 additions & 4 deletions extensions/amp-accordion/1.0/amp-accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {getWin} from '#core/window';

import {isExperimentOn} from '#experiments';

import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

import {Services} from '#service';

Expand All @@ -18,7 +18,7 @@ import {CSS} from '../../../build/amp-accordion-1.0.css';
const TAG = 'amp-accordion';

/** @extends {PreactBaseElement<BentoAccordionDef.AccordionApi>} */
class AmpAccordion extends PreactBaseElement {
class AmpAccordion extends AmpPreactBaseElement {
/** @override */
init() {
this.registerApiAction('toggle', (api, invocation) =>
Expand All @@ -33,8 +33,8 @@ class AmpAccordion extends PreactBaseElement {

return elementInit(
this.element,
this.mutateProps.bind(this), // eslint-disable-line local/restrict-this-access
this.triggerEvent.bind(this) // eslint-disable-line local/restrict-this-access
this.mutateProps.bind(this),
this.triggerEvent.bind(this)
);
}

Expand Down
9 changes: 5 additions & 4 deletions extensions/amp-base-carousel/1.0/amp-base-carousel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ActionTrust_Enum} from '#core/constants/action-constants';
import {PreactBaseElement} from '#preact/base-element';

import {CSS} from '../../../build/amp-base-carousel-1.0.css';
import {Services} from '#service';
import {createCustomEvent} from '#utils/event-helper';
Expand All @@ -16,12 +16,13 @@ import {
useContexts,
usesShadowDom,
} from './element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

/** @const {string} */
const TAG = 'amp-base-carousel';

/** @extends {PreactBaseElement<BaseCarouselDef.CarouselApi>} */
class AmpBaseCarousel extends PreactBaseElement {
class AmpBaseCarousel extends AmpPreactBaseElement {
/** @override */
constructor(element) {
super(element);
Expand All @@ -45,7 +46,7 @@ class AmpBaseCarousel extends PreactBaseElement {

const {props, slide} = elementInit(
this.element,
this.triggerEvent.bind(this) // eslint-disable-line local/restrict-this-access
this.triggerEvent.bind(this)
);
this.slide_ = slide;
return props;
Expand Down Expand Up @@ -82,7 +83,7 @@ class AmpBaseCarousel extends PreactBaseElement {
this.slide_ = mutationObserverCallback(
this.element,
this.slide_,
this.api().goToSlide.bind(this) // eslint-disable-line local/restrict-this-access
this.api().goToSlide.bind(this)
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-date-countdown/1.0/amp-date-countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {dict} from '#core/types/object';

import {isExperimentOn} from '#experiments';

import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

import {Services} from '#service';

Expand All @@ -20,7 +20,7 @@ import {
/** @const {string} */
const TAG = 'amp-date-countdown';

class AmpDateCountdown extends PreactBaseElement {
class AmpDateCountdown extends AmpPreactBaseElement {
/** @param {!AmpElement} element */
constructor(element) {
super(element);
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-date-display/1.0/amp-date-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {dict} from '#core/types/object';

import {isExperimentOn} from '#experiments';

import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

import {Services} from '#service';

Expand All @@ -19,7 +19,7 @@ import {
/** @const {string} */
const TAG = 'amp-date-display';

class AmpDateDisplay extends PreactBaseElement {
class AmpDateDisplay extends AmpPreactBaseElement {
/** @param {!AmpElement} element */
constructor(element) {
super(element);
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-embedly-card/1.0/amp-embedly-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {dict} from '#core/types/object';

import {isExperimentOn} from '#experiments';

import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

import {userAssert} from '#utils/log';

Expand All @@ -13,7 +13,7 @@ import {Component, layoutSizeDefined, props, usesShadowDom} from './element';
/** @const {string} */
const TAG = 'amp-embedly-card';

class AmpEmbedlyCard extends PreactBaseElement {
class AmpEmbedlyCard extends AmpPreactBaseElement {
/** @override */
init() {
return dict({
Expand Down
5 changes: 3 additions & 2 deletions extensions/amp-facebook/1.0/amp-facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {dashToUnderline} from '#core/types/string';
import {dict} from '#core/types/object';
import {isExperimentOn} from '#experiments';
import {userAssert} from '#utils/log';
import {PreactBaseElement} from '#preact/base-element';

import {
Component,
commentsStaticProps,
Expand All @@ -14,6 +14,7 @@ import {
props,
usesShadowDom,
} from './element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';
import {getBootstrapBaseUrl, getBootstrapUrl} from '../../../src/3p-frame';

/** @const {string} */
Expand All @@ -23,7 +24,7 @@ const LIKE_TAG = 'amp-facebook-like';
const PAGE_TAG = 'amp-facebook-page';
const TYPE = 'facebook';

class AmpFacebook extends PreactBaseElement {
class AmpFacebook extends AmpPreactBaseElement {
/** @override @nocollapse */
static createLoaderLogoCallback(element) {
return createLoaderLogo(element);
Expand Down
5 changes: 3 additions & 2 deletions extensions/amp-fit-text/1.0/amp-fit-text.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import {CSS} from '../../../build/amp-fit-text-1.0.css';
import {isExperimentOn} from '#experiments';
import {userAssert} from '#utils/log';
import {PreactBaseElement} from '#preact/base-element';

import {
Component,
layoutSizeDefined,
props,
shadowCss,
usesShadowDom,
} from './element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

/** @const {string} */
const TAG = 'amp-fit-text';

class AmpFitText extends PreactBaseElement {
class AmpFitText extends AmpPreactBaseElement {
/** @override */
isLayoutSupported(layout) {
userAssert(
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-iframe/1.0/amp-iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {userAssert} from '#utils/log';
import {dict} from '#core/types/object';
import {measureIntersection} from '#core/dom/layout/intersection';
import {Component, layoutSizeDefined, props, usesShadowDom} from './element';
import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

/** @const {string} */
const TAG = 'amp-iframe';
Expand All @@ -12,7 +12,7 @@ const MINIMUM_DISTANCE_FROM_TOP_PX = 600;
/** @const {number} */
const MINIMUM_VIEWPORT_PROPORTION = 0.75;

class AmpIframe extends PreactBaseElement {
class AmpIframe extends AmpPreactBaseElement {
/** @override */
isLayoutSupported(layout) {
userAssert(
Expand Down
5 changes: 3 additions & 2 deletions extensions/amp-inline-gallery/1.0/amp-inline-gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import {Layout_Enum} from '#core/dom/layout';
import {CSS as PAGINATION_CSS} from '../../../build/amp-inline-gallery-pagination-1.0.css';
import {isExperimentOn} from '#experiments';
import {userAssert} from '#utils/log';
import {PreactBaseElement} from '#preact/base-element';

import {Component, ContextExporter, detached, props} from './element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';
import {dict} from '#core/types/object';

/** @const {string} */
const TAG = 'amp-inline-gallery';

class AmpInlineGallery extends PreactBaseElement {
class AmpInlineGallery extends AmpPreactBaseElement {
/** @override */
init() {
return dict({
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-instagram/1.0/amp-instagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {dict} from '#core/types/object';

import {isExperimentOn} from '#experiments';

import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

import {userAssert} from '#utils/log';

Expand All @@ -20,7 +20,7 @@ import {CSS} from '../../../build/amp-instagram-1.0.css';
/** @const {string} */
const TAG = 'amp-instagram';

class AmpInstagram extends PreactBaseElement {
class AmpInstagram extends AmpPreactBaseElement {
/** @override */
isLayoutSupported(layout) {
userAssert(
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-lightbox-gallery/1.0/amp-lightbox-gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {dict} from '#core/types/object';

import {isExperimentOn} from '#experiments';

import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

import {Services} from '#service';

Expand All @@ -35,7 +35,7 @@ const TAG = 'amp-lightbox-gallery';
/** @const {string} */
const DEFAULT_GALLERY_ID = 'amp-lightbox-gallery';

class AmpLightboxGallery extends PreactBaseElement {
class AmpLightboxGallery extends AmpPreactBaseElement {
/** @override */
constructor(element) {
super(element);
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-lightbox/1.0/amp-lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import {
shadowCss,
usesShadowDom,
} from './element';
import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

/** @const {string} */
const TAG = 'amp-lightbox';

/** @extends {PreactBaseElement<LightboxDef.Api>} */
class AmpLightbox extends PreactBaseElement {
class AmpLightbox extends AmpPreactBaseElement {
/** @override */
constructor(element) {
super(element);
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-mathml/1.0/amp-mathml.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {isExperimentOn} from '#experiments';

import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

import {userAssert} from '#utils/log';

Expand All @@ -19,7 +19,7 @@ import {getBootstrapBaseUrl, getBootstrapUrl} from '../../../src/3p-frame';
/** @const {string} */
const TAG = 'amp-mathml';

class AmpMathml extends PreactBaseElement {
class AmpMathml extends AmpPreactBaseElement {
/** @override @nocollapse */
static getPreconnects(element) {
const ampdoc = element.getAmpDoc();
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-selector/1.0/amp-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {getWin} from '#core/window';

import {isExperimentOn} from '#experiments';

import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

import {Services} from '#service';

Expand All @@ -18,7 +18,7 @@ import {CSS} from '../../../build/amp-selector-1.0.css';
/** @const {string} */
const TAG = 'amp-selector';

class AmpSelector extends PreactBaseElement {
class AmpSelector extends AmpPreactBaseElement {
/** @override */
constructor(element) {
super(element);
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-sidebar/1.0/amp-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import {
updatePropsForRendering,
usesShadowDom,
} from './element';
import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

/** @const {string} */
const TAG = 'amp-sidebar';

class AmpSidebar extends PreactBaseElement {
class AmpSidebar extends AmpPreactBaseElement {
/** @override */
static deferredMount(unusedElement) {
deferredMount(unusedElement);
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-social-share/1.0/amp-social-share.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {getWin} from '#core/window';

import {isExperimentOn} from '#experiments';

import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

import {Services} from '#service';

Expand Down Expand Up @@ -125,7 +125,7 @@ const updateTypeConfig = (element, mutations, prevTypeValue) => {
return typeConfig;
};

class AmpSocialShare extends PreactBaseElement {
class AmpSocialShare extends AmpPreactBaseElement {
/** @param {!AmpElement} element */
constructor(element) {
super(element);
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-soundcloud/1.0/amp-soundcloud.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {isExperimentOn} from '#experiments';

import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

import {userAssert} from '#utils/log';

Expand All @@ -15,7 +15,7 @@ import {
/** @const {string} */
const TAG = 'amp-soundcloud';

class AmpSoundcloud extends PreactBaseElement {
class AmpSoundcloud extends AmpPreactBaseElement {
/** @override */
static getPreconnects() {
return preconnects;
Expand Down
9 changes: 3 additions & 6 deletions extensions/amp-stream-gallery/1.0/amp-stream-gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import {
shadowCss,
usesShadowDom,
} from './element';
import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

/** @const {string} */
const TAG = 'amp-stream-gallery';

class AmpStreamGallery extends PreactBaseElement {
class AmpStreamGallery extends AmpPreactBaseElement {
/** @override */
init() {
this.registerApiAction('prev', (api) => api.prev(), ActionTrust_Enum.LOW);
Expand All @@ -32,10 +32,7 @@ class AmpStreamGallery extends PreactBaseElement {
ActionTrust_Enum.LOW
);

return elementInit(
this.element,
this.triggerEvent.bind(this) // eslint-disable-line local/restrict-this-access
);
return elementInit(this.element, this.triggerEvent.bind(this));
}

/** @override */
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-timeago/1.0/amp-timeago.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {isExperimentOn} from '#experiments';

import {PreactBaseElement} from '#preact/base-element';
import {AmpPreactBaseElement} from '#preact/amp-base-element';

import {userAssert} from '#utils/log';

Expand All @@ -15,7 +15,7 @@ import {
/** @const {string} */
const TAG = 'amp-timeago';

class AmpTimeago extends PreactBaseElement {
class AmpTimeago extends AmpPreactBaseElement {
/** @override */
isLayoutSupported(layout) {
userAssert(
Expand Down
Loading

0 comments on commit f28fdbc

Please sign in to comment.