-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[REFACTOR] Extensible block - initial phase (#38)
* [REFACTOR] Introduce common LiveBlock component * Remove unused code * Introduce common StaticBlock component * Update changelog * Fix incorrect block transform Any transform containing a space character ended up being applied too soon due to a "hack" space character being put into every new cell. * Add blank `.credo.exs` * Make ContentEditable less hacky Rely on building correct cells and selection in hook rather than backend placing in custom characters * Document ContentEditable.ts * Run build * Simplify spec * Revert page.spec * Fix tests * Revert block.scss
- Loading branch information
Showing
20 changed files
with
344 additions
and
187 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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
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
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,28 @@ | ||
defmodule Philtre.LiveBlock do | ||
@moduledoc """ | ||
Single live component in charge of rendering all types of live blocks. | ||
Current implementation infers block type from struct module and simply | ||
delegates major callbacks to the bloc module. | ||
Later implementations might instead take block type from some sort of registry | ||
and require some sort of return format from the block modules, to decide how | ||
to render them. | ||
Ideally, we want individual blocks to be decoupled from the editor. | ||
""" | ||
use Phoenix.LiveComponent | ||
|
||
def update(assigns, socket) do | ||
{:ok, assign(socket, assigns)} | ||
end | ||
|
||
def render(%{block: %module{}} = assigns) do | ||
module.render_live(assigns) | ||
end | ||
|
||
def handle_event(event, payload, socket) do | ||
%module{} = socket.assigns.block | ||
module.handle_event(event, payload, socket) | ||
end | ||
end |
Oops, something went wrong.