Skip to content

Commit e7971b8

Browse files
committed
fix: styling fixes, hack to make the text flicker appear
1 parent e59e79b commit e7971b8

File tree

3 files changed

+43
-17
lines changed

3 files changed

+43
-17
lines changed

web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"@kleros/ui-components-library": "^2.20.0",
9292
"@lifi/wallet-management": "^3.7.1",
9393
"@lifi/widget": "^3.18.1",
94-
"@mdxeditor/editor": "^3.44.2",
94+
"@mdxeditor/editor": "^3.45.0",
9595
"@reown/appkit": "^1.7.1",
9696
"@reown/appkit-adapter-wagmi": "^1.7.1",
9797
"@sentry/react": "^7.120.0",

web/src/components/MarkdownEditor.tsx

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,47 @@ import InfoIcon from "svgs/icons/info-circle.svg";
3131
const Container = styled.div<{ isEmpty: boolean }>`
3232
width: 100%;
3333
34-
[class*="mdxeditor"] {
35-
background-color: ${({ theme }) => theme.whiteBackground} !important;
34+
[class*="mdxeditor-toolbar"] {
35+
background-color: ${({ theme }) => theme.lightGrey};
3636
border: 1px solid ${({ theme }) => theme.stroke} !important;
3737
border-radius: 3px;
3838
font-family: "Open Sans", sans-serif;
39-
}
4039
41-
[class*="toolbar"] {
42-
background-color: ${({ theme }) => theme.lightGrey} !important;
43-
border-bottom: none !important;
40+
* svg {
41+
color: ${({ theme }) => theme.primaryText} !important;
42+
}
4443
45-
button {
46-
color: ${({ theme }) => theme.whiteBackground} !important;
44+
[class*="selectTrigger"] {
45+
background-color: ${({ theme }) => theme.whiteBackground} !important;
46+
color: ${({ theme }) => theme.primaryText} !important;
47+
cursor: pointer !important;
4748
}
4849
49-
svg {
50-
fill: ${({ theme }) => theme.whiteBackground} !important;
50+
button:hover {
51+
background-color: ${({ theme }) => theme.lightGrey}80 !important;
52+
cursor: pointer;
5153
}
5254
53-
select {
55+
button[data-state="on"],
56+
button[aria-pressed="true"] {
5457
background-color: ${({ theme }) => theme.whiteBackground} !important;
55-
color: ${({ theme }) => theme.primaryText} !important;
58+
}
59+
60+
button:disabled,
61+
button[data-disabled="true"] {
62+
opacity: 0.4 !important;
63+
cursor: not-allowed !important;
64+
65+
svg {
66+
color: ${({ theme }) => theme.secondaryText} !important;
67+
}
5668
}
5769
}
5870
5971
[class*="contentEditable"] {
6072
background-color: ${({ theme }) => theme.whiteBackground} !important;
73+
border: 1px solid ${({ theme }) => theme.stroke} !important;
74+
border-radius: 3px;
6175
color: ${({ theme }) => theme.primaryText} !important;
6276
min-height: 200px;
6377
padding: 16px;
@@ -165,7 +179,19 @@ const MarkdownEditor: React.FC<IMarkdownEditor> = ({
165179
const editorRef = useRef<MDXEditorMethods>(null);
166180

167181
const handleChange = (markdown: string) => {
168-
onChange(markdown);
182+
const cleanedMarkdown = markdown === "\u200B" ? "" : markdown.replace(/^\u200B/, "");
183+
onChange(cleanedMarkdown);
184+
};
185+
186+
const handleContainerClick = () => {
187+
if (isEmpty && editorRef.current) {
188+
editorRef.current.setMarkdown("\u200B");
189+
setTimeout(() => {
190+
if (editorRef.current) {
191+
editorRef.current.focus();
192+
}
193+
}, 0);
194+
}
169195
};
170196

171197
const isEmpty = !value || value.trim() === "";
@@ -204,7 +230,7 @@ const MarkdownEditor: React.FC<IMarkdownEditor> = ({
204230
};
205231

206232
return (
207-
<Container isEmpty={isEmpty}>
233+
<Container isEmpty={isEmpty} onClick={handleContainerClick}>
208234
<MDXEditor ref={editorRef} {...editorProps} />
209235
{showMessage && (
210236
<MessageContainer>

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6791,7 +6791,7 @@ __metadata:
67916791
"@kleros/ui-components-library": "npm:^2.20.0"
67926792
"@lifi/wallet-management": "npm:^3.7.1"
67936793
"@lifi/widget": "npm:^3.18.1"
6794-
"@mdxeditor/editor": "npm:^3.44.2"
6794+
"@mdxeditor/editor": "npm:^3.45.0"
67956795
"@reown/appkit": "npm:^1.7.1"
67966796
"@reown/appkit-adapter-wagmi": "npm:^1.7.1"
67976797
"@sentry/react": "npm:^7.120.0"
@@ -7635,7 +7635,7 @@ __metadata:
76357635
languageName: node
76367636
linkType: hard
76377637

7638-
"@mdxeditor/editor@npm:^3.44.2":
7638+
"@mdxeditor/editor@npm:^3.45.0":
76397639
version: 3.45.0
76407640
resolution: "@mdxeditor/editor@npm:3.45.0"
76417641
dependencies:

0 commit comments

Comments
 (0)