Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dribbble plugin #123

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/dribbble.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,247 changes: 1,181 additions & 66 deletions package-lock.json

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions plugins/dribbble/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies

/node_modules
/.pnp
.pnp.js
.yarn

# misc

.DS_Store
\*.pem

# files

my-plugin
dev-plugin
dist

# debug

npm-debug.log*
yarn-debug.log*
yarn-error.log\*

# local env files

.env\*.local

# Packed plugin

plugin.zip
7 changes: 7 additions & 0 deletions plugins/dribbble/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Dribbble Plugin

Sync shots from Dribbble

**By:** @sakib25800

![Dribbble Image](../../assets/dribbble.png)
25 changes: 25 additions & 0 deletions plugins/dribbble/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import js from "@eslint/js"
import globals from "globals"
import reactHooks from "eslint-plugin-react-hooks"
import reactRefresh from "eslint-plugin-react-refresh"
import tseslint from "typescript-eslint"

export default tseslint.config(
{ ignores: ["dist"] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2022,
globals: globals.browser,
},
plugins: {
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
},
}
)
6 changes: 6 additions & 0 deletions plugins/dribbble/framer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"id": "357ab0",
"name": "Dribbble",
"modes": ["canvas", "configureManagedCollection", "syncManagedCollection"],
"icon": "/icon.svg"
}
14 changes: 14 additions & 0 deletions plugins/dribbble/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/icon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dribbble</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

41 changes: 41 additions & 0 deletions plugins/dribbble/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "dribbble",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"pack": "npx framer-plugin-tools@latest pack"
},
"dependencies": {
"@tanstack/react-query": "^5.61.5",
"classnames": "^2.5.1",
"framer-plugin": "^2",
"p-limit": "^6.1.0",
"react": "^18",
"react-dom": "^18",
"react-error-boundary": "^4.1.2",
"vite-plugin-mkcert": "^1"
},
"devDependencies": {
"@eslint/js": "^9",
"@types/react": "^18",
"@types/react-dom": "^18",
"@vitejs/plugin-react": "^4.3.1",
"@vitejs/plugin-react-swc": "^3",
"autoprefixer": "^10.4.20",
"eslint": "^9.9.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.9",
"globals": "^15.9.0",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.15",
"typescript": "^5.3",
"typescript-eslint": "^8.0.1",
"vite": "^5",
"vite-plugin-framer": "^1"
}
}
6 changes: 6 additions & 0 deletions plugins/dribbble/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
15 changes: 15 additions & 0 deletions plugins/dribbble/public/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions plugins/dribbble/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { useEffect, useState } from "react"
import { getPluginContext, PluginContext, useSyncShotsMutation } from "./sync"
import { framer } from "framer-plugin"
import auth from "./auth"
import Authenticate from "./pages/Authenticate"
import MapFields from "./pages/MapFields"

export function AuthenticatedApp({ context }: { context: PluginContext }) {
const syncMutation = useSyncShotsMutation({
onSuccess: result => (result.status === "success" ? framer.closePlugin("Synchronization successful") : null),
onError: e => framer.notify(e.message, { variant: "error" }),
})

useEffect(() => {
framer.showUI({
width: 340,
height: 410,
})
}, [])

return <MapFields context={context} onSubmit={syncMutation.mutate} isLoading={syncMutation.isPending} />
}

export function App({ context }: { context: PluginContext }) {
const [pluginContext, setPluginContext] = useState(context)

useEffect(() => {
if (!auth.isAuthenticated()) {
framer.showUI({
width: 260,
height: 345,
})
}
}, [])

const handleAuthenticated = async () => {
setPluginContext(await getPluginContext())
}

if (!auth.isAuthenticated()) {
return <Authenticate onAuthenticated={handleAuthenticated} />
}

return <AuthenticatedApp context={pluginContext} />
}
Loading