-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating @usewaypoint/email-builder (#58)
* Creating @usewaypoint/email-builder * Consuming @usewaypoint/email-builder
- Loading branch information
Showing
34 changed files
with
788 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/ContainerSidebarPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 14 additions & 13 deletions
27
packages/editor-sample/src/App/TemplatePanel/HtmlPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/editor-sample/src/documents/blocks/ColumnsContainer/ColumnsContainerEditor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
|
||
import { ColumnsContainer as BaseColumnsContainer } from '@usewaypoint/block-columns-container'; | ||
|
||
import { useCurrentBlockId } from '../../editor/EditorBlock'; | ||
import { setDocument, setSelectedBlockId } from '../../editor/EditorContext'; | ||
import EditorChildrenIds, { EditorChildrenChange } from '../helpers/EditorChildrenIds'; | ||
|
||
import ColumnsContainerPropsSchema, { ColumnsContainerProps } from './ColumnsContainerPropsSchema'; | ||
|
||
const EMPTY_COLUMNS = [{ childrenIds: [] }, { childrenIds: [] }, { childrenIds: [] }]; | ||
|
||
export default function ColumnsContainerEditor({ style, props }: ColumnsContainerProps) { | ||
const currentBlockId = useCurrentBlockId(); | ||
|
||
const { columns, ...restProps } = props ?? {}; | ||
const columnsValue = columns ?? EMPTY_COLUMNS; | ||
|
||
const updateColumn = (columnIndex: 0 | 1 | 2, { block, blockId, childrenIds }: EditorChildrenChange) => { | ||
const nColumns = [...columnsValue]; | ||
nColumns[columnIndex] = { childrenIds }; | ||
setDocument({ | ||
[blockId]: block, | ||
[currentBlockId]: { | ||
type: 'ColumnsContainer', | ||
data: ColumnsContainerPropsSchema.parse({ | ||
style, | ||
props: { | ||
...restProps, | ||
columns: nColumns, | ||
}, | ||
}), | ||
}, | ||
}); | ||
setSelectedBlockId(blockId); | ||
}; | ||
|
||
return ( | ||
<BaseColumnsContainer | ||
props={restProps} | ||
style={style} | ||
columns={[ | ||
<EditorChildrenIds childrenIds={columns?.[0]?.childrenIds} onChange={(change) => updateColumn(0, change)} />, | ||
<EditorChildrenIds childrenIds={columns?.[1]?.childrenIds} onChange={(change) => updateColumn(1, change)} />, | ||
<EditorChildrenIds childrenIds={columns?.[2]?.childrenIds} onChange={(change) => updateColumn(2, change)} />, | ||
]} | ||
/> | ||
); | ||
} |
84 changes: 0 additions & 84 deletions
84
packages/editor-sample/src/documents/blocks/ColumnsContainer/index.tsx
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
packages/editor-sample/src/documents/blocks/Container/ContainerEditor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
|
||
import { Container as BaseContainer } from '@usewaypoint/block-container'; | ||
|
||
import { useCurrentBlockId } from '../../editor/EditorBlock'; | ||
import { setDocument, setSelectedBlockId, useDocument } from '../../editor/EditorContext'; | ||
import EditorChildrenIds from '../helpers/EditorChildrenIds'; | ||
|
||
import { ContainerProps } from './ContainerPropsSchema'; | ||
|
||
export default function ContainerEditor({ style, props }: ContainerProps) { | ||
const childrenIds = props?.childrenIds ?? []; | ||
|
||
const document = useDocument(); | ||
const currentBlockId = useCurrentBlockId(); | ||
|
||
return ( | ||
<BaseContainer style={style}> | ||
<EditorChildrenIds | ||
childrenIds={childrenIds} | ||
onChange={({ block, blockId, childrenIds }) => { | ||
setDocument({ | ||
[blockId]: block, | ||
[currentBlockId]: { | ||
type: 'Container', | ||
data: { | ||
...document[currentBlockId].data, | ||
props: { childrenIds: childrenIds }, | ||
}, | ||
}, | ||
}); | ||
setSelectedBlockId(blockId); | ||
}} | ||
/> | ||
</BaseContainer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.