Skip to content

Commit 5e190fe

Browse files
layershifterlevithomason
authored andcommitted
style(Embed): update typings and propTypes usage (#1217)
1 parent 1911865 commit 5e190fe

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

src/modules/Embed/Embed.js

+22-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from 'lodash'
21
import cx from 'classnames'
2+
import _ from 'lodash'
33
import React, { PropTypes } from 'react'
44

55
import {
@@ -12,45 +12,26 @@ import {
1212
} from '../../lib'
1313
import Icon from '../../elements/Icon'
1414

15-
const _meta = {
16-
name: 'Embed',
17-
type: META.TYPES.MODULE,
18-
props: {
19-
aspectRatio: ['4:3', '16:9', '21:9'],
20-
source: ['youtube', 'vimeo'],
21-
},
22-
}
23-
2415
/**
2516
* An embed displays content from other websites like YouTube videos or Google Maps.
2617
*/
2718
export default class Embed extends Component {
28-
static autoControlledProps = [
29-
'active',
30-
]
31-
32-
static defaultProps = {
33-
icon: 'video play',
34-
}
35-
36-
static _meta = _meta
37-
3819
static propTypes = {
3920
/** An element type to render as (string or function). */
4021
as: customPropTypes.as,
4122

4223
/** An embed can be active. */
4324
active: PropTypes.bool,
4425

45-
/** Setting to true or false will force autoplay. */
26+
/** An embed can specify an alternative aspect ratio. */
27+
aspectRatio: PropTypes.oneOf(['4:3', '16:9', '21:9']),
28+
29+
/** Setting to true or false will force autoplay. */
4630
autoplay: customPropTypes.every([
4731
customPropTypes.demand(['source']),
4832
PropTypes.bool,
4933
]),
5034

51-
/** An embed can specify an alternative aspect ratio. */
52-
aspectRatio: PropTypes.oneOf(_meta.props.aspectRatio),
53-
5435
/** Whether to show networks branded UI like title cards, or after video calls to action. */
5536
brandedUI: customPropTypes.every([
5637
customPropTypes.demand(['source']),
@@ -78,15 +59,15 @@ export default class Embed extends Component {
7859
PropTypes.bool,
7960
]),
8061

62+
/** Specifies an icon to use with placeholder content. */
63+
icon: customPropTypes.itemShorthand,
64+
8165
/** Specifies an id for source. */
8266
id: customPropTypes.every([
8367
customPropTypes.demand(['source']),
8468
PropTypes.string,
8569
]),
8670

87-
/** Specifies an icon to use with placeholder content. */
88-
icon: customPropTypes.itemShorthand,
89-
9071
/**
9172
* Сalled on click.
9273
*
@@ -101,7 +82,7 @@ export default class Embed extends Component {
10182
/** Specifies a source to use. */
10283
source: customPropTypes.every([
10384
customPropTypes.disallow(['sourceUrl']),
104-
PropTypes.oneOf(_meta.props.source),
85+
PropTypes.oneOf(['youtube', 'vimeo']),
10586
]),
10687

10788
/** Specifies a url to use for embed. */
@@ -111,6 +92,19 @@ export default class Embed extends Component {
11192
]),
11293
}
11394

95+
static autoControlledProps = [
96+
'active',
97+
]
98+
99+
static defaultProps = {
100+
icon: 'video play',
101+
}
102+
103+
static _meta = {
104+
name: 'Embed',
105+
type: META.TYPES.MODULE,
106+
}
107+
114108
state = {}
115109

116110
getSrc() {

src/modules/Embed/index.d.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import * as React from 'react';
22

33
interface EmbedProps {
4-
/** An embed can be active. */
5-
active?: boolean;
4+
[key: string]: any;
65

76
/** An element type to render as (string or function). */
87
as?: any;
98

9+
/** An embed can be active. */
10+
active?: boolean;
11+
1012
/** An embed can specify an alternative aspect ratio. */
1113
aspectRatio?: '4:3' | '16:9' | '21:9';
1214

@@ -16,6 +18,9 @@ interface EmbedProps {
1618
/** Whether to show networks branded UI like title cards, or after video calls to action. */
1719
brandedUI?: boolean;
1820

21+
/** Primary content. */
22+
children?: React.ReactNode;
23+
1924
/** Additional classes. */
2025
className?: string;
2126

@@ -40,7 +45,7 @@ interface EmbedProps {
4045
* @param {SyntheticEvent} event - React's original SyntheticEvent.
4146
* @param {object} data - All props and proposed value.
4247
*/
43-
onClick?: (e: React.FormEvent<HTMLVideoElement>, data: this) => void;
48+
onClick?: (event: React.MouseEvent<HTMLDivElement>, data: EmbedProps) => void;
4449

4550
/** A placeholder image for embed. */
4651
placeholder?: string;

0 commit comments

Comments
 (0)