Skip to content

Commit a0dd670

Browse files
committed
feat: be possible to customize placeholder
closes #249
1 parent f880dc8 commit a0dd670

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

packages/react/src/components/Card/CardEmpty.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ import { Content } from './CardContent'
99
import { GlobalContext } from '../../context/GlobalState'
1010
import { isLarge, isSmall } from '../../utils'
1111

12+
const Placeholder = styled('span')``
13+
14+
Placeholder.defaultProps = {
15+
className: 'microlink_card_placeholder'
16+
}
17+
1218
const MediaEmpty = styled(CardImage)`
1319
${emptyStateImageAnimation};
1420
`
1521

16-
const HeaderEmpty = styled('span')`
22+
const HeaderEmpty = styled(Placeholder)`
1723
opacity: 0.8;
1824
height: 16px;
1925
width: ${({ cardSize }) => (!isSmall(cardSize) ? '60%' : '75%')};
@@ -30,7 +36,7 @@ const HeaderEmpty = styled('span')`
3036
`};
3137
`
3238

33-
const DescriptionEmpty = styled('span')`
39+
const DescriptionEmpty = styled(Placeholder)`
3440
opacity: 0.8;
3541
height: 14px;
3642
width: 95%;
@@ -40,12 +46,13 @@ const DescriptionEmpty = styled('span')`
4046
animation-delay: 0.125s;
4147
`
4248

43-
const FooterEmpty = styled('span')`
49+
const FooterEmpty = styled(Placeholder)`
4450
opacity: 0.8;
4551
height: 12px;
4652
width: 30%;
4753
display: block;
48-
${emptyStateAnimation} animation-delay: .25s;
54+
${emptyStateAnimation};
55+
animation-delay: 0.25s;
4956
5057
${({ cardSize }) =>
5158
!isLarge(cardSize) &&

packages/react/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const Card = props => {
3939
setData,
4040
url,
4141
apiKey, // destructuring to avoid pass it
42+
placeholderComponent: CardEmpty,
4243
...restProps
4344
} = props
4445

@@ -224,6 +225,7 @@ const Microlink = props => (
224225
Microlink.defaultProps = {
225226
className: '',
226227
apiKey: undefined,
228+
placeholderComponent: CardEmpty,
227229
autoPlay: true,
228230
controls: true,
229231
direction: 'ltr',

packages/react/stories/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ storiesOf('props', module)
2626
createStoryEntry({ url, media: 'video', controls: false })
2727
)
2828
)
29-
.add('loading', () => createStoryEntry({ loading: true }))
29+
.add('loading', () => createStoryEntry({ loading: true, fetchData: false }))
3030
.add('lazy', () => [
3131
createStoryEntry({ lazy: false }, true),
3232
createStoryEntry({ lazy: { threshold: 1 } }, true)

0 commit comments

Comments
 (0)