Skip to content

Commit 4746650

Browse files
committed
Refactored contexts away
1 parent 4d4c803 commit 4746650

16 files changed

Lines changed: 718 additions & 768 deletions

packages/email-editor/src/blocks/image/settings.tsx

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { useEmailEditor } from "@/context/email-editor-context";
2-
import type { Content } from "@/types/email-editor";
1+
import type { Content, Style } from "@/types/email-editor";
32
import type { ImageBlockSettings } from "./types";
43
import { SettingsInput } from "@/components/settings/settings-input";
54
import { SettingsSelect } from "@/components/settings/settings-select";
@@ -11,11 +10,15 @@ import { Upload } from "lucide-react";
1110

1211
interface ImageSettingsProps {
1312
block: Required<Content> & { settings: ImageBlockSettings };
13+
style?: Style;
14+
updateBlock: (id: string, content: Partial<Content>) => void;
1415
}
1516

16-
export function ImageSettings({ block }: ImageSettingsProps) {
17-
const { updateBlock } = useEmailEditor();
18-
17+
export function ImageSettings({
18+
block,
19+
style,
20+
updateBlock,
21+
}: ImageSettingsProps) {
1922
const handleSettingChange = (key: string, value: any) => {
2023
updateBlock(block.id, {
2124
settings: {
@@ -203,7 +206,7 @@ export function ImageSettings({ block }: ImageSettingsProps) {
203206
handleSettingChange("borderRadius", `${value}px`)
204207
}
205208
min={0}
206-
max={250}
209+
max={50}
207210
defaultValue={0}
208211
/>
209212

@@ -214,7 +217,7 @@ export function ImageSettings({ block }: ImageSettingsProps) {
214217
handleSettingChange("borderWidth", `${value}px`)
215218
}
216219
min={0}
217-
max={10}
220+
max={20}
218221
defaultValue={0}
219222
/>
220223

@@ -249,35 +252,40 @@ export function ImageSettings({ block }: ImageSettingsProps) {
249252
defaultValue="transparent"
250253
/>
251254

252-
{/* <SettingsColorPicker
253-
label="Foreground Color"
254-
value={block.settings.foregroundColor || "#000000"}
255-
onChange={(value) =>
256-
handleSettingChange("foregroundColor", value)
257-
}
258-
defaultValue="#000000"
259-
/> */}
260-
261255
<SettingsSlider
262256
label="Padding Top"
263-
value={paddingTop}
257+
value={pxToNumber(
258+
block.settings.paddingTop ||
259+
style?.structure.section.padding?.y,
260+
16,
261+
)}
264262
onChange={(value) =>
265263
handleSettingChange("paddingTop", `${value}px`)
266264
}
267265
min={0}
268266
max={100}
269-
defaultValue={0}
267+
defaultValue={pxToNumber(
268+
style?.structure.section.padding?.y,
269+
16,
270+
)}
270271
/>
271272

272273
<SettingsSlider
273274
label="Padding Bottom"
274-
value={paddingBottom}
275+
value={pxToNumber(
276+
block.settings.paddingBottom ||
277+
style?.structure.section.padding?.y,
278+
16,
279+
)}
275280
onChange={(value) =>
276281
handleSettingChange("paddingBottom", `${value}px`)
277282
}
278283
min={0}
279284
max={100}
280-
defaultValue={0}
285+
defaultValue={pxToNumber(
286+
style?.structure.section.padding?.y,
287+
16,
288+
)}
281289
/>
282290
</SettingsSection>
283291
</div>

0 commit comments

Comments
 (0)