-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from nuxt-modules/chore/2.4.0
Chore/2.4.0
- Loading branch information
Showing
17 changed files
with
523 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,6 @@ | |
"nuxt": "^3.6.2" | ||
}, | ||
"dependencies": { | ||
"@nuxtjs/cloudinary": "^2.3.4" | ||
"@nuxtjs/cloudinary": "^2.4.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script setup lang="ts"> | ||
const buttonId = "open-btn"; | ||
const apiKey = "12345"; | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<button :id="buttonId">Select Image or Video</button> | ||
Check warning on line 8 in docs/components/content/MediaLibrary.vue GitHub Actions / ci (ubuntu-latest, 16)
|
||
<CldMediaLibrary :api-key="apiKey" :button-id="buttonId" /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script setup lang="ts"> | ||
const mediaAssets = [ | ||
{ tag: "electric_car_product_gallery_demo" }, // by default mediaType: "image" | ||
{ tag: "electric_car_product_gallery_demo", mediaType: "video" }, | ||
{ tag: "electric_car_360_product_gallery_demo", mediaType: "spin" }, | ||
]; | ||
</script> | ||
|
||
<template> | ||
<CldProductGallery :media-assets="mediaAssets" cloud-name="demo" /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# CldMediaLibrary.vue | ||
|
||
--- | ||
|
||
The CldMediaLibrary creates a media gallery element that uses an instance of the [Cloudinary Media Library Widget](https://cloudinary.com/documentation/media_library_widget) to give you an easy way to add media librarry component to your Nuxt app. | ||
|
||
## Basic Usage | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
const buttonId = "open-btn"; | ||
const apiKey = useRuntimeConfig().public.cloudinary.apiKey; | ||
</script> | ||
<template> | ||
<div> | ||
<button :id="buttonId">Select Image or Video</button> | ||
<CldMediaLibrary :api-key="apiKey" :button-id="buttonId" /> | ||
</div> | ||
</template> | ||
``` | ||
|
||
:media-library | ||
|
||
## Props | ||
|
||
CldMediaLibrary accepts several customization props listed below: | ||
|
||
| Prop Name | Type | Example | | ||
| --------- | ------- | ---------- | | ||
| cloudName | string | `"demo"` | | ||
| apiKey | string | `"12345"` | | ||
| buttonId | string | `"my-btn"` | | ||
| username | string | `"user"` | | ||
| useSaml | boolean | `false` | | ||
| params | object | `{}` | | ||
|
||
For all other available props checkout [Cloudinary Media Gallery Docs](https://cloudinary.com/documentation/media_library_widget#2_set_the_configuration_options) and make sure to pass them to the component as `params` like following: | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
const buttonId = "open-btn"; | ||
const apiKey = useRuntimeConfig().public.cloudinary.apiKey; | ||
const params = { | ||
sortProps: { | ||
button_caption: "Open Media Library", | ||
insert_caption: "Insert", | ||
remove_header: false, | ||
max_files: 6, | ||
}, | ||
}; | ||
</script> | ||
<template> | ||
<div> | ||
<button :id="buttonId">Select Image or Video</button> | ||
<ClsMediaLibrary :api-key="apiKey" :button-id="buttonId" :params="params" /> | ||
</div> | ||
</template> | ||
``` | ||
|
||
## Events | ||
|
||
ClsMediaLibrary emits following events: | ||
|
||
| Event Name | Type | Example | | ||
| ---------- | -------- | --------------- | | ||
| onInsert | function | `(data) => { }` | | ||
|
||
You can use this event like following: | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
const buttonId = "open-btn"; | ||
const apiKey = useRuntimeConfig().public.cloudinary.apiKey; | ||
function handleInsert(data: unknown) { | ||
console.log(data) | ||
} | ||
</script> | ||
<template> | ||
<div> | ||
<button :id="buttonId">Select Image or Video</button> | ||
<ClsMediaLibrary | ||
:api-key="apiKey" | ||
:button-id="buttonId" | ||
:params="params" | ||
@on-insert="handleInsert" | ||
/> | ||
</div> | ||
</template> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# CldProductGallery.vue | ||
|
||
--- | ||
|
||
The CldProductGallery creates a product gallery element that uses an instance of the [Cloudinary Product Gallery Widget](https://cloudinary.com/documentation/product_gallery_reference) to give you an easy way to add product gallery component to your Nuxt app. | ||
|
||
## Basic Usage | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
const mediaAssets = [ | ||
{ tag: "electric_car_product_gallery_demo" }, // by default mediaType: "image" | ||
{ tag: "electric_car_product_gallery_demo", mediaType: "video" }, | ||
{ tag: "electric_car_360_product_gallery_demo", mediaType: "spin" }, | ||
]; | ||
</script> | ||
<template> | ||
<CldProductGallery :media-assets="mediaAssets" /> | ||
</template> | ||
``` | ||
|
||
:product-gallery | ||
|
||
## Props | ||
|
||
CldProductGallery accepts several customization props listed below: | ||
|
||
| Prop Name | Type | Example | | ||
| ---------------- | ------- | -------------------------------------------------------------------- | | ||
| cloudName | string | `"demo"` | | ||
| mediaAssets | array | `[{ tag: 'electric_car_product_gallery_demo', mediaType: 'video' }]` | | ||
| displayProps | object | `{ mode: "expanded", columns: 2 }` | | ||
| aspectRatio | string | `"4:3"` | | ||
| imageBreakpoint | number | `200` | | ||
| carouselStyle | string | `"indicators"` | | ||
| indicatorProps | object | `{ color: "red" }` | | ||
| carouselLocation | string | `"right"` | | ||
| borderColor | string | `"red"` | | ||
| borderWidth | number | `5` | | ||
| transition | string | `"fade"` | | ||
| zoom | boolean | `false` | | ||
| params | object | `{}` | | ||
|
||
For all other available props checkout [Cloudinary Product Gallery Docs](https://cloudinary.com/documentation/product_gallery_reference#widget_parameters) and make sure to pass them to the component as `params` like following: | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
const mediaAssets = [ | ||
{ tag: "electric_car_product_gallery_demo" }, // by default mediaType: "image" | ||
{ tag: "electric_car_product_gallery_demo", mediaType: "video" }, | ||
{ tag: "electric_car_360_product_gallery_demo", mediaType: "spin" }, | ||
]; | ||
const params = { | ||
sortProps: { | ||
source: "public_id", | ||
direction: "asc", | ||
videoBreakpoint: 200, | ||
carouselOffset: 6 | ||
} | ||
} | ||
</script> | ||
<template> | ||
<CldProductGallery | ||
:media-assets="mediaAssets" | ||
:params="params" | ||
/> | ||
</template> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,6 @@ | |
"nuxt": "^3.5.3" | ||
}, | ||
"dependencies": { | ||
"@nuxtjs/cloudinary": "^2.3.4" | ||
"@nuxtjs/cloudinary": "^2.4.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<script setup lang="ts"> | ||
import { useHead } from "@unhead/vue"; | ||
import { useRuntimeConfig } from "#imports"; | ||
import { PropType, ref } from "vue"; | ||
const cloudinaryRef = ref(); | ||
const props = defineProps({ | ||
cloudName: { | ||
type: String, | ||
default: "", | ||
}, | ||
apiKey: { | ||
type: String, | ||
required: true | ||
}, | ||
username: { | ||
type: String, | ||
default: "", | ||
}, | ||
useSaml: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
buttonId: { | ||
type: String, | ||
required: true, | ||
}, | ||
// Other params listed https://cloudinary.com/documentation/media_library_widget#2_set_the_configuration_options | ||
params: { | ||
type: Object as PropType<Record<string, any>>, | ||
default: () => ({}), | ||
}, | ||
}); | ||
const emit = defineEmits(['onInsert']) | ||
const handleOnLoad = () => { | ||
if ("cloudinary" in window) { | ||
cloudinaryRef.value = window.cloudinary; | ||
const options = Object.fromEntries( | ||
Object.entries(props).filter((elem) => Boolean(elem[1])) | ||
); | ||
cloudinaryRef.value.createMediaLibrary({ | ||
inline_container: '#widget_container', | ||
cloud_name: | ||
props.cloudName || useRuntimeConfig().public.cloudinary.cloudName, | ||
api_key: props.apiKey || useRuntimeConfig().public.cloudinary.apiKey, | ||
...options, | ||
...props.params, | ||
}, | ||
{ | ||
insertHandler: function (data: unknown) { | ||
emit('onInsert', data) | ||
} | ||
}, | ||
document.getElementById(props.buttonId) | ||
); | ||
} | ||
}; | ||
useHead({ | ||
script: [ | ||
{ | ||
id: `cloudinary-media-library-${Math.floor(Math.random() * 100)}`, | ||
src: `https://media-library.cloudinary.com/global/all.js`, | ||
onload: handleOnLoad, | ||
onerror: (e) => | ||
console.error( | ||
`Failed to load Cloudinary Media Library: ${(e as any).message}` | ||
), | ||
}, | ||
], | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<div id="widget_container"></div> | ||
</div> | ||
</template> |
Oops, something went wrong.