Skip to content

Commit

Permalink
fix: buttonClassNames and buttonStyles
Browse files Browse the repository at this point in the history
  • Loading branch information
fers4t committed Dec 12, 2022
1 parent 0118c6b commit dc9aa8c
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 9 deletions.
65 changes: 60 additions & 5 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,9 +1,64 @@
### IN DEVELOPMENT
# cloudinary-react-widget

## Install package to Next.js app
Next.js component for [Cloudinary Upload Widget](https://cloudinary.com/documentation/upload_widget)

cd example pnpm install ../
### Installing

## Watch changes
I did not release it on NPM for now. So you can install it like this;

cd to root folder and run pnpm watch
```bash
pnpm install fers4t/cloudinary-react-widget
```

### Usage

```tsx
import React, { useState } from 'react';
import { CloudinaryUpload } from 'cloudinary-react-widget';

export default function Home() {
const [callbacks, setCallbacks] = useState();
return (
<CloudinaryUpload
cloudName="YOUR CLOUD NAME"
uploadPreset="YOUR UPLOAD PRESET"
onUpload={(a) => setCallbacks(a)}
/>
);
}
```

You can track all callbacks with `onUpload` prop. I'm storing all of them.

## Styling

```tsx
import React, { useState } from 'react';
import { CloudinaryUpload } from 'cloudinary-react-widget';

export default function Home() {
const [callbacks, setCallbacks] = useState();

return (
<CloudinaryUpload
cloudName="YOUR CLOUD NAME"
uploadPreset="YOUR UPLOAD PRESET"
onUpload={(a) => setCallbacks(a)}
buttonClassNames="text-lg font-bold"
imageWrapperStyles={{ width: '100px', height: '100px' }}
/>
);
}
```

Custom styles are **overriding defaults completely**. So if you want to use custom styles, you must handle whole style yourself.

## TO-DO

- [ ] Add `multiple` prop to prevent/allow multiple uploads.
- [ ] Add `signed` version
... open issues/PRs for more.

## License

This project is licensed under the MIT License.
13 changes: 9 additions & 4 deletions src/cloudinary-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const CloudinaryUpload: React.FC<ICloudinaryUpload> = (props) => {
}}
/>
<button
className={`cloudinary-close-btn-${cb.info.etag} ${buttonClassNames || ''}`}
className={`cloudinary-close-btn-${cb.info.etag}`}
style={{
// display: 'none',
display: 'flex',
Expand All @@ -120,8 +120,7 @@ const CloudinaryUpload: React.FC<ICloudinaryUpload> = (props) => {
outline: 'none',
border: 'none',
padding: '2px',
cursor: 'pointer',
...buttonStyles
cursor: 'pointer'
}}
onClick={() => {
// @ts-ignore
Expand All @@ -145,7 +144,13 @@ const CloudinaryUpload: React.FC<ICloudinaryUpload> = (props) => {
)}

<div>
<button type="button" id="leftbutton" onClick={openWidget}>
<button
type="button"
id="leftbutton"
onClick={openWidget}
className={buttonClassNames || ''}
style={buttonStyles || {}}
>
Upload Image(s)
</button>
</div>
Expand Down

0 comments on commit dc9aa8c

Please sign in to comment.