create-weave-frontend-app 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/chunk-HZJMO45D.js +437 -0
- package/dist/create-app.d.ts +14 -0
- package/dist/create-app.js +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +106 -0
- package/package.json +65 -0
- package/template/+nextjs+azure-web-pubsub/README.md +36 -0
- package/template/+nextjs+azure-web-pubsub/api/del-image.ts +8 -0
- package/template/+nextjs+azure-web-pubsub/api/get-images.ts +15 -0
- package/template/+nextjs+azure-web-pubsub/api/post-image.ts +14 -0
- package/template/+nextjs+azure-web-pubsub/api/post-remove-background.ts +10 -0
- package/template/+nextjs+azure-web-pubsub/app/error/page.tsx +10 -0
- package/template/+nextjs+azure-web-pubsub/app/favicon.ico +0 -0
- package/template/+nextjs+azure-web-pubsub/app/globals.css +193 -0
- package/template/+nextjs+azure-web-pubsub/app/layout.tsx +46 -0
- package/template/+nextjs+azure-web-pubsub/app/page.tsx +7 -0
- package/template/+nextjs+azure-web-pubsub/app/providers.tsx +18 -0
- package/template/+nextjs+azure-web-pubsub/app/room/[roomId]/page.tsx +5 -0
- package/template/+nextjs+azure-web-pubsub/assets/images/home.png +0 -0
- package/template/+nextjs+azure-web-pubsub/assets/images/logo.png +0 -0
- package/template/+nextjs+azure-web-pubsub/components/actions/align-elements-tool/align-elements-tool.ts +94 -0
- package/template/+nextjs+azure-web-pubsub/components/actions/color-token-tool/color-token-tool.ts +164 -0
- package/template/+nextjs+azure-web-pubsub/components/actions/color-token-tool/constants.ts +5 -0
- package/template/+nextjs+azure-web-pubsub/components/actions/color-token-tool/types.ts +12 -0
- package/template/+nextjs+azure-web-pubsub/components/error/error.tsx +62 -0
- package/template/+nextjs+azure-web-pubsub/components/error/errors.ts +35 -0
- package/template/+nextjs+azure-web-pubsub/components/home/home.tsx +92 -0
- package/template/+nextjs+azure-web-pubsub/components/home-components/home-showcase-animation.tsx +119 -0
- package/template/+nextjs+azure-web-pubsub/components/home-components/login-form.tsx +117 -0
- package/template/+nextjs+azure-web-pubsub/components/nodes/color-token/color-token.ts +171 -0
- package/template/+nextjs+azure-web-pubsub/components/room/room.layout.tsx +115 -0
- package/template/+nextjs+azure-web-pubsub/components/room/room.tsx +125 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/color-tokens-library/color-token.tsx +31 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/color-tokens-library/color-tokens-library.tsx +64 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/connected-users.tsx +152 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/connection-status.tsx +52 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/context-menu.tsx +152 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/frames-library/frames-library.image.tsx +48 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/frames-library/frames-library.presentation-image.tsx +61 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/frames-library/frames-library.tsx +316 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/frames-library/utils.ts +27 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/help/help-arrange.tsx +69 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/help/help-drawer.tsx +140 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/help/help-edit.tsx +80 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/help/help-selection.tsx +30 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/help/help-shortcut-element.tsx +24 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/help/help-tools.tsx +89 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/help/help-view.tsx +30 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/help/help-zoom.tsx +46 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/help/shortcut-element.tsx +42 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/hooks/use-context-menu.tsx +514 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/hooks/use-get-azure-web-pubsub-provider.ts +78 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/hooks/use-get-os.ts +12 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/hooks/use-get-weave-js-props.tsx +120 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/hooks/use-handle-route-params.ts +30 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/hooks/use-key-down.ts +29 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/hooks/use-keyboard-handler.tsx +557 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/images-library/images-library.tsx +146 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/inputs/input-color.tsx +101 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/inputs/input-font-family.tsx +99 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/inputs/input-number.tsx +61 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/inputs/input-text.tsx +51 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/inputs/number-input.tsx +107 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/node-properties/appearance-properties.tsx +119 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/node-properties/color-token-properties.tsx +108 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/node-properties/crop-properties.tsx +156 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/node-properties/fill-properties.tsx +115 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/node-properties/frame-properties.tsx +100 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/node-properties/image-properties.tsx +57 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/node-properties/position-properties.tsx +156 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/node-properties/size-properties.tsx +131 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/node-properties/stroke-properties.tsx +327 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/node-properties/text-properties.tsx +467 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/overlay/multiuse-overlay.tsx +127 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/overlay/node-properties.tsx +98 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/overlay/overlay-animation-wrapper.tsx +31 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/overlay/room-information-overlay.tsx +247 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/overlay/room-users-overlay.tsx +31 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/overlay/tools-overlay.tsx +289 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/overlay/variants.ts +58 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/overlay/zoom-handler-overlay.tsx +447 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/room-error.tsx +37 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/room-loader/room-loader.tsx +98 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/selection-information.tsx +74 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/toggle-icon-button.tsx +60 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/toolbar/toolbar-button.tsx +60 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/toolbar/toolbar-toggle-button.tsx +40 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/toolbar/toolbar.tsx +28 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/upload-file.tsx +130 -0
- package/template/+nextjs+azure-web-pubsub/components/room-components/with-instance-node.tsx +53 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/accordion.tsx +66 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/avatar.tsx +53 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/button.tsx +58 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/card.tsx +68 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/checkbox.tsx +32 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/color-picker/color-picker-component.tsx +69 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/color-picker/context/color-picker-context.tsx +28 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/color-picker/editor/color-picker-format-editor.tsx +34 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/color-picker/index.ts +7 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/color-picker/selector/color-picker-alpha.tsx +79 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/color-picker/selector/color-picker-eyedropper.tsx +95 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/color-picker/selector/color-picker-format-selector.tsx +50 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/color-picker/selector/color-picker-hue.tsx +67 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/color-picker/selector/color-picker-saturation.tsx +145 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/color-picker/text-inputs/color-picker-alpha-percentage.tsx +60 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/color-picker/text-inputs/color-picker-hexa.tsx +65 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/color-picker/text-inputs/color-picker-rgba.tsx +62 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/command.tsx +177 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/dialog.tsx +135 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/drawer.tsx +132 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/dropdown-menu.tsx +201 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/form.tsx +167 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/input.tsx +21 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/label.tsx +24 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/popover.tsx +48 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/reactbits/Backgrounds/Dither/Dither.tsx +350 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/reactbits/Backgrounds/Threads/Threads.tsx +239 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/reactbits/TextAnimations/RotatingText/RotatingText.tsx +276 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/scroll-area.tsx +58 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/select.tsx +185 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/sheet.tsx +139 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/sonner.tsx +25 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/tabs.tsx +66 -0
- package/template/+nextjs+azure-web-pubsub/components/ui/tooltip.tsx +61 -0
- package/template/+nextjs+azure-web-pubsub/components/utils/constants.ts +118 -0
- package/template/+nextjs+azure-web-pubsub/components/utils/logo.tsx +34 -0
- package/template/+nextjs+azure-web-pubsub/components.json +21 -0
- package/template/+nextjs+azure-web-pubsub/example.env +2 -0
- package/template/+nextjs+azure-web-pubsub/example.gitignore +44 -0
- package/template/+nextjs+azure-web-pubsub/jsrepo.json +11 -0
- package/template/+nextjs+azure-web-pubsub/lib/utils.ts +43 -0
- package/template/+nextjs+azure-web-pubsub/new-types.d.ts +8 -0
- package/template/+nextjs+azure-web-pubsub/next-env.d.ts +5 -0
- package/template/+nextjs+azure-web-pubsub/next.config.js +52 -0
- package/template/+nextjs+azure-web-pubsub/postcss.config.mjs +5 -0
- package/template/+nextjs+azure-web-pubsub/store/store.ts +241 -0
- package/template/+nextjs+azure-web-pubsub/tsconfig.json +37 -0
- package/template/+nextjs+azure-web-pubsub/vitest.config.mts +10 -0
- package/template/+nextjs+websockets/README.md +39 -0
- package/template/+nextjs+websockets/api/del-image.ts +8 -0
- package/template/+nextjs+websockets/api/get-images.ts +15 -0
- package/template/+nextjs+websockets/api/post-image.ts +14 -0
- package/template/+nextjs+websockets/api/post-remove-background.ts +10 -0
- package/template/+nextjs+websockets/app/error/page.tsx +10 -0
- package/template/+nextjs+websockets/app/favicon.ico +0 -0
- package/template/+nextjs+websockets/app/globals.css +193 -0
- package/template/+nextjs+websockets/app/layout.tsx +46 -0
- package/template/+nextjs+websockets/app/page.tsx +7 -0
- package/template/+nextjs+websockets/app/providers.tsx +18 -0
- package/template/+nextjs+websockets/app/room/[roomId]/page.tsx +5 -0
- package/template/+nextjs+websockets/assets/images/home.png +0 -0
- package/template/+nextjs+websockets/assets/images/logo.png +0 -0
- package/template/+nextjs+websockets/components/actions/align-elements-tool/align-elements-tool.ts +94 -0
- package/template/+nextjs+websockets/components/actions/color-token-tool/color-token-tool.ts +164 -0
- package/template/+nextjs+websockets/components/actions/color-token-tool/constants.ts +5 -0
- package/template/+nextjs+websockets/components/actions/color-token-tool/types.ts +12 -0
- package/template/+nextjs+websockets/components/error/error.tsx +62 -0
- package/template/+nextjs+websockets/components/error/errors.ts +35 -0
- package/template/+nextjs+websockets/components/home/home.tsx +92 -0
- package/template/+nextjs+websockets/components/home-components/home-showcase-animation.tsx +119 -0
- package/template/+nextjs+websockets/components/home-components/login-form.tsx +117 -0
- package/template/+nextjs+websockets/components/nodes/color-token/color-token.ts +171 -0
- package/template/+nextjs+websockets/components/room/room.layout.tsx +115 -0
- package/template/+nextjs+websockets/components/room/room.tsx +125 -0
- package/template/+nextjs+websockets/components/room-components/color-tokens-library/color-token.tsx +31 -0
- package/template/+nextjs+websockets/components/room-components/color-tokens-library/color-tokens-library.tsx +64 -0
- package/template/+nextjs+websockets/components/room-components/connected-users.tsx +152 -0
- package/template/+nextjs+websockets/components/room-components/connection-status.tsx +52 -0
- package/template/+nextjs+websockets/components/room-components/context-menu.tsx +152 -0
- package/template/+nextjs+websockets/components/room-components/frames-library/frames-library.image.tsx +48 -0
- package/template/+nextjs+websockets/components/room-components/frames-library/frames-library.presentation-image.tsx +61 -0
- package/template/+nextjs+websockets/components/room-components/frames-library/frames-library.tsx +316 -0
- package/template/+nextjs+websockets/components/room-components/frames-library/utils.ts +27 -0
- package/template/+nextjs+websockets/components/room-components/help/help-arrange.tsx +69 -0
- package/template/+nextjs+websockets/components/room-components/help/help-drawer.tsx +140 -0
- package/template/+nextjs+websockets/components/room-components/help/help-edit.tsx +80 -0
- package/template/+nextjs+websockets/components/room-components/help/help-selection.tsx +30 -0
- package/template/+nextjs+websockets/components/room-components/help/help-shortcut-element.tsx +24 -0
- package/template/+nextjs+websockets/components/room-components/help/help-tools.tsx +89 -0
- package/template/+nextjs+websockets/components/room-components/help/help-view.tsx +30 -0
- package/template/+nextjs+websockets/components/room-components/help/help-zoom.tsx +46 -0
- package/template/+nextjs+websockets/components/room-components/help/shortcut-element.tsx +42 -0
- package/template/+nextjs+websockets/components/room-components/hooks/use-context-menu.tsx +514 -0
- package/template/+nextjs+websockets/components/room-components/hooks/use-get-os.ts +12 -0
- package/template/+nextjs+websockets/components/room-components/hooks/use-get-weave-js-props.tsx +120 -0
- package/template/+nextjs+websockets/components/room-components/hooks/use-get-websockets-provider.ts +79 -0
- package/template/+nextjs+websockets/components/room-components/hooks/use-handle-route-params.ts +30 -0
- package/template/+nextjs+websockets/components/room-components/hooks/use-key-down.ts +29 -0
- package/template/+nextjs+websockets/components/room-components/hooks/use-keyboard-handler.tsx +557 -0
- package/template/+nextjs+websockets/components/room-components/images-library/images-library.tsx +146 -0
- package/template/+nextjs+websockets/components/room-components/inputs/input-color.tsx +101 -0
- package/template/+nextjs+websockets/components/room-components/inputs/input-font-family.tsx +99 -0
- package/template/+nextjs+websockets/components/room-components/inputs/input-number.tsx +61 -0
- package/template/+nextjs+websockets/components/room-components/inputs/input-text.tsx +51 -0
- package/template/+nextjs+websockets/components/room-components/inputs/number-input.tsx +107 -0
- package/template/+nextjs+websockets/components/room-components/node-properties/appearance-properties.tsx +119 -0
- package/template/+nextjs+websockets/components/room-components/node-properties/color-token-properties.tsx +108 -0
- package/template/+nextjs+websockets/components/room-components/node-properties/crop-properties.tsx +156 -0
- package/template/+nextjs+websockets/components/room-components/node-properties/fill-properties.tsx +115 -0
- package/template/+nextjs+websockets/components/room-components/node-properties/frame-properties.tsx +100 -0
- package/template/+nextjs+websockets/components/room-components/node-properties/image-properties.tsx +57 -0
- package/template/+nextjs+websockets/components/room-components/node-properties/position-properties.tsx +156 -0
- package/template/+nextjs+websockets/components/room-components/node-properties/size-properties.tsx +131 -0
- package/template/+nextjs+websockets/components/room-components/node-properties/stroke-properties.tsx +327 -0
- package/template/+nextjs+websockets/components/room-components/node-properties/text-properties.tsx +467 -0
- package/template/+nextjs+websockets/components/room-components/overlay/multiuse-overlay.tsx +127 -0
- package/template/+nextjs+websockets/components/room-components/overlay/node-properties.tsx +98 -0
- package/template/+nextjs+websockets/components/room-components/overlay/overlay-animation-wrapper.tsx +31 -0
- package/template/+nextjs+websockets/components/room-components/overlay/room-information-overlay.tsx +247 -0
- package/template/+nextjs+websockets/components/room-components/overlay/room-users-overlay.tsx +31 -0
- package/template/+nextjs+websockets/components/room-components/overlay/tools-overlay.tsx +289 -0
- package/template/+nextjs+websockets/components/room-components/overlay/variants.ts +58 -0
- package/template/+nextjs+websockets/components/room-components/overlay/zoom-handler-overlay.tsx +447 -0
- package/template/+nextjs+websockets/components/room-components/room-error.tsx +37 -0
- package/template/+nextjs+websockets/components/room-components/room-loader/room-loader.tsx +98 -0
- package/template/+nextjs+websockets/components/room-components/selection-information.tsx +74 -0
- package/template/+nextjs+websockets/components/room-components/toggle-icon-button.tsx +60 -0
- package/template/+nextjs+websockets/components/room-components/toolbar/toolbar-button.tsx +60 -0
- package/template/+nextjs+websockets/components/room-components/toolbar/toolbar-toggle-button.tsx +40 -0
- package/template/+nextjs+websockets/components/room-components/toolbar/toolbar.tsx +28 -0
- package/template/+nextjs+websockets/components/room-components/upload-file.tsx +130 -0
- package/template/+nextjs+websockets/components/room-components/with-instance-node.tsx +53 -0
- package/template/+nextjs+websockets/components/ui/accordion.tsx +66 -0
- package/template/+nextjs+websockets/components/ui/avatar.tsx +53 -0
- package/template/+nextjs+websockets/components/ui/button.tsx +58 -0
- package/template/+nextjs+websockets/components/ui/card.tsx +68 -0
- package/template/+nextjs+websockets/components/ui/checkbox.tsx +32 -0
- package/template/+nextjs+websockets/components/ui/color-picker/color-picker-component.tsx +69 -0
- package/template/+nextjs+websockets/components/ui/color-picker/context/color-picker-context.tsx +28 -0
- package/template/+nextjs+websockets/components/ui/color-picker/editor/color-picker-format-editor.tsx +34 -0
- package/template/+nextjs+websockets/components/ui/color-picker/index.ts +7 -0
- package/template/+nextjs+websockets/components/ui/color-picker/selector/color-picker-alpha.tsx +79 -0
- package/template/+nextjs+websockets/components/ui/color-picker/selector/color-picker-eyedropper.tsx +95 -0
- package/template/+nextjs+websockets/components/ui/color-picker/selector/color-picker-format-selector.tsx +50 -0
- package/template/+nextjs+websockets/components/ui/color-picker/selector/color-picker-hue.tsx +67 -0
- package/template/+nextjs+websockets/components/ui/color-picker/selector/color-picker-saturation.tsx +145 -0
- package/template/+nextjs+websockets/components/ui/color-picker/text-inputs/color-picker-alpha-percentage.tsx +60 -0
- package/template/+nextjs+websockets/components/ui/color-picker/text-inputs/color-picker-hexa.tsx +65 -0
- package/template/+nextjs+websockets/components/ui/color-picker/text-inputs/color-picker-rgba.tsx +62 -0
- package/template/+nextjs+websockets/components/ui/command.tsx +177 -0
- package/template/+nextjs+websockets/components/ui/dialog.tsx +135 -0
- package/template/+nextjs+websockets/components/ui/drawer.tsx +132 -0
- package/template/+nextjs+websockets/components/ui/dropdown-menu.tsx +201 -0
- package/template/+nextjs+websockets/components/ui/form.tsx +167 -0
- package/template/+nextjs+websockets/components/ui/input.tsx +21 -0
- package/template/+nextjs+websockets/components/ui/label.tsx +24 -0
- package/template/+nextjs+websockets/components/ui/popover.tsx +48 -0
- package/template/+nextjs+websockets/components/ui/reactbits/Backgrounds/Dither/Dither.tsx +350 -0
- package/template/+nextjs+websockets/components/ui/reactbits/Backgrounds/Threads/Threads.tsx +239 -0
- package/template/+nextjs+websockets/components/ui/reactbits/TextAnimations/RotatingText/RotatingText.tsx +276 -0
- package/template/+nextjs+websockets/components/ui/scroll-area.tsx +58 -0
- package/template/+nextjs+websockets/components/ui/select.tsx +185 -0
- package/template/+nextjs+websockets/components/ui/sheet.tsx +139 -0
- package/template/+nextjs+websockets/components/ui/sonner.tsx +25 -0
- package/template/+nextjs+websockets/components/ui/tabs.tsx +66 -0
- package/template/+nextjs+websockets/components/ui/tooltip.tsx +61 -0
- package/template/+nextjs+websockets/components/utils/constants.ts +118 -0
- package/template/+nextjs+websockets/components/utils/logo.tsx +34 -0
- package/template/+nextjs+websockets/components.json +21 -0
- package/template/+nextjs+websockets/example.env +2 -0
- package/template/+nextjs+websockets/example.gitignore +44 -0
- package/template/+nextjs+websockets/jsrepo.json +11 -0
- package/template/+nextjs+websockets/lib/utils.ts +43 -0
- package/template/+nextjs+websockets/new-types.d.ts +8 -0
- package/template/+nextjs+websockets/next-env.d.ts +5 -0
- package/template/+nextjs+websockets/next.config.js +52 -0
- package/template/+nextjs+websockets/postcss.config.mjs +5 -0
- package/template/+nextjs+websockets/store/store.ts +241 -0
- package/template/+nextjs+websockets/tsconfig.json +37 -0
- package/template/+nextjs+websockets/vitest.config.mts +10 -0
- package/template/package.json +81 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { WeaveNode } from '@inditextech/weave-sdk';
|
|
2
|
+
import {
|
|
3
|
+
WeaveElementAttributes,
|
|
4
|
+
WeaveElementInstance,
|
|
5
|
+
} from '@inditextech/weave-types';
|
|
6
|
+
import Konva from 'konva';
|
|
7
|
+
import { Noto_Sans_Mono } from 'next/font/google';
|
|
8
|
+
|
|
9
|
+
export const COLOR_TOKEN_NODE_TYPE = 'color-token';
|
|
10
|
+
|
|
11
|
+
const notoSansMono = Noto_Sans_Mono({
|
|
12
|
+
preload: true,
|
|
13
|
+
variable: '--font-noto-sans-mono',
|
|
14
|
+
subsets: ['latin'],
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export class ColorTokenNode extends WeaveNode {
|
|
18
|
+
protected nodeType = COLOR_TOKEN_NODE_TYPE;
|
|
19
|
+
|
|
20
|
+
createNode(key: string, props: WeaveElementAttributes) {
|
|
21
|
+
return {
|
|
22
|
+
key,
|
|
23
|
+
type: this.nodeType,
|
|
24
|
+
props: {
|
|
25
|
+
...props,
|
|
26
|
+
id: key,
|
|
27
|
+
nodeType: this.nodeType,
|
|
28
|
+
children: [],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
createInstance(props: WeaveElementAttributes) {
|
|
34
|
+
const { id } = props;
|
|
35
|
+
|
|
36
|
+
const colorTokenColor = props.colorToken ?? '#DEFFA0';
|
|
37
|
+
|
|
38
|
+
const colorTokenParams = {
|
|
39
|
+
...props,
|
|
40
|
+
};
|
|
41
|
+
delete colorTokenParams.zIndex;
|
|
42
|
+
|
|
43
|
+
const colorToken = new Konva.Group({
|
|
44
|
+
...colorTokenParams,
|
|
45
|
+
width: colorTokenParams.width,
|
|
46
|
+
height: colorTokenParams.height,
|
|
47
|
+
name: 'node',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const internalRect = new Konva.Rect({
|
|
51
|
+
groupId: id,
|
|
52
|
+
x: 0,
|
|
53
|
+
y: 0,
|
|
54
|
+
fill: '#FFFFFFFF',
|
|
55
|
+
width: colorTokenParams.width,
|
|
56
|
+
height: colorTokenParams.height,
|
|
57
|
+
draggable: false,
|
|
58
|
+
listening: true,
|
|
59
|
+
stroke: 'black',
|
|
60
|
+
strokeWidth: 2,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
colorToken.add(internalRect);
|
|
64
|
+
|
|
65
|
+
const internalRect2 = new Konva.Rect({
|
|
66
|
+
id: `${id}-colorToken-1`,
|
|
67
|
+
groupId: id,
|
|
68
|
+
x: 1,
|
|
69
|
+
y: 1,
|
|
70
|
+
fill: colorTokenColor,
|
|
71
|
+
width: colorTokenParams.width - 2,
|
|
72
|
+
height: (colorTokenParams.height ?? 0) - 60,
|
|
73
|
+
draggable: false,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
colorToken.add(internalRect2);
|
|
77
|
+
|
|
78
|
+
const internalRect3 = new Konva.Rect({
|
|
79
|
+
id: `${id}-colorToken-2`,
|
|
80
|
+
groupId: id,
|
|
81
|
+
x: 1,
|
|
82
|
+
y: 168,
|
|
83
|
+
fill: colorTokenColor,
|
|
84
|
+
width: colorTokenParams.width - 2,
|
|
85
|
+
height: 12,
|
|
86
|
+
draggable: false,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
colorToken.add(internalRect3);
|
|
90
|
+
|
|
91
|
+
const internalText = new Konva.Text({
|
|
92
|
+
id: `${id}-colorToken-code`,
|
|
93
|
+
groupId: id,
|
|
94
|
+
x: 20,
|
|
95
|
+
y: 260,
|
|
96
|
+
fontSize: 20,
|
|
97
|
+
fontFamily: notoSansMono.style.fontFamily,
|
|
98
|
+
fill: '#CCCCCCFF',
|
|
99
|
+
strokeEnabled: false,
|
|
100
|
+
stroke: '#000000FF',
|
|
101
|
+
strokeWidth: 1,
|
|
102
|
+
text: `${colorTokenColor}`,
|
|
103
|
+
width: (colorTokenParams.width ?? 0) - 40,
|
|
104
|
+
height: 20,
|
|
105
|
+
align: 'left',
|
|
106
|
+
draggable: false,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
colorToken.add(internalText);
|
|
110
|
+
|
|
111
|
+
this.setupDefaultNodeEvents(colorToken);
|
|
112
|
+
|
|
113
|
+
return colorToken;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
updateInstance(
|
|
117
|
+
nodeInstance: WeaveElementInstance,
|
|
118
|
+
nextProps: WeaveElementAttributes
|
|
119
|
+
) {
|
|
120
|
+
const { id, colorToken } = nextProps;
|
|
121
|
+
|
|
122
|
+
const colorTokenNode = nodeInstance as Konva.Group;
|
|
123
|
+
|
|
124
|
+
const nodeInstanceZIndex = nodeInstance.zIndex();
|
|
125
|
+
nodeInstance.setAttrs({
|
|
126
|
+
...nextProps,
|
|
127
|
+
zIndex: nodeInstanceZIndex,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const colorTokenColor = colorToken ?? '#DEFFA0';
|
|
131
|
+
|
|
132
|
+
const colorTokenNode1 = colorTokenNode.findOne(`#${id}-colorToken-1`);
|
|
133
|
+
if (colorTokenNode1) {
|
|
134
|
+
colorTokenNode1.setAttrs({
|
|
135
|
+
fill: colorTokenColor,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
const colorTokenNode2 = colorTokenNode.findOne(`#${id}-colorToken-2`);
|
|
139
|
+
if (colorTokenNode2) {
|
|
140
|
+
colorTokenNode2.setAttrs({
|
|
141
|
+
fill: colorTokenColor,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
const colorTokenCode = colorTokenNode.findOne(`#${id}-colorToken-code`);
|
|
145
|
+
if (colorTokenCode) {
|
|
146
|
+
colorTokenCode.setAttr('text', `${colorTokenColor}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
removeInstance(nodeInstance: WeaveElementInstance) {
|
|
151
|
+
nodeInstance.destroy();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
toNode(instance: WeaveElementInstance) {
|
|
155
|
+
const attrs = instance.getAttrs();
|
|
156
|
+
|
|
157
|
+
const cleanedAttrs = { ...attrs };
|
|
158
|
+
delete cleanedAttrs.draggable;
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
key: attrs.id ?? '',
|
|
162
|
+
type: attrs.nodeType,
|
|
163
|
+
props: {
|
|
164
|
+
...cleanedAttrs,
|
|
165
|
+
id: attrs.id ?? '',
|
|
166
|
+
nodeType: attrs.nodeType,
|
|
167
|
+
children: [],
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { ContextMenuRender } from '@/components/room-components/context-menu';
|
|
5
|
+
import { useCollaborationRoom } from '@/store/store';
|
|
6
|
+
import { RoomInformationOverlay } from '@/components/room-components/overlay/room-information-overlay';
|
|
7
|
+
import { RoomUsersOverlay } from '@/components/room-components/overlay/room-users-overlay';
|
|
8
|
+
import { ToolsOverlay } from '@/components/room-components/overlay/tools-overlay';
|
|
9
|
+
import { MultiuseOverlay } from '@/components/room-components/overlay/multiuse-overlay';
|
|
10
|
+
import { useWeave } from '@inditextech/weave-react';
|
|
11
|
+
import { WEAVE_INSTANCE_STATUS } from '@inditextech/weave-types';
|
|
12
|
+
import { ZoomHandlerOverlay } from '../room-components/overlay/zoom-handler-overlay';
|
|
13
|
+
import { Logo } from '../utils/logo';
|
|
14
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
15
|
+
|
|
16
|
+
export const RoomLayout = () => {
|
|
17
|
+
const status = useWeave((state) => state.status);
|
|
18
|
+
const roomLoaded = useWeave((state) => state.room.loaded);
|
|
19
|
+
|
|
20
|
+
const contextMenuShow = useCollaborationRoom(
|
|
21
|
+
(state) => state.contextMenu.show
|
|
22
|
+
);
|
|
23
|
+
const contextMenuPosition = useCollaborationRoom(
|
|
24
|
+
(state) => state.contextMenu.position
|
|
25
|
+
);
|
|
26
|
+
const contextMenuOptions = useCollaborationRoom(
|
|
27
|
+
(state) => state.contextMenu.options
|
|
28
|
+
);
|
|
29
|
+
const setContextMenuShow = useCollaborationRoom(
|
|
30
|
+
(state) => state.setContextMenuShow
|
|
31
|
+
);
|
|
32
|
+
const transformingImage = useCollaborationRoom(
|
|
33
|
+
(state) => state.images.transforming
|
|
34
|
+
);
|
|
35
|
+
const uploadingImage = useCollaborationRoom(
|
|
36
|
+
(state) => state.images.uploading
|
|
37
|
+
);
|
|
38
|
+
const loadingImage = useCollaborationRoom((state) => state.images.loading);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className="w-full h-full relative flex">
|
|
42
|
+
<AnimatePresence>
|
|
43
|
+
<motion.div
|
|
44
|
+
animate={{
|
|
45
|
+
filter: !(status === WEAVE_INSTANCE_STATUS.RUNNING && roomLoaded)
|
|
46
|
+
? 'blur(10px)'
|
|
47
|
+
: 'blur(0px)',
|
|
48
|
+
}}
|
|
49
|
+
transition={{
|
|
50
|
+
duration: 0.5,
|
|
51
|
+
delay: !(status === WEAVE_INSTANCE_STATUS.RUNNING && roomLoaded)
|
|
52
|
+
? 0
|
|
53
|
+
: 0.5,
|
|
54
|
+
}}
|
|
55
|
+
className="w-full h-full"
|
|
56
|
+
>
|
|
57
|
+
<div id="weave" className="w-full h-full"></div>
|
|
58
|
+
{status === WEAVE_INSTANCE_STATUS.RUNNING && roomLoaded && (
|
|
59
|
+
<>
|
|
60
|
+
<ContextMenuRender
|
|
61
|
+
show={contextMenuShow}
|
|
62
|
+
onChanged={(show: boolean) => {
|
|
63
|
+
setContextMenuShow(show);
|
|
64
|
+
}}
|
|
65
|
+
position={contextMenuPosition}
|
|
66
|
+
options={contextMenuOptions}
|
|
67
|
+
/>
|
|
68
|
+
<RoomInformationOverlay />
|
|
69
|
+
<div className="absolute top-[64px] left-[8px] right-[8px] flex justify-start items-center pointer-events-none">
|
|
70
|
+
<div className="max-w-[320px] text-left bg-transparent bg-white/50 p-1 font-noto-sans-mono text-[10px] text-zinc-600">
|
|
71
|
+
To pan the canvas, keep the mouse wheel or the space bar
|
|
72
|
+
pressed while dragging or use the hand tool.
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
<RoomUsersOverlay />
|
|
76
|
+
<ToolsOverlay />
|
|
77
|
+
<ZoomHandlerOverlay />
|
|
78
|
+
<MultiuseOverlay />
|
|
79
|
+
{transformingImage && (
|
|
80
|
+
<div className="bg-black/25 flex justify-center items-center absolute top-0 left-0 right-0 bottom-0">
|
|
81
|
+
<div className="flex flex-col gap-5 bg-white p-11 py-8 justify-center items-center">
|
|
82
|
+
<Logo kind="large" variant="no-text" />
|
|
83
|
+
<div className="font-noto-sans-mono text-base">
|
|
84
|
+
Removing background...
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
)}
|
|
89
|
+
{uploadingImage && (
|
|
90
|
+
<div className="bg-black/25 flex justify-center items-center absolute top-0 left-0 right-0 bottom-0">
|
|
91
|
+
<div className="flex flex-col gap-5 bg-white p-11 py-8 justify-center items-center">
|
|
92
|
+
<Logo kind="large" variant="no-text" />
|
|
93
|
+
<div className="font-noto-sans-mono text-base">
|
|
94
|
+
Uploading image...
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
)}
|
|
99
|
+
{loadingImage && (
|
|
100
|
+
<div className="bg-black/25 flex justify-center items-center absolute top-0 left-0 right-0 bottom-0">
|
|
101
|
+
<div className="flex flex-col gap-5 bg-white p-11 py-8 justify-center items-center">
|
|
102
|
+
<Logo kind="large" variant="no-text" />
|
|
103
|
+
<div className="font-noto-sans-mono text-base">
|
|
104
|
+
Loading image...
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
)}
|
|
109
|
+
</>
|
|
110
|
+
)}
|
|
111
|
+
</motion.div>
|
|
112
|
+
</AnimatePresence>
|
|
113
|
+
</div>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Toaster } from '@/components/ui/sonner';
|
|
5
|
+
import { useRouter } from 'next/navigation';
|
|
6
|
+
import { WeaveUser, WEAVE_INSTANCE_STATUS } from '@inditextech/weave-types';
|
|
7
|
+
import { useCollaborationRoom } from '@/store/store';
|
|
8
|
+
import { useWeave, WeaveProvider } from '@inditextech/weave-react';
|
|
9
|
+
import { RoomLayout } from './room.layout';
|
|
10
|
+
import { RoomLoader } from '../room-components/room-loader/room-loader';
|
|
11
|
+
import { AnimatePresence } from 'framer-motion';
|
|
12
|
+
import useGetWeaveJSProps from '../room-components/hooks/use-get-weave-js-props';
|
|
13
|
+
import useGetWebsocketsProvider from '../room-components/hooks/use-get-websockets-provider';
|
|
14
|
+
import useHandleRouteParams from '../room-components/hooks/use-handle-route-params';
|
|
15
|
+
import { UploadFile } from '../room-components/upload-file';
|
|
16
|
+
|
|
17
|
+
const statusMap = {
|
|
18
|
+
['idle']: 'Idle',
|
|
19
|
+
['starting']: 'Starting Weave...',
|
|
20
|
+
['loadingFonts']: 'Fetching custom fonts...',
|
|
21
|
+
['running']: 'Running',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Room = () => {
|
|
25
|
+
const router = useRouter();
|
|
26
|
+
|
|
27
|
+
const instance = useWeave((state) => state.instance);
|
|
28
|
+
const status = useWeave((state) => state.status);
|
|
29
|
+
const roomLoaded = useWeave((state) => state.room.loaded);
|
|
30
|
+
|
|
31
|
+
const room = useCollaborationRoom((state) => state.room);
|
|
32
|
+
const user = useCollaborationRoom((state) => state.user);
|
|
33
|
+
const loadingFetchConnectionUrl = useCollaborationRoom(
|
|
34
|
+
(state) => state.fetchConnectionUrl.loading
|
|
35
|
+
);
|
|
36
|
+
const errorFetchConnectionUrl = useCollaborationRoom(
|
|
37
|
+
(state) => state.fetchConnectionUrl.error
|
|
38
|
+
);
|
|
39
|
+
const setFetchConnectionUrlError = useCollaborationRoom(
|
|
40
|
+
(state) => state.setFetchConnectionUrlError
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const { loadedParams } = useHandleRouteParams();
|
|
44
|
+
|
|
45
|
+
const getUser = React.useCallback(() => {
|
|
46
|
+
return user as WeaveUser;
|
|
47
|
+
}, [user]);
|
|
48
|
+
|
|
49
|
+
const loadingDescription = React.useMemo(() => {
|
|
50
|
+
if (!loadedParams) {
|
|
51
|
+
return 'Fetching room parameters...';
|
|
52
|
+
}
|
|
53
|
+
if (loadingFetchConnectionUrl) {
|
|
54
|
+
return 'Connecting to the room...';
|
|
55
|
+
}
|
|
56
|
+
if (status !== WEAVE_INSTANCE_STATUS.RUNNING) {
|
|
57
|
+
return statusMap[status];
|
|
58
|
+
}
|
|
59
|
+
if (status === WEAVE_INSTANCE_STATUS.RUNNING && !roomLoaded) {
|
|
60
|
+
return 'Fetching room content...';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return '';
|
|
64
|
+
}, [loadedParams, loadingFetchConnectionUrl, status, roomLoaded]);
|
|
65
|
+
|
|
66
|
+
const { fonts, nodes, customPlugins, actions } = useGetWeaveJSProps();
|
|
67
|
+
|
|
68
|
+
const store = useGetWebsocketsProvider({
|
|
69
|
+
loadedParams,
|
|
70
|
+
getUser,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
setFetchConnectionUrlError(null);
|
|
75
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
78
|
+
React.useEffect(() => {
|
|
79
|
+
if (instance && status === WEAVE_INSTANCE_STATUS.RUNNING && roomLoaded) {
|
|
80
|
+
instance.triggerAction('selectionTool');
|
|
81
|
+
}
|
|
82
|
+
}, [instance, status, roomLoaded]);
|
|
83
|
+
|
|
84
|
+
if ((!room || !user) && loadedParams) {
|
|
85
|
+
router.push('/error?errorCode=room-required-parameters');
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (errorFetchConnectionUrl) {
|
|
90
|
+
router.push('/error?errorCode=room-failed-connection');
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<>
|
|
96
|
+
<AnimatePresence>
|
|
97
|
+
{(!loadedParams ||
|
|
98
|
+
loadingFetchConnectionUrl ||
|
|
99
|
+
status !== WEAVE_INSTANCE_STATUS.RUNNING ||
|
|
100
|
+
(status === WEAVE_INSTANCE_STATUS.RUNNING && !roomLoaded)) && (
|
|
101
|
+
<RoomLoader
|
|
102
|
+
roomId={room ? room : '-'}
|
|
103
|
+
content="LOADING ROOM"
|
|
104
|
+
description={loadingDescription}
|
|
105
|
+
/>
|
|
106
|
+
)}
|
|
107
|
+
</AnimatePresence>
|
|
108
|
+
{loadedParams && room && store && (
|
|
109
|
+
<WeaveProvider
|
|
110
|
+
containerId="weave"
|
|
111
|
+
getUser={getUser}
|
|
112
|
+
store={store}
|
|
113
|
+
fonts={fonts}
|
|
114
|
+
nodes={nodes}
|
|
115
|
+
actions={actions}
|
|
116
|
+
customPlugins={customPlugins}
|
|
117
|
+
>
|
|
118
|
+
<UploadFile />
|
|
119
|
+
<RoomLayout />
|
|
120
|
+
</WeaveProvider>
|
|
121
|
+
)}
|
|
122
|
+
<Toaster position="bottom-center" />
|
|
123
|
+
</>
|
|
124
|
+
);
|
|
125
|
+
};
|
package/template/+nextjs+websockets/components/room-components/color-tokens-library/color-token.tsx
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { colorIsLight } from '@/lib/utils';
|
|
5
|
+
|
|
6
|
+
type ColorTokenProps = {
|
|
7
|
+
color: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const ColorToken = ({ color }: Readonly<ColorTokenProps>) => {
|
|
11
|
+
let forefrontColor = '#ffffff';
|
|
12
|
+
if (colorIsLight(color)) {
|
|
13
|
+
forefrontColor = '#000000';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
className="cursor-pointer w-full h-full p-3"
|
|
19
|
+
draggable="true"
|
|
20
|
+
data-colortoken={color}
|
|
21
|
+
style={{ background: color }}
|
|
22
|
+
>
|
|
23
|
+
<div
|
|
24
|
+
style={{ color: forefrontColor }}
|
|
25
|
+
className="font-noto-sans-mono font-bold text-base"
|
|
26
|
+
>
|
|
27
|
+
{color}
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { useWeave } from '@inditextech/weave-react';
|
|
5
|
+
import { useCollaborationRoom } from '@/store/store';
|
|
6
|
+
import { ColorToken } from './color-token';
|
|
7
|
+
|
|
8
|
+
type ColorTokenElement = {
|
|
9
|
+
id: string;
|
|
10
|
+
color: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const ColorTokensLibrary = () => {
|
|
14
|
+
const instance = useWeave((state) => state.instance);
|
|
15
|
+
|
|
16
|
+
const colorTokenLibraryVisible = useCollaborationRoom(
|
|
17
|
+
(state) => state.colorToken.library.visible
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const commonColorTokens: ColorTokenElement[] = React.useMemo(() => {
|
|
21
|
+
return [
|
|
22
|
+
{ id: '1', color: '#28282D' },
|
|
23
|
+
{ id: '2', color: '#00656B' },
|
|
24
|
+
{ id: '3', color: '#D79D00' },
|
|
25
|
+
{ id: '4', color: '#3073B7' },
|
|
26
|
+
{ id: '5', color: '#953640' },
|
|
27
|
+
{ id: '6', color: '#C5AECF' },
|
|
28
|
+
{ id: '7', color: '#46295A' },
|
|
29
|
+
{ id: '8', color: '#79797C' },
|
|
30
|
+
];
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
if (!instance) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!colorTokenLibraryVisible) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div className="pointer-events-auto w-full h-full">
|
|
43
|
+
<div className="w-[calc(100%-38px)] font-title-xs p-1 bg-white flex justify-between items-center">
|
|
44
|
+
<div className="flex justify-between h-7 font-noto-sans-mono font-light items-center text-md pl-2">
|
|
45
|
+
Some Color Tokens
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
<div className="flex flex-col gap-2 w-full h-[calc(100%-50px)] border-t border-zinc-200">
|
|
49
|
+
<div
|
|
50
|
+
className="grid grid-cols-1 gap-2 w-full weaveDraggable p-4"
|
|
51
|
+
onDragStart={(e) => {
|
|
52
|
+
if (e.target instanceof HTMLDivElement) {
|
|
53
|
+
window.colorTokenDragColor = e.target.dataset.colortoken;
|
|
54
|
+
}
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
{commonColorTokens.map((ele) => {
|
|
58
|
+
return <ColorToken key={ele.id} color={ele.color} />;
|
|
59
|
+
})}
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import Avatar from 'boring-avatars';
|
|
5
|
+
import { Avatar as AvatarUI, AvatarFallback } from '@/components/ui/avatar';
|
|
6
|
+
import {
|
|
7
|
+
Tooltip,
|
|
8
|
+
TooltipContent,
|
|
9
|
+
TooltipProvider,
|
|
10
|
+
TooltipTrigger,
|
|
11
|
+
} from '@/components/ui/tooltip';
|
|
12
|
+
import { useCollaborationRoom } from '@/store/store';
|
|
13
|
+
import { ChevronDown } from 'lucide-react';
|
|
14
|
+
import {
|
|
15
|
+
DropdownMenu,
|
|
16
|
+
DropdownMenuContent,
|
|
17
|
+
DropdownMenuItem,
|
|
18
|
+
DropdownMenuTrigger,
|
|
19
|
+
} from '@/components/ui/dropdown-menu';
|
|
20
|
+
import { useWeave } from '@inditextech/weave-react';
|
|
21
|
+
import { cn } from '@/lib/utils';
|
|
22
|
+
|
|
23
|
+
export const ConnectedUsers = () => {
|
|
24
|
+
const connectedUsers = useWeave((state) => state.users);
|
|
25
|
+
|
|
26
|
+
const user = useCollaborationRoom((state) => state.user);
|
|
27
|
+
|
|
28
|
+
const [menuOpen, setMenuOpen] = React.useState(false);
|
|
29
|
+
|
|
30
|
+
const connectedUserKey = React.useMemo(() => {
|
|
31
|
+
const filterOwnUser = Object.keys(connectedUsers).filter(
|
|
32
|
+
(actUser) => actUser === user?.name
|
|
33
|
+
);
|
|
34
|
+
return filterOwnUser?.[0];
|
|
35
|
+
}, [user, connectedUsers]);
|
|
36
|
+
|
|
37
|
+
const { showUsers, restUsers } = React.useMemo(() => {
|
|
38
|
+
const filterOwnUser = Object.keys(connectedUsers).filter(
|
|
39
|
+
(actUser) => actUser !== user?.name
|
|
40
|
+
);
|
|
41
|
+
return {
|
|
42
|
+
showUsers: filterOwnUser.slice(0, 4),
|
|
43
|
+
restUsers: filterOwnUser.slice(4),
|
|
44
|
+
};
|
|
45
|
+
}, [user, connectedUsers]);
|
|
46
|
+
|
|
47
|
+
if (Object.keys(connectedUsers).length === 0) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div className="w-full min-h-[40px] flex gap-1 justify-between items-center">
|
|
53
|
+
<TooltipProvider delayDuration={300}>
|
|
54
|
+
<div className="w-full flex gap-1 justify-start items-center">
|
|
55
|
+
{connectedUserKey && (
|
|
56
|
+
<Tooltip>
|
|
57
|
+
<TooltipTrigger asChild>
|
|
58
|
+
<button className="cursor-pointer pointer-events-auto">
|
|
59
|
+
<AvatarUI className="w-[32px] h-[32px]">
|
|
60
|
+
<AvatarFallback>
|
|
61
|
+
<Avatar name={user?.name} variant="beam" />
|
|
62
|
+
</AvatarFallback>
|
|
63
|
+
</AvatarUI>
|
|
64
|
+
</button>
|
|
65
|
+
</TooltipTrigger>
|
|
66
|
+
<TooltipContent side="bottom" className="rounded-none">
|
|
67
|
+
<p className="font-noto-sans-mono text-xs">{user?.name}</p>
|
|
68
|
+
</TooltipContent>
|
|
69
|
+
</Tooltip>
|
|
70
|
+
)}
|
|
71
|
+
{showUsers.map((user) => {
|
|
72
|
+
const userInfo = connectedUsers[user];
|
|
73
|
+
return (
|
|
74
|
+
<Tooltip key={user}>
|
|
75
|
+
<TooltipTrigger asChild>
|
|
76
|
+
<button className="cursor-pointer pointer-events-auto">
|
|
77
|
+
<AvatarUI className="w-[32px] h-[32px]">
|
|
78
|
+
<AvatarFallback>
|
|
79
|
+
<Avatar name={userInfo?.name} variant="beam" />
|
|
80
|
+
</AvatarFallback>
|
|
81
|
+
</AvatarUI>
|
|
82
|
+
</button>
|
|
83
|
+
</TooltipTrigger>
|
|
84
|
+
<TooltipContent side="bottom">
|
|
85
|
+
<p className="font-noto-sans-mono text-sm">{userInfo.name}</p>
|
|
86
|
+
</TooltipContent>
|
|
87
|
+
</Tooltip>
|
|
88
|
+
);
|
|
89
|
+
})}
|
|
90
|
+
{restUsers.length > 0 && (
|
|
91
|
+
<>
|
|
92
|
+
<Tooltip>
|
|
93
|
+
<TooltipTrigger asChild>
|
|
94
|
+
<DropdownMenu
|
|
95
|
+
onOpenChange={(open: boolean) => setMenuOpen(open)}
|
|
96
|
+
>
|
|
97
|
+
<DropdownMenuTrigger
|
|
98
|
+
className={cn(
|
|
99
|
+
' pointer-events-auto rounded-none cursor-pointer p-2 hover:bg-accent focus:outline-none',
|
|
100
|
+
{
|
|
101
|
+
['bg-accent']: menuOpen,
|
|
102
|
+
['bg-white']: !menuOpen,
|
|
103
|
+
}
|
|
104
|
+
)}
|
|
105
|
+
>
|
|
106
|
+
<ChevronDown className="rounded-none" />
|
|
107
|
+
</DropdownMenuTrigger>
|
|
108
|
+
<DropdownMenuContent
|
|
109
|
+
align="end"
|
|
110
|
+
side="bottom"
|
|
111
|
+
alignOffset={0}
|
|
112
|
+
sideOffset={4}
|
|
113
|
+
className="font-noto-sans-mono rounded-none"
|
|
114
|
+
>
|
|
115
|
+
{restUsers.map((user) => {
|
|
116
|
+
const userInfo = connectedUsers[user];
|
|
117
|
+
return (
|
|
118
|
+
<DropdownMenuItem
|
|
119
|
+
key={user}
|
|
120
|
+
className="text-foreground focus:bg-white hover:rounded-none"
|
|
121
|
+
>
|
|
122
|
+
<AvatarUI className="w-[32px] h-[32px]">
|
|
123
|
+
<AvatarFallback>
|
|
124
|
+
<Avatar name={userInfo?.name} variant="beam" />
|
|
125
|
+
</AvatarFallback>
|
|
126
|
+
</AvatarUI>
|
|
127
|
+
{userInfo?.name}
|
|
128
|
+
</DropdownMenuItem>
|
|
129
|
+
);
|
|
130
|
+
})}
|
|
131
|
+
</DropdownMenuContent>
|
|
132
|
+
</DropdownMenu>
|
|
133
|
+
</TooltipTrigger>
|
|
134
|
+
<TooltipContent side="bottom">
|
|
135
|
+
<p className="font-noto-sans-mono text-sm">More users</p>
|
|
136
|
+
</TooltipContent>
|
|
137
|
+
</Tooltip>
|
|
138
|
+
</>
|
|
139
|
+
)}
|
|
140
|
+
</div>
|
|
141
|
+
<div className="flex justify-start items-center gap-1">
|
|
142
|
+
<div className="w-full flex justify-start gap-2 items-center text-center font-noto-sans-mono text-xs px-2">
|
|
143
|
+
<div className="px-2 py-1 bg-accent">
|
|
144
|
+
{Object.keys(connectedUsers).length}
|
|
145
|
+
</div>
|
|
146
|
+
<div className="text-left">users</div>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</TooltipProvider>
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
};
|