Skip to content

Commit 1e533df

Browse files
committed
feat(Editor): Initially replace the footer section
1 parent 8eb9de0 commit 1e533df

File tree

2 files changed

+44
-43
lines changed

2 files changed

+44
-43
lines changed

src/components/ButtonGroup.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React, { useState } from "react";
2+
import { buttonStyle, outlineButtonStyle } from "./styles.ts";
3+
4+
const activeStyle = "px-4 py-2 " + buttonStyle;
5+
const inactiveStyle = "px-4 py-2 " + outlineButtonStyle;
6+
const ButtonGroup: React.FC = () => {
7+
const [activeButton, setActiveButton] = useState("Nothing");
8+
9+
const handleButtonClick = (buttonName: string) => {
10+
setActiveButton(buttonName);
11+
};
12+
13+
return (
14+
<div className="flex gap-2 text-xs">
15+
<button
16+
className={activeButton === "Nothing" ? activeStyle : inactiveStyle}
17+
onClick={() => handleButtonClick("Nothing")}
18+
>
19+
Nothing
20+
</button>
21+
<button
22+
className={activeButton === "Text/HTML" ? activeStyle : inactiveStyle}
23+
onClick={() => handleButtonClick("Text/HTML")}
24+
>
25+
Text / HTML
26+
</button>
27+
<button
28+
className={activeButton === "Image" ? activeStyle : inactiveStyle}
29+
onClick={() => handleButtonClick("Image")}
30+
>
31+
Image
32+
</button>
33+
</div>
34+
);
35+
};
36+
37+
export default ButtonGroup;

src/components/Editor.tsx

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import DraggableItem from "./DraggableItem";
1010
import AceEditor from "react-ace";
1111
import "ace-builds/src-noconflict/mode-css";
1212
import "ace-builds/src-noconflict/ext-language_tools";
13-
import fieldStyle from "./fieldStyle.ts";
1413
import { buttonIconClasses, buttonStyle, fieldStyle, outlineButtonStyle } from "./styles.ts";
14+
import ButtonGroup from "./ButtonGroup.tsx";
1515

1616
const { emailHtml } = yekaEmailHtmlLib.dev.yekta.yeka.email.html;
1717

@@ -350,49 +350,13 @@ const App: React.FC = () => {
350350

351351
<div className="mb-6">
352352
<h2 className="mb-2 text-xl font-semibold text-primary-900">Footer</h2>
353-
<div className="mb-4">
354-
<h3 className="mb-2 font-semibold text-primary-800">Top Row</h3>
355-
<AddButton
356-
html={"Raw HTML"}
357-
onClick={() =>
358-
addFunction(setFooterTopRowFunctions, {
359-
type: "raw",
360-
html: "<div>Top Row Content</div>",
361-
})
362-
}
363-
/>
364-
<AddButton
365-
html={"Primary Button"}
366-
onClick={() =>
367-
addFunction(setFooterTopRowFunctions, {
368-
type: "primaryButton",
369-
label: "Click Me",
370-
href: "https://example.com",
371-
})
372-
}
373-
/>
353+
<div className="mb-4 flex items-center">
354+
<h3 className="me-4 font-semibold text-primary-800">Top Row</h3>
355+
<ButtonGroup />
374356
</div>
375-
<div className="mb-4">
376-
<h3 className="mb-2 font-semibold text-primary-800">Bottom Row</h3>
377-
<AddButton
378-
html={"Raw HTML"}
379-
onClick={() =>
380-
addFunction(setFooterBottomRowFunctions, {
381-
type: "raw",
382-
html: "<div>Top Row Content</div>",
383-
})
384-
}
385-
/>
386-
<AddButton
387-
html={"Primary Button"}
388-
onClick={() =>
389-
addFunction(setFooterBottomRowFunctions, {
390-
type: "primaryButton",
391-
label: "Click Me",
392-
href: "https://example.com",
393-
})
394-
}
395-
/>
357+
<div className="mb-4 flex items-center">
358+
<h3 className="me-4 font-semibold text-primary-800">Bottom Row</h3>
359+
<ButtonGroup />
396360
</div>
397361
</div>
398362

0 commit comments

Comments
 (0)