Skip to content

Commit b79d114

Browse files
author
Amir Tocker
committed
Separate class definition and export statements. Updated documentation comments.
1 parent 86996f5 commit b79d114

File tree

9 files changed

+43
-14
lines changed

9 files changed

+43
-14
lines changed

src/Util/closestAbove.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* @param {Array} list a sorted array of items
44
* @param {*} value
55
* @returns {*}
6+
* @protected
67
*/
78
export default function closestAbove(list, value) {
89
return list.reduce((last, next) => value <= last ? last : next, undefined);

src/Util/debounce.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @param {number} wait waiting time in milliseconds
55
* @param {boolean=false} immediate if true execute func at the beginning of the wait period
66
* @returns {function()} debounced function
7+
* @protected
78
*/
89
export default function debounce(func, wait, immediate) {
910
let timeout = null;

src/Util/firstDefined.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Returns the first argument that is not undefined
33
* @param {...*} values a list of arguments of any type
44
* @returns {*}
5+
* @protected
56
*/
67
export default function firstDefined(...values){
78
for(let i = 0; i < values.length; i++) {

src/Util/isElement.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @category Lang
99
* @param {*} value The value to check.
1010
* @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
11+
* @protected
1112
* @example
1213
*
1314
* _.isElement(document.body);

src/components/CloudinaryComponent/CloudinaryComponent.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import {mapKeys} from '../../Util'
55
const camelCase = Util.camelCase;
66
const snakeCase = Util.snakeCase;
77

8-
export default class CloudinaryComponent extends Component {
8+
/**
9+
* A base component for Cloudinary components.
10+
* @protected
11+
*/
12+
class CloudinaryComponent extends Component {
913
constructor(props, context) {
1014
super(props, context);
1115
}
@@ -41,6 +45,7 @@ export default class CloudinaryComponent extends Component {
4145
* and any children.
4246
* @param options
4347
* @returns {object} a hash of transformation and configuration parameters
48+
* @protected
4449
*/
4550
getTransformation(options) {
4651
var transformation;
@@ -56,7 +61,8 @@ export default class CloudinaryComponent extends Component {
5661

5762
/**
5863
* Combine properties of all options to create an option Object that can be passed to Cloudinary methods.<br>
59-
* All names are converted to snake_case. undefined and null values are filtered out.
64+
* `undefined` and `null` values are filtered out.
65+
* @protected
6066
* @returns {Object}
6167
* @param options one or more options objects
6268
*/
@@ -77,6 +83,7 @@ export default class CloudinaryComponent extends Component {
7783
* Generate a Cloudinary resource URL based on the options provided and child Transformation elements
7884
* @param options
7985
* @returns {string} a cloudinary URL
86+
* @protected
8087
*/
8188
getUrl(options) {
8289
let transformation = this.getTransformation(options);
@@ -98,6 +105,7 @@ CloudinaryComponent.childContextTypes = {};
98105
* Create a React type definition object. All items are PropTypes.string or [string] or object or [object].
99106
* @param {Array} configParams a list of parameter names
100107
* @returns {Object}
108+
* @private
101109
*/
102110
function typesFrom(configParams) {
103111
configParams = configParams || [];
@@ -109,3 +117,4 @@ function typesFrom(configParams) {
109117
return types;
110118
}
111119

120+
export default CloudinaryComponent;

src/components/CloudinaryContext/CloudinaryContext.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import CloudinaryComponent from '../CloudinaryComponent';
44
/**
55
* Provides a container for Cloudinary components. Any option set in CloudinaryContext will be passed to the children.
66
* @example
7-
* <CloudinaryContext cloudName="mycloud" dpr="auto">
8-
* <!-- other tags -->
9-
* <Image publicId={id}/>
10-
* </CloudinaryContext>
7+
*<CloudinaryContext cloudName="mycloud" dpr="auto">
8+
* <!-- other tags -->
9+
* <Image publicId={id}/>
10+
*</CloudinaryContext>
1111
*
1212
*/
13-
export default class CloudinaryContext extends CloudinaryComponent {
13+
class CloudinaryContext extends CloudinaryComponent {
1414
constructor(props, context) {
1515
super(props, context);
1616
this.state = {};
@@ -37,4 +37,6 @@ export default class CloudinaryContext extends CloudinaryComponent {
3737

3838
CloudinaryContext.propTypes = CloudinaryComponent.propTypes;
3939
CloudinaryContext.defaultProps = {};
40-
CloudinaryContext.childContextTypes = CloudinaryComponent.contextTypes;
40+
CloudinaryContext.childContextTypes = CloudinaryComponent.contextTypes;
41+
42+
export default CloudinaryContext;

src/components/Image/Image.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import CloudinaryComponent from '../CloudinaryComponent';
44
import {debounce, firstDefined, closestAbove, requestAnimationFrame, equals, isElement} from '../../Util';
55

66
/**
7-
* An element representing a Cloudinary served image
7+
* A component representing a Cloudinary served image
88
*/
9-
export default class Image extends CloudinaryComponent {
9+
class Image extends CloudinaryComponent {
1010
constructor(props, context) {
1111
function defaultBreakpoints(width, steps = 100) {
1212
return steps * Math.ceil(width / steps);
@@ -22,6 +22,7 @@ export default class Image extends CloudinaryComponent {
2222
/**
2323
* Retrieve the window or default view of the current element
2424
* @returns {DocumentView|*}
25+
* @private
2526
*/
2627
get window() {
2728
let windowRef = null;
@@ -45,6 +46,7 @@ export default class Image extends CloudinaryComponent {
4546
* @param {Object} [props=this.props]
4647
* @param {Object} [context=this.context]
4748
* @returns {Object} state updates
49+
* @private
4850
*/
4951
prepareState(props = this.props, context = this.context) {
5052
let options = CloudinaryComponent.normalizeOptions(context, props);
@@ -217,3 +219,5 @@ export default class Image extends CloudinaryComponent {
217219
Image.defaultProps = {};
218220
Image.contextTypes = CloudinaryComponent.contextTypes;
219221
Image.propTypes = CloudinaryComponent.propTypes;
222+
223+
export default Image;

src/components/Transformation/Transformation.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import React, {Component} from 'react';
22
import CloudinaryComponent from '../CloudinaryComponent';
33

4-
export default class Transformation extends CloudinaryComponent {
4+
/**
5+
* Define a transformation that is applied to the parent tag.
6+
*/
7+
class Transformation extends CloudinaryComponent {
58
constructor(props) {
69
super(props);
710
}
@@ -12,4 +15,6 @@ export default class Transformation extends CloudinaryComponent {
1215
}
1316
Transformation.propTypes = CloudinaryComponent.propTypes;
1417
Transformation.defaultProps = {};
15-
Transformation.contextTypes = {};
18+
Transformation.contextTypes = {};
19+
20+
export default Transformation;

src/components/Video/Video.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ const DEFAULT_POSTER_OPTIONS = {
77
resource_type: 'video'
88
};
99

10-
export default class Video extends CloudinaryComponent {
10+
/**
11+
* A component representing a Cloudinary served video
12+
*/
13+
class Video extends CloudinaryComponent {
1114
constructor(props) {
1215
super(props);
1316
this.state = {};
@@ -56,4 +59,6 @@ export default class Video extends CloudinaryComponent {
5659
}
5760
Video.propTypes = {publicId: PropTypes.string};
5861
Video.defaultProps = {};
59-
Video.contextTypes = CloudinaryComponent.contextTypes;
62+
Video.contextTypes = CloudinaryComponent.contextTypes;
63+
64+
export default Video;

0 commit comments

Comments
 (0)