Skip to content

Commit a0d7a3a

Browse files
ANKUR DWIVEDIANKUR DWIVEDI
authored andcommitted
replaced IKContext with ImageKitProvider
1 parent 390da91 commit a0d7a3a

File tree

16 files changed

+185
-165
lines changed

16 files changed

+185
-165
lines changed

README.md

Lines changed: 53 additions & 34 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "imagekitio-react",
3-
"version": "4.2.0",
3+
"version": "5.0.0",
44
"description": "React SDK for ImageKit.io which implements client-side upload and URL generation for use inside a react application.",
55
"scripts": {
66
"build:js": "rollup -c",

src/components/IKImage/combinedProps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { UrlOptionsPath, UrlOptionsSrc } from "imagekit-javascript/dist/src/interfaces/UrlOptions";
22
import { InferProps } from "prop-types";
3-
import COMMON_PROPS from "../IKContext/props";
3+
import COMMON_PROPS from "../ImageKitProvider/props";
44
import Props from "./props";
55

66
const COMBINED_IMAGE_PROP_TYPES = {

src/components/IKImage/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useContext, useEffect, useRef, useState } from 'react';
22
import COMBINED_PROP_TYPES, { IKImageProps } from './combinedProps';
33
import { fetchEffectiveConnection, getIKElementsUrl, getSrc } from '../../utils/Utility';
4-
import { ImageKitContext } from '../IKContext';
4+
import { ImageKitContext } from '../ImageKitProvider';
55
import useImageKitComponent from '../ImageKitComponent';
66

77
const IKImage = (props: IKImageProps) => {

src/components/IKUpload/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import React, { forwardRef, useContext, useEffect, useState } from 'react';
2-
import { IKContextBaseProps } from "../IKContext/props";
2+
import { ImageKitProviderBaseProps } from "../ImageKitProvider/props";
33
import { IKUploadProps, OverrideValues } from "./props";
4-
import { ImageKitContext } from '../IKContext';
4+
import { ImageKitContext } from '../ImageKitProvider';
55
import useImageKitComponent from '../ImageKitComponent';
66

77
type IKUploadState = {
88
xhr?: XMLHttpRequest;
99
};
1010

11-
const IKUpload = forwardRef<HTMLInputElement, IKUploadProps & IKContextBaseProps>((props, ref) => {
11+
const IKUpload = forwardRef<HTMLInputElement, IKUploadProps & ImageKitProviderBaseProps>((props, ref) => {
1212
const [state, setState] = useState<IKUploadState>({});
1313
const contextOptions = useContext(ImageKitContext);
1414
const { getIKClient } = useImageKitComponent({ ...props });

src/components/IKVideo/combinedProps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { UrlOptionsPath, UrlOptionsSrc } from 'imagekit-javascript/dist/src/interfaces/UrlOptions';
22
import { InferProps } from 'prop-types';
3-
import COMMON_PROPS from "../IKContext/props";
3+
import COMMON_PROPS from "../ImageKitProvider/props";
44
import Props from './props';
55

66
const COMBINED_IMAGE_PROP_TYPES = {

src/components/IKVideo/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import React, { useContext, useEffect, useRef, useState } from 'react';
2-
import { IKContextBaseProps, IKContextExtractedProps } from "../IKContext/props";
2+
import { ImageKitProviderBaseProps, ImageKitProviderExtractedProps } from "../ImageKitProvider/props";
33
import COMBINED_PROP_TYPES, { IKVideoProps } from './combinedProps';
44
import { getSrc } from '../../utils/Utility';
55
import useImageKitComponent from '../ImageKitComponent';
6-
import { ImageKitContext } from '../IKContext';
6+
import { ImageKitContext } from '../ImageKitProvider';
77

88
export type IKVideoState = {
99
currentUrl?: string;
10-
contextOptions: IKContextExtractedProps;
10+
contextOptions: ImageKitProviderExtractedProps;
1111
};
1212

13-
const IKVideo = (props: IKVideoProps & IKContextBaseProps) => {
13+
const IKVideo = (props: IKVideoProps & ImageKitProviderBaseProps) => {
1414
const videoRef = useRef<HTMLVideoElement>(null);
1515
const [state, setState] = useState<IKVideoState>({
1616
currentUrl: undefined,

src/components/ImageKitComponent/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, { useContext } from 'react';
22
import ImageKit from 'imagekit-javascript';
3-
import { IKContextBaseProps } from '../IKContext/props';
4-
import { ImageKitContext } from '../IKContext';
3+
import { ImageKitProviderBaseProps } from '../ImageKitProvider/props';
4+
import { ImageKitContext } from '../ImageKitProvider';
55

6-
const useImageKitComponent= <T = void>(props: React.PropsWithChildren & IKContextBaseProps & T):{getIKClient:() => ImageKit} => {
6+
const useImageKitComponent= <T = void>(props: React.PropsWithChildren & ImageKitProviderBaseProps & T):{getIKClient:() => ImageKit} => {
77
const contextOptions = useContext(ImageKitContext);
88

99
const getIKClient = (): ImageKit => {
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@
22
import React, { createContext } from 'react';
33
import { InferProps } from 'prop-types';
44
import ImageKit from 'imagekit-javascript';
5-
import { IKContextProps, IKContextExtractedProps } from "./props";
5+
import { ImageKitProviderProps, ImageKitProviderExtractedProps } from "./props";
66

77
// Create the context
8-
export const ImageKitContext = createContext<IKContextExtractedProps>({});
8+
export const ImageKitContext = createContext<ImageKitProviderExtractedProps>({});
99

1010
/**
11-
* Provides a container for ImageKit components. Any option set in IKContext will be passed to the children.
11+
* Provides a container for ImageKit components. Any option set in ImageKitProvider will be passed to the children.
1212
*
1313
* @example
14-
*<IKContext publicKey="<public key>" urlEndpoint="url link">
14+
*<ImageKitProvider publicKey="<public key>" urlEndpoint="url link">
1515
* <!-- other tags -->
1616
* <Image src={link}/>
17-
*</IKContext>
17+
*</ImageKitProvider>
1818
*/
19-
const IKContext = (props: React.PropsWithChildren<IKContextProps>) => {
19+
const ImageKitProvider = (props: React.PropsWithChildren<ImageKitProviderProps>) => {
2020

21-
const extractContextOptions = (mergedOptions: InferProps<IKContextExtractedProps>) => {
22-
var result: IKContextExtractedProps = {};
21+
const extractContextOptions = (mergedOptions: InferProps<ImageKitProviderExtractedProps>) => {
22+
var result: ImageKitProviderExtractedProps = {};
2323

24-
const propKeys = Object.keys(IKContextExtractedProps);
24+
const propKeys = Object.keys(ImageKitProviderExtractedProps);
2525

2626
for (var i = 0; i < propKeys.length; i++) {
2727
var key = propKeys[i];
28-
const value = mergedOptions[key as keyof IKContextExtractedProps];
28+
const value = mergedOptions[key as keyof ImageKitProviderExtractedProps];
2929
if (value) {
30-
result[key as keyof IKContextExtractedProps] = value;
30+
result[key as keyof ImageKitProviderExtractedProps] = value;
3131
}
3232
}
3333

@@ -55,4 +55,4 @@ const IKContext = (props: React.PropsWithChildren<IKContextProps>) => {
5555
);
5656
}
5757

58-
export default IKContext;
58+
export default ImageKitProvider;
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ const Props = {
77
authenticator: PropTypes.func
88
};
99

10-
export const IKContextProps = {
10+
export const ImageKitProviderProps = {
1111
...Props,
1212
transformationPosition: PropTypes.oneOf(['path', 'query']),
1313
};
1414

15-
export const IKContextExtractedProps = {
16-
...IKContextProps,
15+
export const ImageKitProviderExtractedProps = {
16+
...ImageKitProviderProps,
1717
ikClient: PropTypes.instanceOf(ImageKit),
1818
};
1919

20-
export type IKContextProps = InferProps<typeof IKContextProps> & {
20+
export type ImageKitProviderProps = InferProps<typeof ImageKitProviderProps> & {
2121
urlEndpoint?: string;
2222
};
2323

24-
export type IKContextBaseProps = InferProps<typeof Props>;
24+
export type ImageKitProviderBaseProps = InferProps<typeof Props>;
2525

26-
export type IKContextExtractedProps = InferProps<typeof IKContextExtractedProps> & {
26+
export type ImageKitProviderExtractedProps = InferProps<typeof ImageKitProviderExtractedProps> & {
2727
urlEndpoint?: string;
2828
};
2929

0 commit comments

Comments
 (0)