diff --git a/package.json b/package.json index bafd76f4..5e3cc679 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,9 @@ "tauri": "tauri" }, "dependencies": { - "@headlessui/react": "^1.7.11", "@nanostores/persistent": "^0.7.0", "@nanostores/react": "^0.4.1", + "@radix-ui/react-dialog": "^1.0.2", "@tauri-apps/api": "^1.2.0", "@uiw/react-markdown-preview": "^4.1.8", "@uiw/react-md-editor": "^3.20.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 977a0422..3415ec40 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,9 +1,9 @@ lockfileVersion: 5.4 specifiers: - '@headlessui/react': ^1.7.11 '@nanostores/persistent': ^0.7.0 '@nanostores/react': ^0.4.1 + '@radix-ui/react-dialog': ^1.0.2 '@tailwindcss/typography': ^0.5.9 '@tauri-apps/api': ^1.2.0 '@tauri-apps/cli': ^1.2.3 @@ -48,9 +48,9 @@ specifiers: unique-names-generator: ^4.7.1 dependencies: - '@headlessui/react': 1.7.11_biqbaboplfbrettd7655fr4n2y '@nanostores/persistent': 0.7.0_nanostores@0.7.4 '@nanostores/react': 0.4.1_nkfnbc2tpc77iht7asm3uqwau4 + '@radix-ui/react-dialog': 1.0.2_zula6vjvt3wdocc4mwcxqa6nzi '@tauri-apps/api': 1.2.0 '@uiw/react-markdown-preview': 4.1.8_zula6vjvt3wdocc4mwcxqa6nzi '@uiw/react-md-editor': 3.20.5_zula6vjvt3wdocc4mwcxqa6nzi @@ -397,18 +397,6 @@ packages: - supports-color dev: true - /@headlessui/react/1.7.11_biqbaboplfbrettd7655fr4n2y: - resolution: {integrity: sha512-EaDbVgcyiylhtskZZf4Qb/JiiByY7cYbd0qgZ9xm2pm2X7hKojG0P4TaQYKgPOV3vojPhd/pZyQh3nmRkkcSyw==} - engines: {node: '>=10'} - peerDependencies: - react: ^16 || ^17 || ^18 - react-dom: ^16 || ^17 || ^18 - dependencies: - client-only: 0.0.1 - react: 18.2.0 - react-dom: 18.2.0_react@18.2.0 - dev: false - /@humanwhocodes/config-array/0.11.8: resolution: {integrity: sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==} engines: {node: '>=10.10.0'} @@ -701,6 +689,191 @@ packages: tslib: 2.5.0 dev: true + /@radix-ui/primitive/1.0.0: + resolution: {integrity: sha512-3e7rn8FDMin4CgeL7Z/49smCA3rFYY3Ha2rUQ7HRWFadS5iCRw08ZgVT1LaNTCNqgvrUiyczLflrVrF0SRQtNA==} + dependencies: + '@babel/runtime': 7.21.0 + dev: false + + /@radix-ui/react-compose-refs/1.0.0_react@18.2.0: + resolution: {integrity: sha512-0KaSv6sx787/hK3eF53iOkiSLwAGlFMx5lotrqD2pTjB18KbybKoEIgkNZTKC60YECDQTKGTRcDBILwZVqVKvA==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + react: 18.2.0 + dev: false + + /@radix-ui/react-context/1.0.0_react@18.2.0: + resolution: {integrity: sha512-1pVM9RfOQ+n/N5PJK33kRSKsr1glNxomxONs5c49MliinBY6Yw2Q995qfBUUo0/Mbg05B/sGA0gkgPI7kmSHBg==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + react: 18.2.0 + dev: false + + /@radix-ui/react-dialog/1.0.2_zula6vjvt3wdocc4mwcxqa6nzi: + resolution: {integrity: sha512-EKxxp2WNSmUPkx4trtWNmZ4/vAYEg7JkAfa1HKBUnaubw9eHzf1Orr9B472lJYaYz327RHDrd4R95fsw7VR8DA==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + react-dom: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + '@radix-ui/primitive': 1.0.0 + '@radix-ui/react-compose-refs': 1.0.0_react@18.2.0 + '@radix-ui/react-context': 1.0.0_react@18.2.0 + '@radix-ui/react-dismissable-layer': 1.0.2_biqbaboplfbrettd7655fr4n2y + '@radix-ui/react-focus-guards': 1.0.0_react@18.2.0 + '@radix-ui/react-focus-scope': 1.0.1_biqbaboplfbrettd7655fr4n2y + '@radix-ui/react-id': 1.0.0_react@18.2.0 + '@radix-ui/react-portal': 1.0.1_biqbaboplfbrettd7655fr4n2y + '@radix-ui/react-presence': 1.0.0_biqbaboplfbrettd7655fr4n2y + '@radix-ui/react-primitive': 1.0.1_biqbaboplfbrettd7655fr4n2y + '@radix-ui/react-slot': 1.0.1_react@18.2.0 + '@radix-ui/react-use-controllable-state': 1.0.0_react@18.2.0 + aria-hidden: 1.2.2_pmekkgnqduwlme35zpnqhenc34 + react: 18.2.0 + react-dom: 18.2.0_react@18.2.0 + react-remove-scroll: 2.5.5_pmekkgnqduwlme35zpnqhenc34 + transitivePeerDependencies: + - '@types/react' + dev: false + + /@radix-ui/react-dismissable-layer/1.0.2_biqbaboplfbrettd7655fr4n2y: + resolution: {integrity: sha512-WjJzMrTWROozDqLB0uRWYvj4UuXsM/2L19EmQ3Au+IJWqwvwq9Bwd+P8ivo0Deg9JDPArR1I6MbWNi1CmXsskg==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + react-dom: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + '@radix-ui/primitive': 1.0.0 + '@radix-ui/react-compose-refs': 1.0.0_react@18.2.0 + '@radix-ui/react-primitive': 1.0.1_biqbaboplfbrettd7655fr4n2y + '@radix-ui/react-use-callback-ref': 1.0.0_react@18.2.0 + '@radix-ui/react-use-escape-keydown': 1.0.2_react@18.2.0 + react: 18.2.0 + react-dom: 18.2.0_react@18.2.0 + dev: false + + /@radix-ui/react-focus-guards/1.0.0_react@18.2.0: + resolution: {integrity: sha512-UagjDk4ijOAnGu4WMUPj9ahi7/zJJqNZ9ZAiGPp7waUWJO0O1aWXi/udPphI0IUjvrhBsZJGSN66dR2dsueLWQ==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + react: 18.2.0 + dev: false + + /@radix-ui/react-focus-scope/1.0.1_biqbaboplfbrettd7655fr4n2y: + resolution: {integrity: sha512-Ej2MQTit8IWJiS2uuujGUmxXjF/y5xZptIIQnyd2JHLwtV0R2j9NRVoRj/1j/gJ7e3REdaBw4Hjf4a1ImhkZcQ==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + react-dom: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + '@radix-ui/react-compose-refs': 1.0.0_react@18.2.0 + '@radix-ui/react-primitive': 1.0.1_biqbaboplfbrettd7655fr4n2y + '@radix-ui/react-use-callback-ref': 1.0.0_react@18.2.0 + react: 18.2.0 + react-dom: 18.2.0_react@18.2.0 + dev: false + + /@radix-ui/react-id/1.0.0_react@18.2.0: + resolution: {integrity: sha512-Q6iAB/U7Tq3NTolBBQbHTgclPmGWE3OlktGGqrClPozSw4vkQ1DfQAOtzgRPecKsMdJINE05iaoDUG8tRzCBjw==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + '@radix-ui/react-use-layout-effect': 1.0.0_react@18.2.0 + react: 18.2.0 + dev: false + + /@radix-ui/react-portal/1.0.1_biqbaboplfbrettd7655fr4n2y: + resolution: {integrity: sha512-NY2vUWI5WENgAT1nfC6JS7RU5xRYBfjZVLq0HmgEN1Ezy3rk/UruMV4+Rd0F40PEaFC5SrLS1ixYvcYIQrb4Ig==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + react-dom: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + '@radix-ui/react-primitive': 1.0.1_biqbaboplfbrettd7655fr4n2y + react: 18.2.0 + react-dom: 18.2.0_react@18.2.0 + dev: false + + /@radix-ui/react-presence/1.0.0_biqbaboplfbrettd7655fr4n2y: + resolution: {integrity: sha512-A+6XEvN01NfVWiKu38ybawfHsBjWum42MRPnEuqPsBZ4eV7e/7K321B5VgYMPv3Xx5An6o1/l9ZuDBgmcmWK3w==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + react-dom: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + '@radix-ui/react-compose-refs': 1.0.0_react@18.2.0 + '@radix-ui/react-use-layout-effect': 1.0.0_react@18.2.0 + react: 18.2.0 + react-dom: 18.2.0_react@18.2.0 + dev: false + + /@radix-ui/react-primitive/1.0.1_biqbaboplfbrettd7655fr4n2y: + resolution: {integrity: sha512-fHbmislWVkZaIdeF6GZxF0A/NH/3BjrGIYj+Ae6eTmTCr7EB0RQAAVEiqsXK6p3/JcRqVSBQoceZroj30Jj3XA==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + react-dom: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + '@radix-ui/react-slot': 1.0.1_react@18.2.0 + react: 18.2.0 + react-dom: 18.2.0_react@18.2.0 + dev: false + + /@radix-ui/react-slot/1.0.1_react@18.2.0: + resolution: {integrity: sha512-avutXAFL1ehGvAXtPquu0YK5oz6ctS474iM3vNGQIkswrVhdrS52e3uoMQBzZhNRAIE0jBnUyXWNmSjGHhCFcw==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + '@radix-ui/react-compose-refs': 1.0.0_react@18.2.0 + react: 18.2.0 + dev: false + + /@radix-ui/react-use-callback-ref/1.0.0_react@18.2.0: + resolution: {integrity: sha512-GZtyzoHz95Rhs6S63D2t/eqvdFCm7I+yHMLVQheKM7nBD8mbZIt+ct1jz4536MDnaOGKIxynJ8eHTkVGVVkoTg==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + react: 18.2.0 + dev: false + + /@radix-ui/react-use-controllable-state/1.0.0_react@18.2.0: + resolution: {integrity: sha512-FohDoZvk3mEXh9AWAVyRTYR4Sq7/gavuofglmiXB2g1aKyboUD4YtgWxKj8O5n+Uak52gXQ4wKz5IFST4vtJHg==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + '@radix-ui/react-use-callback-ref': 1.0.0_react@18.2.0 + react: 18.2.0 + dev: false + + /@radix-ui/react-use-escape-keydown/1.0.2_react@18.2.0: + resolution: {integrity: sha512-DXGim3x74WgUv+iMNCF+cAo8xUHHeqvjx8zs7trKf+FkQKPQXLk2sX7Gx1ysH7Q76xCpZuxIJE7HLPxRE+Q+GA==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + '@radix-ui/react-use-callback-ref': 1.0.0_react@18.2.0 + react: 18.2.0 + dev: false + + /@radix-ui/react-use-layout-effect/1.0.0_react@18.2.0: + resolution: {integrity: sha512-6Tpkq+R6LOlmQb1R5NNETLG0B4YP0wc+klfXafpUCj6JGyaUc8il7/kUZ7m59rGbXGczE9Bs+iz2qloqsZBduQ==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.0 + react: 18.2.0 + dev: false + /@rushstack/eslint-patch/1.2.0: resolution: {integrity: sha512-sXo/qW2/pAcmT43VoRKOJbDOfV3cYpq3szSVfIThQXNt+E4DfKj361vaAt3c88U5tPUxzEswam7GW48PJqtKAg==} dev: true @@ -1208,6 +1381,21 @@ packages: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} dev: true + /aria-hidden/1.2.2_pmekkgnqduwlme35zpnqhenc34: + resolution: {integrity: sha512-6y/ogyDTk/7YAe91T3E2PR1ALVKyM2QbTio5HwM+N1Q6CMlCKhvClyIjkckBswa0f2xJhjsfzIGa1yVSe1UMVA==} + engines: {node: '>=10'} + peerDependencies: + '@types/react': ^16.9.0 || ^17.0.0 || ^18.0.0 + react: ^16.9.0 || ^17.0.0 || ^18.0.0 + peerDependenciesMeta: + '@types/react': + optional: true + dependencies: + '@types/react': 18.0.28 + react: 18.2.0 + tslib: 2.5.0 + dev: false + /aria-query/5.1.3: resolution: {integrity: sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==} dependencies: @@ -1598,6 +1786,10 @@ packages: engines: {node: '>=6'} dev: false + /detect-node-es/1.1.0: + resolution: {integrity: sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==} + dev: false + /detective/5.2.1: resolution: {integrity: sha512-v9XE1zRnz1wRtgurGu0Bs8uHKFSTdteYZNbIPFVhUZ39L/S79ppMpdmVOZAnoz1jfEFodc48n6MX483Xo3t1yw==} engines: {node: '>=0.8.0'} @@ -2214,6 +2406,11 @@ packages: has-symbols: 1.0.3 dev: true + /get-nonce/1.0.1: + resolution: {integrity: sha512-FJhYRoDaiatfEkUK8HKlicmu/3SGFD51q3itKDGoSTysQJBnfOcxU5GxnhE1E6soB76MbT0MBtnKJuXyAx+96Q==} + engines: {node: '>=6'} + dev: false + /get-symbol-description/1.0.0: resolution: {integrity: sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==} engines: {node: '>= 0.4'} @@ -2540,6 +2737,12 @@ packages: side-channel: 1.0.4 dev: true + /invariant/2.2.4: + resolution: {integrity: sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==} + dependencies: + loose-envify: 1.4.0 + dev: false + /is-alphabetical/2.0.1: resolution: {integrity: sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==} dev: false @@ -3957,6 +4160,58 @@ packages: react-fast-compare: 3.2.0 dev: false + /react-remove-scroll-bar/2.3.4_pmekkgnqduwlme35zpnqhenc34: + resolution: {integrity: sha512-63C4YQBUt0m6ALadE9XV56hV8BgJWDmmTPY758iIJjfQKt2nYwoUrPk0LXRXcB/yIj82T1/Ixfdpdk68LwIB0A==} + engines: {node: '>=10'} + peerDependencies: + '@types/react': ^16.8.0 || ^17.0.0 || ^18.0.0 + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + peerDependenciesMeta: + '@types/react': + optional: true + dependencies: + '@types/react': 18.0.28 + react: 18.2.0 + react-style-singleton: 2.2.1_pmekkgnqduwlme35zpnqhenc34 + tslib: 2.5.0 + dev: false + + /react-remove-scroll/2.5.5_pmekkgnqduwlme35zpnqhenc34: + resolution: {integrity: sha512-ImKhrzJJsyXJfBZ4bzu8Bwpka14c/fQt0k+cyFp/PBhTfyDnU5hjOtM4AG/0AMyy8oKzOTR0lDgJIM7pYXI0kw==} + engines: {node: '>=10'} + peerDependencies: + '@types/react': ^16.8.0 || ^17.0.0 || ^18.0.0 + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + peerDependenciesMeta: + '@types/react': + optional: true + dependencies: + '@types/react': 18.0.28 + react: 18.2.0 + react-remove-scroll-bar: 2.3.4_pmekkgnqduwlme35zpnqhenc34 + react-style-singleton: 2.2.1_pmekkgnqduwlme35zpnqhenc34 + tslib: 2.5.0 + use-callback-ref: 1.3.0_pmekkgnqduwlme35zpnqhenc34 + use-sidecar: 1.1.2_pmekkgnqduwlme35zpnqhenc34 + dev: false + + /react-style-singleton/2.2.1_pmekkgnqduwlme35zpnqhenc34: + resolution: {integrity: sha512-ZWj0fHEMyWkHzKYUr2Bs/4zU6XLmq9HsgBURm7g5pAVfyn49DgUiNgY2d4lXRlYSiCif9YBGpQleewkcqddc7g==} + engines: {node: '>=10'} + peerDependencies: + '@types/react': ^16.8.0 || ^17.0.0 || ^18.0.0 + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + peerDependenciesMeta: + '@types/react': + optional: true + dependencies: + '@types/react': 18.0.28 + get-nonce: 1.0.1 + invariant: 2.2.4 + react: 18.2.0 + tslib: 2.5.0 + dev: false + /react-virtuoso/4.1.0_biqbaboplfbrettd7655fr4n2y: resolution: {integrity: sha512-Vcq5WXn18PvPT55kdeGQ8BN3K95XyPe7hum8zG6Tx7g1CtUYVsQKN7fouMxBSy+XymEDB5ynGy8JWhuqyLLtPw==} engines: {node: '>=10'} @@ -4589,6 +4844,37 @@ packages: dependencies: punycode: 2.3.0 + /use-callback-ref/1.3.0_pmekkgnqduwlme35zpnqhenc34: + resolution: {integrity: sha512-3FT9PRuRdbB9HfXhEq35u4oZkvpJ5kuYbpqhCfmiZyReuRgpnhDlbr2ZEnnuS0RrJAPn6l23xjFg9kpDM+Ms7w==} + engines: {node: '>=10'} + peerDependencies: + '@types/react': ^16.8.0 || ^17.0.0 || ^18.0.0 + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + peerDependenciesMeta: + '@types/react': + optional: true + dependencies: + '@types/react': 18.0.28 + react: 18.2.0 + tslib: 2.5.0 + dev: false + + /use-sidecar/1.1.2_pmekkgnqduwlme35zpnqhenc34: + resolution: {integrity: sha512-epTbsLuzZ7lPClpz2TyryBfztm7m+28DlEv2ZCQ3MDr5ssiwyOwGH/e5F9CkfWjJ1t4clvI58yF822/GUkjjhw==} + engines: {node: '>=10'} + peerDependencies: + '@types/react': ^16.9.0 || ^17.0.0 || ^18.0.0 + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + peerDependenciesMeta: + '@types/react': + optional: true + dependencies: + '@types/react': 18.0.28 + detect-node-es: 1.1.0 + react: 18.2.0 + tslib: 2.5.0 + dev: false + /use-sync-external-store/1.2.0_react@18.2.0: resolution: {integrity: sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==} peerDependencies: diff --git a/src/components/accountBar/index.tsx b/src/components/accountBar/index.tsx index 56337034..618c4bf3 100644 --- a/src/components/accountBar/index.tsx +++ b/src/components/accountBar/index.tsx @@ -5,65 +5,15 @@ import { currentUser } from '@stores/currentUser'; import LumeIcon from '@assets/icons/Lume'; import MiniPlusIcon from '@assets/icons/MiniPlus'; -import PostIcon from '@assets/icons/Post'; -import { Dialog, Transition } from '@headlessui/react'; import { useStore } from '@nanostores/react'; -import * as commands from '@uiw/react-md-editor/lib/commands'; -import dynamic from 'next/dynamic'; import Link from 'next/link'; -import { dateToUnix, useNostr } from 'nostr-react'; -import { getEventHash, signEvent } from 'nostr-tools'; -import { Fragment, useCallback, useEffect, useState } from 'react'; +import { useCallback, useEffect, useState } from 'react'; import Database from 'tauri-plugin-sql-api'; -const MDEditor = dynamic(() => import('@uiw/react-md-editor').then((mod) => mod.default), { - ssr: false, -}); - export default function AccountBar() { - const { publish } = useNostr(); - - const [isOpen, setIsOpen] = useState(false); - const [value, setValue] = useState(''); const [users, setUsers] = useState([]); - const $currentUser: any = useStore(currentUser); - const pubkey = $currentUser.pubkey; - const privkey = $currentUser.privkey; - - const postButton = { - name: 'post', - keyCommand: 'post', - buttonProps: { className: 'cta-btn', 'aria-label': 'Post a message' }, - icon: ( -
- - Post - - -
- ), - execute: (state: { text: any }) => { - const message = state.text; - - if (message.length > 0) { - const event: any = { - content: message, - created_at: dateToUnix(), - kind: 1, - pubkey: pubkey, - tags: [], - }; - - event.id = getEventHash(event); - event.sig = signEvent(event, privkey); - - publish(event); - setValue(''); - } - }, - }; const getAccounts = useCallback(async () => { const db = await Database.load('sqlite:lume.db'); @@ -89,78 +39,8 @@ export default function AccountBar() {
- {/* post button */} - - {/* end post button */}
- {/* modal */} - - setIsOpen(false)}> - -
- - -
-
- - -
-
-
- setValue(val)} - /> -
-
-
-
-
-
-
- {/* end modal */} ); } diff --git a/src/components/navigatorBar/createPost.tsx b/src/components/navigatorBar/createPost.tsx new file mode 100644 index 00000000..5ae175aa --- /dev/null +++ b/src/components/navigatorBar/createPost.tsx @@ -0,0 +1,115 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { currentUser } from '@stores/currentUser'; + +import { useStore } from '@nanostores/react'; +import * as Dialog from '@radix-ui/react-dialog'; +import * as commands from '@uiw/react-md-editor/lib/commands'; +import dynamic from 'next/dynamic'; +import { dateToUnix, useNostr } from 'nostr-react'; +import { getEventHash, signEvent } from 'nostr-tools'; +import { useState } from 'react'; + +const MDEditor = dynamic(() => import('@uiw/react-md-editor').then((mod) => mod.default), { + ssr: false, +}); + +export default function CreatePost() { + const { publish } = useNostr(); + const [value, setValue] = useState(''); + + const $currentUser: any = useStore(currentUser); + const pubkey = $currentUser.pubkey; + const privkey = $currentUser.privkey; + + const postButton = { + name: 'post', + keyCommand: 'post', + buttonProps: { className: 'cta-btn', 'aria-label': 'Post a message' }, + icon: ( +
+ + Post + + +
+ ), + execute: (state: { text: any }) => { + const message = state.text; + + if (message.length > 0) { + const event: any = { + content: message, + created_at: dateToUnix(), + kind: 1, + pubkey: pubkey, + tags: [], + }; + + event.id = getEventHash(event); + event.sig = signEvent(event, privkey); + + publish(event); + setValue(''); + } + }, + }; + + return ( + + +
+
+