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

♻️ docs/bento-stream-gallery #35879

Merged
merged 1 commit into from
Sep 7, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions extensions/amp-stream-gallery/1.0/base-element.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {CSS as CAROUSEL_CSS} from '../../amp-base-carousel/1.0/component.jss';
import {CSS as GALLERY_CSS} from './component.jss';
import {PreactBaseElement} from '#preact/base-element';
import {StreamGallery} from './component';
import {BentoStreamGallery} from './component';
import {dict} from '#core/types/object';

export class BaseElement extends PreactBaseElement {
Expand All @@ -17,7 +17,7 @@ export class BaseElement extends PreactBaseElement {
}

/** @override */
BaseElement['Component'] = StreamGallery;
BaseElement['Component'] = BentoStreamGallery;

/** @override */
BaseElement['layoutSizeDefined'] = true;
Expand Down
12 changes: 6 additions & 6 deletions extensions/amp-stream-gallery/1.0/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const DEFAULT_VISIBLE_COUNT = 1;
const OUTSET_ARROWS_WIDTH = 100;

/**
* @param {!StreamGalleryDef.Props} props
* @param {!BentoStreamGalleryDef.Props} props
* @param {{current: (!BentoBaseCarouselDef.CarouselApi|null)}} ref
* @return {PreactDef.Renderable}
*/
function StreamGalleryWithRef(props, ref) {
function BentoStreamGalleryWithRef(props, ref) {
const {
arrowPrevAs = DefaultArrow,
arrowNextAs = DefaultArrow,
Expand Down Expand Up @@ -119,12 +119,12 @@ function StreamGalleryWithRef(props, ref) {
);
}

const StreamGallery = forwardRef(StreamGalleryWithRef);
StreamGallery.displayName = 'StreamGallery'; // Make findable for tests.
export {StreamGallery};
const BentoStreamGallery = forwardRef(BentoStreamGalleryWithRef);
BentoStreamGallery.displayName = 'StreamGallery'; // Make findable for tests.
export {BentoStreamGallery};

/**
* @param {!StreamGalleryDef.ArrowProps} props
* @param {!BentoStreamGalleryDef.ArrowProps} props
* @return {PreactDef.Renderable}
*/
function DefaultArrow({
Expand Down
6 changes: 3 additions & 3 deletions extensions/amp-stream-gallery/1.0/component.type.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @externs */

/** @const */
var StreamGalleryDef = {};
var BentoStreamGalleryDef = {};

/**
* @typedef {{
Expand All @@ -22,7 +22,7 @@ var StreamGalleryDef = {};
* snap: (boolean|undefined)
* }}
*/
StreamGalleryDef.Props;
BentoStreamGalleryDef.Props;

/**
* @typedef {{
Expand All @@ -33,4 +33,4 @@ StreamGalleryDef.Props;
* outsetArrows: (boolean|undefined)
* }}
*/
StreamGalleryDef.ArrowProps;
BentoStreamGalleryDef.ArrowProps;
6 changes: 3 additions & 3 deletions extensions/amp-stream-gallery/1.0/storybook/Basic.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as Preact from '#preact';
import {StreamGallery} from '../component';
import {BentoStreamGallery} from '../component';
import {boolean, number, select, withKnobs} from '@storybook/addon-knobs';

const CONTROLS = ['auto', 'always', 'never'];

export default {
title: 'StreamGallery',
component: StreamGallery,
component: BentoStreamGallery,
decorators: [withKnobs],
};

Expand All @@ -20,7 +20,7 @@ function CarouselWithActions(props) {
const ref = Preact.useRef();
return (
<section>
<StreamGallery ref={ref} {...props} />
<BentoStreamGallery ref={ref} {...props} />
<div style={{marginTop: 8}}>
<button onClick={() => ref.current.goToSlide(3)}>goToSlide(3)</button>
<button onClick={() => ref.current.next()}>next</button>
Expand Down
18 changes: 9 additions & 9 deletions extensions/amp-stream-gallery/1.0/test/test-component.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as Preact from '#preact';
import {StreamGallery} from '../component';
import {BentoStreamGallery} from '../component';
import {mount} from 'enzyme';

describes.sandboxed('StreamGallery preact component', {}, () => {
it('should render BentoBaseCarousel', () => {
const wrapper = mount(
<StreamGallery>
<BentoStreamGallery>
<div>slide 1</div>
<div>slide 2</div>
<div>slide 3</div>
</StreamGallery>
</BentoStreamGallery>
);
const carousel = wrapper.find('BentoBaseCarousel');
expect(carousel).to.have.lengthOf(1);
Expand All @@ -35,11 +35,11 @@ describes.sandboxed('StreamGallery preact component', {}, () => {
</div>
);
const wrapper = mount(
<StreamGallery arrowPrevAs={arrowPrev} arrowNextAs={arrowNext}>
<BentoStreamGallery arrowPrevAs={arrowPrev} arrowNextAs={arrowNext}>
<div>slide 1</div>
<div>slide 2</div>
<div>slide 3</div>
</StreamGallery>
</BentoStreamGallery>
);
const arrows = wrapper.find('Arrow');
expect(arrows).to.have.lengthOf(2);
Expand All @@ -49,11 +49,11 @@ describes.sandboxed('StreamGallery preact component', {}, () => {

it('should not loop by default', () => {
const wrapper = mount(
<StreamGallery>
<BentoStreamGallery>
<div class="my-slide">slide 1</div>
<div class="my-slide">slide 2</div>
<div class="my-slide">slide 3</div>
</StreamGallery>
</BentoStreamGallery>
);
const slides = wrapper.find('[data-slide]');
expect(slides).to.have.lengthOf(3);
Expand All @@ -67,11 +67,11 @@ describes.sandboxed('StreamGallery preact component', {}, () => {

it('should render in preparation for looping with loop prop', () => {
const wrapper = mount(
<StreamGallery loop>
<BentoStreamGallery loop>
<div class="my-slide">slide 1</div>
<div class="my-slide">slide 2</div>
<div class="my-slide">slide 3</div>
</StreamGallery>
</BentoStreamGallery>
);
const slides = wrapper.find('[data-slide]');
expect(slides).to.have.lengthOf(3);
Expand Down