diff --git a/pom.xml b/pom.xml index 6c6594c..a84b853 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.flowingcode.vaadin.addons image-crop-addon - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT Image Crop Add-on Image Crop Add-on for Vaadin Flow https://www.flowingcode.com/en/open-source/ diff --git a/src/main/java/com/flowingcode/vaadin/addons/imagecrop/ImageCrop.java b/src/main/java/com/flowingcode/vaadin/addons/imagecrop/ImageCrop.java index e990585..8ec08a4 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/imagecrop/ImageCrop.java +++ b/src/main/java/com/flowingcode/vaadin/addons/imagecrop/ImageCrop.java @@ -46,7 +46,10 @@ @JsModule("./src/image-crop.tsx") @Tag("image-crop") @CssImport("react-image-crop/dist/ReactCrop.css") +@CssImport("./styles/image-crop-styles.css") public class ImageCrop extends ReactAdapterComponent { + + private static final String IMG_FULL_HEIGHT_CLASS_NAME = "img-full-height"; private String croppedImageDataUri; @@ -341,6 +344,21 @@ public String getCroppedImageDataUri() { return this.croppedImageDataUri; } + /** + * Sets the image to occupy the full viewport height when enabled. + * If {@code fullHeight} is {@code true}, applies a CSS class that + * sets the image height to 100vh. If {@code false}, removes the class + * to revert to the default height. + * + * @param fullHeight whether the image should fill the viewport height + */ + public void setImageFullHeight(Boolean fullHeight) { + if (fullHeight) + this.addClassName(IMG_FULL_HEIGHT_CLASS_NAME); + else + this.removeClassName(IMG_FULL_HEIGHT_CLASS_NAME); + } + /** * Decodes the cropped image data URI and returns it as a byte array. If the image data URI is not * in the format "data:image/*;base64,", it will be decoded assuming it is a Base64 encoded diff --git a/src/main/resources/META-INF/frontend/styles/image-crop-styles.css b/src/main/resources/META-INF/frontend/styles/image-crop-styles.css new file mode 100644 index 0000000..e455f43 --- /dev/null +++ b/src/main/resources/META-INF/frontend/styles/image-crop-styles.css @@ -0,0 +1,23 @@ +/*- + * #%L + * Image Crop Add-on + * %% + * Copyright (C) 2024 Flowing Code + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + +.img-full-height img { + height: 100vh; +}; \ No newline at end of file