diff --git a/packages/frontend/src/features/menu/MenuButton.tsx b/packages/frontend/src/features/menu/MenuButton.tsx
index 08c837c7..41a6bbc7 100644
--- a/packages/frontend/src/features/menu/MenuButton.tsx
+++ b/packages/frontend/src/features/menu/MenuButton.tsx
@@ -4,7 +4,7 @@ import { css, cx } from "#styled-system/css";
import { Flex, styled } from "#styled-system/jsx";
import Button from "@codegouvfr/react-dsfr/Button";
import { createModal } from "@codegouvfr/react-dsfr/Modal";
-import { ReactNode } from "react";
+import { ReactNode, useEffect, useRef } from "react";
import { useIsModalOpen } from "@codegouvfr/react-dsfr/Modal/useIsModalOpen";
import { useSelector } from "@xstate/store/react";
@@ -16,6 +16,8 @@ import { MenuActions } from "./MenuActions";
import { menuStore } from "./menuStore";
import { ShareReport } from "./Share";
+import { useClickAway } from "react-use";
+
const nestedMenus = ["main", "help", "clauses-nationales", "clauses-departementales", "share"] as const;
export type NestedMenu = (typeof nestedMenus)[number];
@@ -26,7 +28,9 @@ export const MenuButton = ({ headerRef }: { headerRef: any }) => {
const isOpen = isDesktop ? !!menu && menu !== "main" : !!menu;
useIsModalOpen(menuModal, {
- onConceal: () => menuStore.send({ type: "setMenu", menu: null }),
+ onConceal: () => {
+ menuStore.send({ type: "setMenu", menu: null });
+ },
});
return (
diff --git a/packages/frontend/src/features/text-editor/TextEditorToolbar.tsx b/packages/frontend/src/features/text-editor/TextEditorToolbar.tsx
index b4466e24..1b1981c1 100644
--- a/packages/frontend/src/features/text-editor/TextEditorToolbar.tsx
+++ b/packages/frontend/src/features/text-editor/TextEditorToolbar.tsx
@@ -1,9 +1,10 @@
import { cva } from "#styled-system/css";
-import { HStack, Stack } from "#styled-system/jsx";
+import { Flex, HStack, Stack, styled } from "#styled-system/jsx";
import Button from "@codegouvfr/react-dsfr/Button";
import { useContext, useState } from "react";
import { ColorPicker } from "../../components/ColorPicker";
import { TextEditorContext } from "./TextEditorContext";
+import { Popover } from "#components/Popover";
const toolbarButtonRecipe = cva({
base: {
@@ -86,74 +87,57 @@ const ColorInput = () => {
};
return (
- setIsOpen(open)}
- value={currentValue}
- onValueChangeEnd={(e) => editor.chain().focus().setColor(e.value.toString("hex")).run()}
- closeOnSelect={false}
- >
- {() => (
- <>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {/*
-
- Saved Colors
-
-
- {presets.map((color, id) => (
-
-
-
- ))}
-
- */}
-
-
-
- >
- )}
-
- //
- // editor
- // .chain()
- // .focus()
- // .setColor((event.target as any).value)
- // .run()
- // }
- // value={editor.getAttributes("textStyle").color ?? "#000000"}
- // />
+ setIsOpen(open)}>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+const ColorButton = ({ color, value }: { color: string; value: string }) => {
+ const editor = useContext(TextEditorContext).editor!;
+
+ const isSelected = value === color;
+
+ return (
+ {
+ editor.chain().focus().setColor(color).run();
+ }}
+ style={{
+ backgroundColor: color,
+ }}
+ border={isSelected ? "1px solid black" : undefined}
+ borderRadius="50%"
+ w="30px"
+ h="30px"
+ >
);
};