-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Simplify AMP/Bento Class Hierarchies #36950
Comments
One thing I might have missed we last discussed was how to share logic between
There are at least 10 extensions that have "non-trivial"
What was the solution to this? (other than obviously copy/pasting this logic into both |
Could we do the same trick? |
Yeah I like that An alternative could be
to allow the BentoFitText component to have non-amp-compliant code. But that should be relatively easy to change after the fact, so I'll go with your solution. |
I was thinking that to achieve something like: class BentoFitText extends setSuperClass(PreactBaseElement, HTMLElement) {}
class AmpPreactBaseElement extends setSuperclass(PreactBaseElement, AMP.BaseElement) {}
class AmpFitText extends AmpPreactBaseElement {} ....we wouldn't need a hierarchy to share behavior between AMP and Bento versions. Bear in mind that we'd either duplicate import {props} from './props';
BaseElement['props'] = props; import {props} from './props';
AmpFoo['props'] = props; Regarding the extensions that @kvchari mentioned: Accordion
Selector
BaseCarousel
StreamGallery
InlineGallery
Lightbox
Sidebar
Soundcloud
Timeago
And a bonus: Video
|
Currently implementing the changes discussed here. Draft PR is available to see the idea: #37156 (although will likely be closed in favor or multiple smaller PRs). One point related to these changes is that bento components were being implicitly tested by the tests for the amp component in the |
updates from today's adhoc meeting
|
The video embed components add an extra layer of complexity here: Using
The issue is that all the Amp* video components extend from AmpVideoBase (which adds extra amp-specific, video-specific functionality) so something like: // for amp layer
class AmpPreactBaseElement extends setSuperClass(PreactBaseElement, AMP.BaseElement) {}
class AmpVideoBaseElement extends setSuperClass(BentoVideo, AmpPreactBaseElement) {}
class AmpBrightcove extends setSuperClass(BentoBrightcove, AmpVideoBaseElement) {}
// for bento layer
class BentoVideo extends PreactBaseElement {}
class BentoBrightcove extends BentoVideo {} |
@kvchari: makes sense to me! Ridiculous number of layers on the AMP side of things, but I don't see a way to avoid it. So it goes. |
Closing as the hierarchy has been solved. Remaining clarity improvements are being tracked by #37538 |
Objectives
Current
Proposed State
changes
CeBaseElement
from Bento by extracting the CustomElement function and also moving all of the HTMLElement CE Mappings into PreactBaseElement.new hierarchies
cc @alanorozco @kvchari @jridgewell
The text was updated successfully, but these errors were encountered: