uploadcare / uploadcare-widget

Uploadcare Widget, an ultimate tool for HTML5 file upload supporting multiple file upload, drag&drop, validation by file size/file extension/MIME file type, progress bar for file uploads, image preview.
https://uploadcare.com/products/file_uploader/
BSD 2-Clause "Simplified" License
227 stars 102 forks source link

How to disable photo button in Video widget in uploadcare #954

Closed Abhishek-pa closed 1 year ago

Abhishek-pa commented 1 year ago

I have a query that while selecting the camera option in video widget in upload care there is also the photo button on right side of the widget. I want to disable that button. Can anyone please guide me on this. Help will be apreciated

optlsnd commented 1 year ago

You can hide the button with CSS

.uploadcare--camera__button_type_capture,
.uploadcare--camera__button_type_photo {
  display: none;
}
Abhishek-pa commented 1 year ago

It's not working because i have 2 widgets in my data-page , One is image wieget and another is video widget. Class of video widget is .uploadcare--button uploadcare--button_primary uploadcare--camerabutton uploadcare--camerabutton_type_capture and this is inside another class .uploadcare--camera__controls.. Css is not working on this

optlsnd commented 1 year ago

You'll need to use some JS and a CSS variable if you have two or more widget instances on a page.

The CSS part:

:root {
  --photo-btn-display: inline-block;
}

.uploadcare--camera__button_type_capture,
.uploadcare--camera__button_type_photo {
  display: var(--photo-btn-display);
}

The JS part:

const root = document.querySelector(":root");

const videoWidget = uploadcare.Widget("#video-widget");
const photoWidget = uploadcare.Widget("#photo-widget");

photoWidget.onDialogOpen(() => {
  root.style.setProperty("--photo-btn-display", "inline-block");
});

videoWidget.onDialogOpen(() => {
  root.style.setProperty("--photo-btn-display", "none");
});

Check out a live demo here https://codesandbox.io/s/dynamic-widget-styling-with-css-variables-1ro9wv

Abhishek-pa commented 1 year ago

Thanks a lott..