diff --git a/editor/src/components/canvas/controls/comment-indicator.tsx b/editor/src/components/canvas/controls/comment-indicator.tsx index d08d3509988d..130b18da2865 100644 --- a/editor/src/components/canvas/controls/comment-indicator.tsx +++ b/editor/src/components/canvas/controls/comment-indicator.tsx @@ -39,7 +39,7 @@ import { canvasPointToWindowPoint } from '../dom-lookup' import { useRemixNavigationContext } from '../remix/utopia-remix-root-component' import { optionalMap } from '../../../core/shared/optional-utils' import { setRightMenuTab } from '../../editor/actions/action-creators' -import { RightMenuTab, getCurrentTheme } from '../../editor/store/editor-state' +import { RightMenuTab } from '../../editor/store/editor-state' import { when } from '../../../utils/react-conditionals' import { CommentRepliesCounter } from './comment-replies-counter' @@ -199,7 +199,6 @@ export const CommentIndicatorUI = React.memo((props) => position: 'fixed', top: position.y + 3, left: position.x - 3, - filter: resolved ? 'grayscale(1)' : undefined, width: IndicatorSize, height: IndicatorSize, background: read ? colorTheme.bg1.value : colorTheme.primary.value, @@ -208,6 +207,7 @@ export const CommentIndicatorUI = React.memo((props) => alignItems: 'center', justifyContent: 'center', boxShadow: UtopiaStyles.shadowStyles.mid.boxShadow, + opacity: resolved ? 0.6 : 'undefined', } const transform: Interpolation = { @@ -249,7 +249,7 @@ export const CommentIndicatorUI = React.memo((props) => justifyContent: 'center', }} > - + ) @@ -363,11 +363,6 @@ const HoveredCommentIndicator = React.memo((props: HoveredCommentIndicatorProps) const { thread, hidden, cancelHover, draggingCallback } = props const dispatch = useDispatch() - const theme = useEditorState( - Substores.userState, - (store) => getCurrentTheme(store.userState), - 'HoveredCommentIndicator theme', - ) const { location, scene: commentScene } = useCanvasLocationOfThread(thread) @@ -461,7 +456,6 @@ const HoveredCommentIndicator = React.memo((props: HoveredCommentIndicatorProps) overflow: 'auto', background: 'transparent', }} - data-theme={theme} user={user} comment={comment} showActions={false} diff --git a/editor/src/components/canvas/controls/comment-popup.tsx b/editor/src/components/canvas/controls/comment-popup.tsx index 3369ce187676..d17b5f987ec7 100644 --- a/editor/src/components/canvas/controls/comment-popup.tsx +++ b/editor/src/components/canvas/controls/comment-popup.tsx @@ -24,16 +24,7 @@ import { create } from '../../../core/shared/property-path' import { assertNever } from '../../../core/shared/utils' import { CommentWrapper, MultiplayerWrapper } from '../../../utils/multiplayer-wrapper' import { when } from '../../../utils/react-conditionals' -import { - Button, - FlexColumn, - FlexRow, - Icn, - Tooltip, - UtopiaStyles, - colorTheme, - useColorTheme, -} from '../../../uuiui' +import { Button, FlexRow, Icn, Tooltip, UtopiaStyles, colorTheme } from '../../../uuiui' import { setProp_UNSAFE, setRightMenuTab, @@ -47,14 +38,13 @@ import { isNewComment, } from '../../editor/editor-modes' import { useDispatch } from '../../editor/store/dispatch-context' -import { RightMenuTab, getCurrentTheme } from '../../editor/store/editor-state' +import { RightMenuTab } from '../../editor/store/editor-state' import { Substores, useEditorState } from '../../editor/store/store-hook' import { stopPropagation } from '../../inspector/common/inspector-utils' import { canvasPointToWindowPoint } from '../dom-lookup' import { RemixNavigationAtom } from '../remix/utopia-remix-root-component' import { getIdOfScene } from './comment-mode/comment-mode-hooks' import { motion, useAnimation } from 'framer-motion' -import { CSSCursor } from '../canvas-types' import type { EditorDispatch } from '../../editor/action-types' export const ComposerEditorClassName = 'lb-composer-editor' @@ -147,12 +137,6 @@ const CommentThread = React.memo(({ comment }: CommentThreadProps) => { } }, []) - const theme = useEditorState( - Substores.userState, - (store) => getCurrentTheme(store.userState), - 'CommentThread theme', - ) - const onCreateThread = React.useCallback( ({ body }: ComposerSubmitComment, event: React.FormEvent) => { event.preventDefault() @@ -406,7 +390,6 @@ const CommentThread = React.memo(({ comment }: CommentThreadProps) => { { const dispatch = useDispatch() - const theme = useEditorState( - Substores.userState, - (store) => getCurrentTheme(store.userState), - 'NewCommentPopup theme', - ) - const onNewCommentComposerKeyDown = React.useCallback( (e: React.KeyboardEvent) => switchToBasicCommentModeOnEscape(e, dispatch), [dispatch], @@ -525,7 +502,6 @@ const NewCommentPopup = React.memo((props: NewCommentPopupProps) => { (projectId == null ? generateUUID() : projectIdToRoomId(projectId)), [projectId], diff --git a/editor/src/components/user-bar.tsx b/editor/src/components/user-bar.tsx index 75af6028c600..2da2ed0b3102 100644 --- a/editor/src/components/user-bar.tsx +++ b/editor/src/components/user-bar.tsx @@ -341,6 +341,7 @@ interface AvatarPictureProps { initials: string size?: number isOffline?: boolean + resolved?: boolean } export const AvatarPicture = React.memo((props: AvatarPictureProps) => { @@ -370,7 +371,7 @@ export const AvatarPicture = React.memo((props: AvatarPictureProps) => { width: size ?? '100%', height: size ?? '100%', borderRadius: '100%', - filter: props.isOffline ? 'grayscale(1)' : undefined, + filter: props.isOffline || props.resolved ? 'grayscale(1)' : undefined, pointerEvents: 'none', }} src={url} diff --git a/editor/src/core/commenting/comment-hooks.tsx b/editor/src/core/commenting/comment-hooks.tsx index e9d3b102665a..6fa2de29df8f 100644 --- a/editor/src/core/commenting/comment-hooks.tsx +++ b/editor/src/core/commenting/comment-hooks.tsx @@ -27,6 +27,7 @@ import { getIdOfScene } from '../../components/canvas/controls/comment-mode/comm import type { ElementPath } from '../shared/project-file-types' import type { ElementInstanceMetadata } from '../shared/element-template' import * as EP from '../shared/element-path' +import { getCurrentTheme } from '../../components/editor/store/editor-state' export function useCanvasCommentThreadAndLocation(comment: CommentId): { location: CanvasPoint | null @@ -357,3 +358,14 @@ export function useDeleteThreadReadStatus() { } }, []) } + +export function useDataThemeAttributeOnBody() { + const theme = useEditorState( + Substores.userState, + (store) => getCurrentTheme(store.userState), + 'useDataThemeAttributeOnBody theme', + ) + React.useEffect(() => { + document.body.setAttribute('data-theme', theme) + }, [theme]) +} diff --git a/editor/src/utils/multiplayer-wrapper.tsx b/editor/src/utils/multiplayer-wrapper.tsx index 86c429807b8d..54c15bf539e7 100644 --- a/editor/src/utils/multiplayer-wrapper.tsx +++ b/editor/src/utils/multiplayer-wrapper.tsx @@ -10,8 +10,6 @@ import { normalizeMultiplayerName, } from '../core/shared/multiplayer' import { ErrorBoundary } from './react-error-boundary' -import { Substores, useEditorState } from '../components/editor/store/store-hook' -import { getCurrentTheme } from '../components/editor/store/editor-state' type Fallback = NonNullable | null @@ -30,14 +28,8 @@ MultiplayerWrapper.displayName = 'MultiplayerWrapper' export const CommentWrapper = React.memo( ({ user, ...commentProps }: { user: UserMeta | null } & CommentProps) => { - const theme = useEditorState( - Substores.userState, - (store) => getCurrentTheme(store.userState), - 'CommentWrapper theme', - ) - if (user == null) { - return + return } return (
@@ -54,7 +46,7 @@ export const CommentWrapper = React.memo( }} picture={user.avatar} /> - +
) },