├── .eslintignore
├── public
├── favicon.ico
├── favicon-16x16.png
├── favicon-32x32.png
├── apple-touch-icon.png
├── android-chrome-192x192.png
├── android-chrome-512x512.png
├── vercel.svg
├── thirteen.svg
└── next.svg
├── postcss.config.js
├── .env.example
├── .prettierignore
├── .vscode
└── settings.json
├── .editorconfig
├── next-env.d.ts
├── components
├── overlay.tsx
├── header.tsx
├── theme-provider.tsx
├── main-nav.tsx
├── ui
│ ├── input.tsx
│ ├── alert.tsx
│ ├── button.tsx
│ ├── tabs.tsx
│ ├── dialog.tsx
│ └── select.tsx
├── theme-toggle.tsx
├── messages
│ ├── save-error-message.tsx
│ └── fetch-error-message.tsx
├── media
│ ├── gif.tsx
│ ├── illustration.tsx
│ ├── photo.tsx
│ └── video.tsx
├── site-header.tsx
├── empty-state.tsx
├── get-button.tsx
├── content.tsx
├── get-ai.tsx
├── get-gifs.tsx
├── get-pexels-videos.tsx
├── get-vectors.tsx
├── get-illustrations.tsx
├── get-photos.tsx
└── icons.tsx
├── lib
├── fonts.ts
├── data.ts
├── utils.ts
└── types.ts
├── styles
└── globals.css
├── components.json
├── .gitignore
├── config
└── site.ts
├── .eslintrc.json
├── app
├── page.tsx
├── layout.tsx
└── api
│ └── upload
│ └── ai
│ └── route.ts
├── tsconfig.json
├── next.config.mjs
├── hooks
└── useDebouncedValue.tsx
├── prettier.config.js
├── LICENSE
├── utils
└── media-fetch.utils.ts
├── package.json
├── README.md
└── tailwind.config.js
/.eslintignore:
--------------------------------------------------------------------------------
1 | dist/*
2 | .cache
3 | public
4 | node_modules
5 | *.esm.js
6 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cosmicjs/cosmic-media-extension/main/public/favicon.ico
--------------------------------------------------------------------------------
/public/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cosmicjs/cosmic-media-extension/main/public/favicon-16x16.png
--------------------------------------------------------------------------------
/public/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cosmicjs/cosmic-media-extension/main/public/favicon-32x32.png
--------------------------------------------------------------------------------
/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | }
7 |
--------------------------------------------------------------------------------
/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cosmicjs/cosmic-media-extension/main/public/apple-touch-icon.png
--------------------------------------------------------------------------------
/public/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cosmicjs/cosmic-media-extension/main/public/android-chrome-192x192.png
--------------------------------------------------------------------------------
/public/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cosmicjs/cosmic-media-extension/main/public/android-chrome-512x512.png
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | NEXT_PUBLIC_UNSPLASH_KEY=
2 | NEXT_PUBLIC_PEXELS_KEY=
3 | NEXT_PUBLIC_PIXABAY_KEY=
4 | NEXT_PUBLIC_OPENAI_API_KEY=
5 | NEXT_PUBLIC_GIPHY_KEY=
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | cache
2 | .cache
3 | package.json
4 | package-lock.json
5 | public
6 | CHANGELOG.md
7 | .yarn
8 | dist
9 | node_modules
10 | .next
11 | build
12 | .contentlayer
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "typescript.tsdk": "../../node_modules/.pnpm/typescript@4.9.5/node_modules/typescript/lib",
3 | "typescript.enablePromptUseWorkspaceTsdk": true
4 | }
5 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | end_of_line = lf
7 | indent_size = 2
8 | indent_style = space
9 | insert_final_newline = true
10 | trim_trailing_whitespace = true
11 |
--------------------------------------------------------------------------------
/next-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
7 |
8 |
9 |
10 |
11 |
12 | ## How to use it
13 | You can use Cosmic Media to search and download media manually, or you can install it in your [Cosmic](https://www.cosmicjs.com/) project as an extension to save media directly in your project.
14 |
15 |
16 | ## How to install in Cosmic
17 |
18 | 1. [Log in to Cosmic](https://app.cosmicjs.com/login).
19 | 2. Go to _Project > Extensions_.
20 | 3. Find this extension and click "Install".
21 |
22 | ## Service keys
23 |
24 | The deployed app uses default API keys for Unsplash, Giphy, Pexels, Pixaby, and OpenAI. If you run into API rate-limit issues, you can update these to your own keys:
25 |
26 | 1. `unsplash_key` Register for a key [here](https://unsplash.com/developers).
27 | 2. `pexels_key` Register for a key [here](https://www.pexels.com/api).
28 | 3. `pixabay_key` Register for a key [here](https://pixabay.com/service/about/api)
29 | 4. `openai_key` Register for a key [here](https://platform.openai.com)
30 | 5. `giphy_key` Register for a key [here](https://developers.giphy.com)
31 |
32 | ### Using service keys
33 | Keys can be provided to the app in one of the following ways:
34 |
35 | 1. As query params in the URL. For example: `?unsplash_key=YOUR_UNSPLASH_KEY&pexels_key=YOUR_PEXELS_KEY`
36 | 2. Using the `.env` file. See the `.env.example` file for env var format.
37 | 3. If installed in Cosmic as an extension, go to Cosmic Media extension settings page by going to _Extensions > Cosmic Media > Settings_, find the Query Parameters section and update the following query params to your own keys:
38 |
39 |
40 |
41 |
42 |
43 | ## Run locally
44 |
45 | ```bash
46 | git clone https://github.com/cosmicjs/cosmic-media-extension
47 | cd cosmic-media-extension
48 | yarn
49 | yarn dev
50 | ```
51 |
52 | ## Built with
53 | - [shadcn/ui](https://github.com/shadcn-ui/ui)
54 | - Next.js 13 App Directory
55 | - Radix UI Primitives
56 | - Tailwind CSS
57 | - Icons from [Lucide](https://lucide.dev)
58 | - Dark mode with `next-themes`
59 | - Tailwind CSS class sorting, merging and linting.
60 |
61 | ## License
62 |
63 | Licensed under the [MIT license](https://github.com/cosmicjs/cosmic-media-extension/blob/main/LICENSE.md).
64 |
--------------------------------------------------------------------------------
/components/ui/dialog.tsx:
--------------------------------------------------------------------------------
1 | "use client"
2 |
3 | import * as React from "react"
4 | import * as DialogPrimitive from "@radix-ui/react-dialog"
5 | import { X } from "lucide-react"
6 |
7 | import { cn } from "@/lib/utils"
8 |
9 | const Dialog = DialogPrimitive.Root
10 |
11 | const DialogTrigger = DialogPrimitive.Trigger
12 |
13 | const DialogPortal = ({
14 | className,
15 | ...props
16 | }: DialogPrimitive.DialogPortalProps) => (
17 |