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

♻️ Migrate stories 30..34 to controls #37697

Merged
merged 26 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b9ea59f
convert amp-date-display storybook knobs to controls
dmanek Feb 15, 2022
6fea81a
migrate from knobs to controls for date-display
dmanek Feb 15, 2022
6f3c329
migrate to controls for amp-iframe
dmanek Feb 15, 2022
52affb5
migrate storybook to controls for image-slider
dmanek Feb 15, 2022
9057b8c
minor fixes
dmanek Feb 15, 2022
2062aca
revert build-system/test-configs/forbidden-terms.js
dmanek Feb 15, 2022
68014b5
Merge branch 'main' into migrate-to-controls
dmanek Feb 17, 2022
f2356d9
Merge branch 'main' into migrate-to-controls
dmanek Feb 23, 2022
c46db9f
minor fixes
dmanek Feb 23, 2022
fbe9c9d
remove storyName prop
dmanek Feb 23, 2022
dc601bf
minor fixes
dmanek Feb 23, 2022
255a4f0
add date option in amp-date-display
dmanek Feb 23, 2022
caf07f8
update forbidden terms
dmanek Feb 23, 2022
2276f9d
lint
dmanek Feb 23, 2022
90d0147
Merge branch 'main' into migrate-to-controls
dmanek Feb 24, 2022
1a76101
minor fixes
dmanek Feb 24, 2022
8a12a8a
Merge branch 'main' into migrate-to-controls
dmanek Feb 24, 2022
d2ec8ec
Merge branch 'main' into migrate-to-controls
dmanek Feb 25, 2022
1e138f7
fix datetime
dmanek Feb 25, 2022
df9e2fc
fix datetime for amp-date-display
dmanek Feb 25, 2022
15de394
fix lint error
dmanek Feb 25, 2022
e33d35c
address code review comment
dmanek Feb 25, 2022
fa7fe3d
Merge branch 'main' into migrate-to-controls
dmanek Feb 28, 2022
9cc2be1
move template argType to specific story
dmanek Feb 28, 2022
58f55af
Merge branch 'main' into migrate-to-controls
dmanek Mar 1, 2022
99d675e
fix lint error
dmanek Mar 1, 2022
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
5 changes: 0 additions & 5 deletions build-system/test-configs/forbidden-terms.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,11 +722,6 @@ const forbiddenTermsGlobal = {
'The @storybook/addon-knobs package has been deprecated. Use Controls instead (`args` and `argTypes`). https://storybook.js.org/docs/react/essentials/controls',
allowlist: [
// TODO(#35923): Update existing files to use Controls instead.
'extensions/amp-date-display/1.0/storybook/Basic.amp.js',
'extensions/amp-date-display/1.0/storybook/Basic.js',
'extensions/amp-iframe/0.1/storybook/Basic.amp.js',
'extensions/amp-iframe/1.0/storybook/Basic.amp.js',
'extensions/amp-image-slider/0.1/storybook/Basic.amp.js',
'extensions/amp-lightbox/1.0/storybook/Basic.js',
'extensions/amp-selector/1.0/storybook/Basic.amp.js',
'extensions/amp-selector/1.0/storybook/Basic.js',
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-date-display/1.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The Bento Date Display Preact/React component allows consumers to render their o

#### `datetime`

Required prop. Denotes the date and time as a Date, String, or Nuumber. If String, must be a standard ISO 8601 date string (e.g. 2017-08-02T15:05:05.000Z) or the string `now`. If set to `now`, it will use the time the page loaded to render its template. If Number, must be a POSIX epoch value in milliseconds.
Required prop. Denotes the date and time as a Date, String, or Number. If String, must be a standard ISO 8601 date string (e.g. 2017-08-02T15:05:05.000Z) or the string `now`. If set to `now`, it will use the time the page loaded to render its template. If Number, must be a POSIX epoch value in milliseconds.

#### `displayIn`

Expand Down
85 changes: 44 additions & 41 deletions extensions/amp-date-display/1.0/storybook/Basic.amp.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,55 @@
import {withAmp} from '@ampproject/storybook-addon';
import {date, select, withKnobs} from '@storybook/addon-knobs';

import * as Preact from '#preact';

const DISPLAY_IN_OPTIONS = ['utc', 'local'];
const LOCALES = ['en-US', 'en-GB', 'fr', 'ru', 'ar', 'he', 'ja'];

export default {
title: 'amp-date-display-1_0',
decorators: [withKnobs, withAmp],

decorators: [withAmp],
parameters: {
extensions: [
{name: 'amp-date-display', version: '1.0'},
{name: 'amp-mustache', version: '0.2'},
],

experiments: ['bento'],
},
argTypes: {
dateTime: {
name: 'Date/time',
control: {type: 'date'},
defaultValue: 1234567890000,
dmanek marked this conversation as resolved.
Show resolved Hide resolved
},
displayIn: {
name: 'Display in',
defaultValue: 'utc',
options: ['utc', 'local'],
control: {type: 'select'},
},
locale: {
name: 'Locale',
defaultValue: 'en-US',
options: ['en-US', 'en-GB', 'fr', 'ru', 'ar', 'he', 'ja'],
control: {type: 'select'},
},
template: {
name: 'Template',
defaultValue: 'template1',
options: ['template1', 'template2'],
control: {type: 'select'},
},
},
};

export const Default = () => {
const datetime = new Date(date('Date/Time', new Date())).toISOString();
const displayIn = select(
'Display in',
DISPLAY_IN_OPTIONS,
DISPLAY_IN_OPTIONS[0]
);
const locale = select('Locale', LOCALES, LOCALES[0]);
export const Default = ({dateTime, displayIn, locale, ...args}) => {
dateTime = new Date(dateTime);
return (
<amp-date-display
datetime={datetime}
datetime={dateTime}
display-in={displayIn}
locale={locale}
layout="responsive"
width="100"
height="100"
{...args}
>
<template type="amp-mustache">
<div>
Expand All @@ -47,39 +61,29 @@ export const Default = () => {
);
};

Default.storyName = 'default';

export const DefaultRenderer = () => {
const datetime = new Date(date('Date/Time', new Date())).toISOString();
const displayIn = select(
'Display in',
DISPLAY_IN_OPTIONS,
DISPLAY_IN_OPTIONS[0]
);
const locale = select('Locale', LOCALES, LOCALES[0]);
export const DefaultRenderer = ({dateTime, displayIn, locale, ...args}) => {
dateTime = new Date(dateTime);
return (
<amp-date-display
datetime={datetime}
datetime={dateTime}
display-in={displayIn}
locale={locale}
layout="responsive"
width="100"
height="100"
{...args}
/>
);
};

DefaultRenderer.storyName = 'default renderer';

export const ExternalTemplate = () => {
const datetime = new Date(date('Date/Time', new Date())).toISOString();
const displayIn = select(
'Display in',
DISPLAY_IN_OPTIONS,
DISPLAY_IN_OPTIONS[0]
);
const locale = select('Locale', LOCALES, LOCALES[0]);
const template = select('Template', ['template1', 'template2'], 'template1');
export const ExternalTemplate = ({
dateTime,
displayIn,
locale,
template,
...args
}) => {
dateTime = new Date(dateTime);
return (
<div>
<template type="amp-mustache" id="template1">
Expand All @@ -89,16 +93,15 @@ export const ExternalTemplate = () => {
<div>{`Template2: {{day}} {{month}} {{year}}`}</div>
</template>
<amp-date-display
datetime={datetime}
datetime={dateTime}
display-in={displayIn}
locale={locale}
template={template}
layout="responsive"
width="100"
height="100"
{...args}
></amp-date-display>
</div>
);
};

ExternalTemplate.storyName = 'external template';
49 changes: 25 additions & 24 deletions extensions/amp-date-display/1.0/storybook/Basic.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
import {date, select, withKnobs} from '@storybook/addon-knobs';

import * as Preact from '#preact';

import {BentoDateDisplay} from '../component';

export default {
title: 'DateDisplay',
component: BentoDateDisplay,
decorators: [withKnobs],
argTypes: {
datetime: {
name: 'Date/time',
control: {type: 'date'},
defaultValue: 1234567890000,
dmanek marked this conversation as resolved.
Show resolved Hide resolved
},
displayIn: {
name: 'Display in',
defaultValue: 'utc',
options: ['utc', 'local'],
control: {type: 'select'},
},
locale: {
name: 'Locale',
defaultValue: 'en-US',
options: ['en-US', 'en-GB', 'fr', 'ru', 'ar', 'he', 'ja'],
control: {type: 'select'},
},
},
};

const DISPLAY_IN_OPTIONS = ['utc', 'local'];
const LOCALES = ['en-US', 'en-GB', 'fr', 'ru', 'ar', 'he', 'ja'];

export const _default = () => {
const dateTime = date('Date/time', new Date());
const displayIn = select(
'Display in',
DISPLAY_IN_OPTIONS,
DISPLAY_IN_OPTIONS[0]
);
const locale = select('Locale', LOCALES, LOCALES[0]);
export const Default = ({datetime, displayIn, locale, ...args}) => {
return (
<BentoDateDisplay
datetime={dateTime}
datetime={datetime}
displayIn={displayIn}
locale={locale}
render={(date) => (
<div>{`ISO: ${date.iso}; locale: ${date.localeString}`}</div>
)}
{...args}
/>
);
};

export const defaultRenderer = () => {
const displayIn = select(
'Display in',
DISPLAY_IN_OPTIONS,
DISPLAY_IN_OPTIONS[0]
);
const dateTime = date('Date/time', new Date());
const locale = select('Locale', LOCALES, LOCALES[0]);
export const DefaultRenderer = ({datetime, displayIn, locale, ...args}) => {
return (
<BentoDateDisplay
datetime={dateTime}
datetime={datetime}
displayIn={displayIn}
locale={locale}
{...args}
/>
);
};
3 changes: 1 addition & 2 deletions extensions/amp-iframe/0.1/storybook/Basic.amp.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {withAmp} from '@ampproject/storybook-addon';
import {withKnobs} from '@storybook/addon-knobs';

import * as Preact from '#preact';

export default {
title: 'amp-iframe',
decorators: [withKnobs, withAmp],
decorators: [withAmp],

parameters: {
extensions: [{name: 'amp-iframe', version: '0.1'}],
Expand Down
34 changes: 11 additions & 23 deletions extensions/amp-iframe/1.0/storybook/Basic.amp.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
import {withAmp} from '@ampproject/storybook-addon';
import {text, withKnobs} from '@storybook/addon-knobs';

import * as Preact from '#preact';

export default {
title: 'amp-iframe-1_0',
decorators: [withKnobs, withAmp],

decorators: [withAmp],
parameters: {
extensions: [{name: 'amp-iframe', version: '1.0'}],
experiments: ['bento'],
},
argTypes: {
src: {
name: 'iframe src',
defaultValue: 'https://www.wikipedia.org/',
control: {type: 'text'},
},
},
};

export const WithSrc = () => {
return (
<amp-iframe
width="800"
height="600"
src="https://www.wikipedia.org/"
></amp-iframe>
);
export const WithSrc = ({src}) => {
return <amp-iframe width="800" height="600" src={src}></amp-iframe>;
};

WithSrc.storyName = 'amp-iframe with src attribute';

export const WithPlaceholder = () => {
const src = text('src', `https://www.wikipedia.org/`);
export const WithPlaceholder = ({src}) => {
return (
<amp-iframe width="800" height="600" src={src}>
<h1 placeholder>Placeholder</h1>
Expand All @@ -35,8 +31,6 @@ export const WithPlaceholder = () => {
);
};

WithPlaceholder.storyName = 'amp-iframe with placeholder';

export const WithResizableIframe = () => {
return (
<div>
Expand All @@ -55,8 +49,6 @@ export const WithResizableIframe = () => {
);
};

WithResizableIframe.storyName = 'resizable amp-iframe';

export const WithContentBelow = () => {
return (
<div>
Expand All @@ -79,8 +71,6 @@ export const WithContentBelow = () => {
);
};

WithContentBelow.storyName = 'resizeable amp-iframe with content below';

export const WithOverflowButton = () => {
return (
<div>
Expand All @@ -99,5 +89,3 @@ export const WithOverflowButton = () => {
</div>
);
};

WithOverflowButton.storyName = 'resizeable amp-iframe with overflow';
19 changes: 11 additions & 8 deletions extensions/amp-iframe/1.0/storybook/Basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ import {BentoIframe} from '../component';
export default {
title: 'Iframe',
component: BentoIframe,
argTypes: {
src: {
name: 'iframe src',
defaultValue: 'https://www.wikipedia.org/',
control: {type: 'text'},
},
},
};

export const _default = () => {
export const _default = ({src}) => {
return (
<BentoIframe
style={{width: 800, height: 600}}
iframeStyle={{border: '1px solid black'}}
src="https://www.wikipedia.org/"
src={src}
title="Wikipedia"
></BentoIframe>
);
Expand Down Expand Up @@ -42,11 +49,10 @@ export const WithIntersectingIframe = () => {
);
};

WithIntersectingIframe.storyName = 'Resizable iframe in viewport';

export const WithResizableIframe = () => {
return (
<div>
<h1>Scroll down</h1>
<div
style={{
width: '100%',
Expand All @@ -68,11 +74,10 @@ export const WithResizableIframe = () => {
);
};

WithResizableIframe.storyName = 'Resizable iframe outside viewport';

export const WithSendIntersectionsPostMessage = () => {
return (
<div>
<h1>Scroll down</h1>
<div
style={{
width: '100%',
Expand All @@ -91,5 +96,3 @@ export const WithSendIntersectionsPostMessage = () => {
</div>
);
};

WithSendIntersectionsPostMessage.storyName = 'Send intersections';
Loading