diff --git a/packages/react/src/components/Card/CardEmpty.js b/packages/react/src/components/Card/CardEmpty.js index c2c246bcc..8c9a7affe 100644 --- a/packages/react/src/components/Card/CardEmpty.js +++ b/packages/react/src/components/Card/CardEmpty.js @@ -7,13 +7,17 @@ import { emptyStateAnimation, emptyStateImageAnimation } from './CardAnimation' import CardImage from './CardMedia/Image' import { Content } from './CardContent' import { GlobalContext } from '../../context/GlobalState' -import { isLarge, isSmall } from '../../utils' +import { classNames, isLarge, isSmall } from '../../utils' -const MediaEmpty = styled(CardImage)` +const Placeholder = styled.span.attrs({ + className: classNames.placeholderContent +})`` + +const MediaEmpty = styled(CardImage).attrs({ className: classNames.placeholderMedia })` ${emptyStateImageAnimation}; ` -const HeaderEmpty = styled('span')` +const HeaderEmpty = styled(Placeholder)` opacity: 0.8; height: 16px; width: ${({ cardSize }) => (!isSmall(cardSize) ? '60%' : '75%')}; @@ -30,7 +34,7 @@ const HeaderEmpty = styled('span')` `}; ` -const DescriptionEmpty = styled('span')` +const DescriptionEmpty = styled(Placeholder)` opacity: 0.8; height: 14px; width: 95%; @@ -40,12 +44,13 @@ const DescriptionEmpty = styled('span')` animation-delay: 0.125s; ` -const FooterEmpty = styled('span')` +const FooterEmpty = styled(Placeholder)` opacity: 0.8; height: 12px; width: 30%; display: block; - ${emptyStateAnimation} animation-delay: .25s; + ${emptyStateAnimation}; + animation-delay: 0.25s; ${({ cardSize }) => !isLarge(cardSize) && diff --git a/packages/react/src/index.js b/packages/react/src/index.js index 9834d42ba..b4f8b8fe4 100644 --- a/packages/react/src/index.js +++ b/packages/react/src/index.js @@ -32,6 +32,7 @@ import { useIntersectionObserver } from './utils/hooks' const Card = props => { const { className, + components, fetchData, lazy, loading, @@ -53,6 +54,10 @@ const Card = props => { [mediaProps, props] ) + const { PlaceholderComponent = CardEmpty } = components + + const isLoading = isLoadingUndefined ? loadingState : loading + const isLazyEnabled = useMemo( () => isLazySupported && (lazy === true || isObject(lazy)), [lazy] @@ -68,6 +73,12 @@ const Card = props => { [isLazyEnabled, hasIntersected] ) + const cardWrapClassName = useMemo(() => { + const base = `${classNames.main} ${isLoading ? classNames.placeholder : ''}`.trim() + + return `${base} ${className}`.trim() + }, [className, isLoading]) + const mergeData = useCallback( fetchedData => { const payload = isFunction(setData) @@ -158,8 +169,6 @@ microlink.io/${error.code.toLowerCase()} useEffect(toFetchData, [url, setData, hasIntersected]) - const isLoading = isLoadingUndefined ? loadingState : loading - if (isError) { return ( @@ -191,14 +200,14 @@ microlink.io/${error.code.toLowerCase()} return ( {isLoading ? ( - + ) : ( <> @@ -217,6 +226,7 @@ Microlink.defaultProps = { className: '', apiKey: undefined, autoPlay: true, + components: { PlaceholderComponent: CardEmpty }, controls: true, direction: 'ltr', lazy: true, @@ -231,6 +241,7 @@ Microlink.defaultProps = { Microlink.propTypes = { apiKey: PropTypes.string, autoPlay: PropTypes.bool, + components: PropTypes.shape({ PlaceholderComponent: PropTypes.elementType }), contrast: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), controls: PropTypes.bool, direction: PropTypes.string, diff --git a/packages/react/src/utils/index.js b/packages/react/src/utils/index.js index 847ec77dd..6e0be6d93 100644 --- a/packages/react/src/utils/index.js +++ b/packages/react/src/utils/index.js @@ -121,6 +121,7 @@ const BASE_CLASSNAME = 'microlink_card' const CONTENT_BASE_CLASSNAME = `${BASE_CLASSNAME}__content` const MEDIA_BASE_CLASSNAME = `${BASE_CLASSNAME}__media` const CONTROLS_BASE_CLASSNAME = `${MEDIA_BASE_CLASSNAME}__controls` +const PLACEHOLDER_BASE_CLASSNAME = `${BASE_CLASSNAME}__placeholder` export const classNames = { main: BASE_CLASSNAME, @@ -144,5 +145,8 @@ export const classNames = { progressBar: `${CONTROLS_BASE_CLASSNAME}_progress_bar`, progressTime: `${CONTROLS_BASE_CLASSNAME}_progress_time`, spinner: `${CONTROLS_BASE_CLASSNAME}_spinner`, - iframe: `${BASE_CLASSNAME}__iframe` + iframe: `${BASE_CLASSNAME}__iframe`, + placeholder: PLACEHOLDER_BASE_CLASSNAME, + placeholderMedia: `${PLACEHOLDER_BASE_CLASSNAME}_media`, + placeholderContent: `${PLACEHOLDER_BASE_CLASSNAME}_content` } diff --git a/packages/react/stories/__snapshots__/index.test.js.snap b/packages/react/stories/__snapshots__/index.test.js.snap index 39f56414f..c87174d12 100644 --- a/packages/react/stories/__snapshots__/index.test.js.snap +++ b/packages/react/stories/__snapshots__/index.test.js.snap @@ -1,5 +1,172 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Storyshots components PlaceholderComponent 1`] = ` +.c2 { + max-width: var(--microlink-max-width,500px); + background-color: var(--microlink-background-color,#fff); + border-width: var(--microlink-border-width,1px); + border-style: var(--microlink-border-style,solid); + border-color: var(--microlink-border-color,#e1e8ed); + color: var(--microlink-color,#181919); + overflow: hidden; + font-family: InterUI,-apple-system,BlinkMacSystemFont,'Helvetica Neue','Segoe UI',Oxygen,Ubuntu,Cantarell,'Open Sans',sans-serif; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-text-decoration: none; + text-decoration: none; + opacity: 1; + position: relative; + -webkit-transition-duration: 150ms; + transition-duration: 150ms; + -webkit-transition-timing-function: cubic-bezier(.25,.8,.25,1); + transition-timing-function: cubic-bezier(.25,.8,.25,1); +} + +.c2:active, +.c2:hover { + outline: 0; +} + +.c4 { + max-width: var(--microlink-max-width,500px); + background-color: var(--microlink-background-color,#fff); + border-width: var(--microlink-border-width,1px); + border-style: var(--microlink-border-style,solid); + border-color: var(--microlink-border-color,#e1e8ed); + color: var(--microlink-color,#181919); + overflow: hidden; + font-family: InterUI,-apple-system,BlinkMacSystemFont,'Helvetica Neue','Segoe UI',Oxygen,Ubuntu,Cantarell,'Open Sans',sans-serif; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-text-decoration: none; + text-decoration: none; + opacity: 1; + position: relative; + -webkit-transition-duration: 150ms; + transition-duration: 150ms; + -webkit-transition-timing-function: cubic-bezier(.25,.8,.25,1); + transition-timing-function: cubic-bezier(.25,.8,.25,1); + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + height: 382px; +} + +.c4:active, +.c4:hover { + outline: 0; +} + +.c0 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + padding-bottom: 32px; + margin-bottom: 32px; +} + +.c0:not(:last-child):not(:only-child) { + border-bottom: 1px solid #e0e0e0; +} + +.c1 { + color: #0366d6; + margin-bottom: 32px; +} + +.c3:not(:last-child):not(:only-child) { + margin-bottom: 32px; +} + +@media (max-width:48em) { + .c4 { + height: calc(382px * 7/9); + } +} + +
+ + https://microlink.io + + + + loading... + + + + + loading... + + + + + loading... + + +
+`; + exports[`Storyshots media audio 1`] = ` .c6 { display: -webkit-box; @@ -235,8 +402,8 @@ exports[`Storyshots media audio 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -349,26 +516,26 @@ exports[`Storyshots media audio 1`] = ` https://open.spotify.com/track/1W2919zs8SBCLTrOB1ftQT?si=4PcqgjH5RlWCvB5q4ukdnw
@@ -530,8 +697,8 @@ exports[`Storyshots media iframe 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -606,26 +773,26 @@ exports[`Storyshots media iframe 1`] = ` https://twitter.com/futurism/status/882987478541533189
@@ -875,8 +1042,8 @@ exports[`Storyshots media image 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -989,26 +1156,26 @@ exports[`Storyshots media image 1`] = ` https://www.apple.com/music/
@@ -1311,8 +1478,8 @@ exports[`Storyshots media logo 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -1425,26 +1592,26 @@ exports[`Storyshots media logo 1`] = ` https://www.apple.com/music/
@@ -1747,8 +1914,8 @@ exports[`Storyshots media screenshot 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -1861,26 +2028,26 @@ exports[`Storyshots media screenshot 1`] = ` https://www.apple.com/music/
@@ -2183,8 +2350,8 @@ exports[`Storyshots media video 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -2297,26 +2464,26 @@ exports[`Storyshots media video 1`] = ` https://www.facebook.com/natgeo/videos/10156364216738951/
@@ -2619,8 +2786,8 @@ exports[`Storyshots props autoPlay (disabled) 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -2733,26 +2900,26 @@ exports[`Storyshots props autoPlay (disabled) 1`] = ` https://www.facebook.com/natgeo/videos/10156364216738951/
@@ -3055,8 +3222,8 @@ exports[`Storyshots props contrast 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -3185,26 +3352,26 @@ exports[`Storyshots props contrast 1`] = ` https://www.apple.com/music/
@@ -3507,8 +3674,8 @@ exports[`Storyshots props controls (disabled) 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -3621,26 +3788,26 @@ exports[`Storyshots props controls (disabled) 1`] = ` https://www.facebook.com/natgeo/videos/10156364216738951/
@@ -3943,8 +4110,8 @@ exports[`Storyshots props default 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -4057,26 +4224,26 @@ exports[`Storyshots props default 1`] = ` https://www.apple.com/music/
@@ -4379,8 +4546,8 @@ exports[`Storyshots props direction + contrast 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -4515,26 +4682,26 @@ exports[`Storyshots props direction + contrast 1`] = ` https://www.apple.com/music/
@@ -4837,8 +5004,8 @@ exports[`Storyshots props direction 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -4957,26 +5124,26 @@ exports[`Storyshots props direction 1`] = ` https://www.apple.com/music/
@@ -5280,8 +5447,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -5417,26 +5584,26 @@ Array [
@@ -5736,8 +5903,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -5875,26 +6042,26 @@ Array [
@@ -6198,8 +6365,8 @@ exports[`Storyshots props loading 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -6312,26 +6479,26 @@ exports[`Storyshots props loading 1`] = ` https://microlink.io
@@ -6634,8 +6801,8 @@ exports[`Storyshots props mediaRef 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -6748,26 +6915,26 @@ exports[`Storyshots props mediaRef 1`] = ` https://www.facebook.com/natgeo/videos/10156364216738951/
@@ -7070,8 +7237,8 @@ exports[`Storyshots setData function 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -7184,26 +7351,26 @@ exports[`Storyshots setData function 1`] = ` https://microlink.io
@@ -7506,8 +7673,8 @@ exports[`Storyshots setData object 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -7620,26 +7787,26 @@ exports[`Storyshots setData object 1`] = ` https://microlink.io
@@ -7802,8 +7969,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -7878,26 +8045,26 @@ Array [ https://youtube.com
@@ -8003,8 +8170,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -8079,26 +8246,26 @@ Array [ https://example.com
@@ -8350,8 +8517,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -8464,7 +8631,7 @@ Array [ https://www.apple.com/music/
@@ -8801,8 +8968,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -8915,7 +9082,7 @@ Array [ https://microlink.io
@@ -9252,8 +9419,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -9366,7 +9533,7 @@ Array [ https://microlink.io
@@ -9708,8 +9875,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -9822,7 +9989,7 @@ Array [ https://www.apple.com/music/
@@ -10159,8 +10326,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -10273,7 +10440,7 @@ Array [ https://microlink.io
@@ -10610,8 +10777,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -10724,7 +10891,7 @@ Array [ https://microlink.io
@@ -11061,8 +11228,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -11175,7 +11342,7 @@ Array [ https://microlink.io
@@ -11512,8 +11679,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -11626,7 +11793,7 @@ Array [ https://microlink.io
@@ -11963,8 +12130,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -12077,7 +12244,7 @@ Array [ https://microlink.io
@@ -12418,8 +12585,8 @@ exports[`Storyshots style misc 1`] = ` display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -12532,7 +12699,7 @@ exports[`Storyshots style misc 1`] = ` https://www.apple.com/music/
@@ -12876,8 +13043,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -12990,7 +13157,7 @@ Array [ https://www.apple.com/music/
@@ -13327,8 +13494,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -13441,7 +13608,7 @@ Array [ https://microlink.io
@@ -13778,8 +13945,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -13892,7 +14059,7 @@ Array [ https://microlink.io
@@ -14229,8 +14396,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -14343,7 +14510,7 @@ Array [ https://microlink.io
@@ -14680,8 +14847,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -14794,7 +14961,7 @@ Array [ https://microlink.io
@@ -15131,8 +15298,8 @@ Array [ display: block; -webkit-animation: ibPKPZ .75s linear infinite; animation: ibPKPZ .75s linear infinite; - -webkit-animation-delay: .25s; - animation-delay: .25s; + -webkit-animation-delay: 0.25s; + animation-delay: 0.25s; height: 10px; } @@ -15245,7 +15412,7 @@ Array [ https://microlink.io
diff --git a/packages/react/stories/index.js b/packages/react/stories/index.js index 998c99528..aff0466ac 100644 --- a/packages/react/stories/index.js +++ b/packages/react/stories/index.js @@ -1,5 +1,6 @@ import 'unfetch/polyfill' +import React from 'react' import { storiesOf } from '@storybook/react' import { urls, urlsVideo, urlsAudio, urlsIframe } from './data' @@ -26,7 +27,7 @@ storiesOf('props', module) createStoryEntry({ url, media: 'video', controls: false }) ) ) - .add('loading', () => createStoryEntry({ loading: true })) + .add('loading', () => createStoryEntry({ loading: true, fetchData: false })) .add('lazy', () => [ createStoryEntry({ lazy: false }, true), createStoryEntry({ lazy: { threshold: 1 } }, true) @@ -207,3 +208,13 @@ storiesOf('style', module) }) ) ) + +const PlaceholderComponent = () => loading... + +storiesOf('components', module) + .add('PlaceholderComponent', () => + createStoryEntry({ + loading: true, + fetchData: false, + components: { PlaceholderComponent } + }))