-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from hedgeye-sdeming/runnable-experiments
feat: runnable experiments
- Loading branch information
Showing
9 changed files
with
166 additions
and
17 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
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
26 changes: 26 additions & 0 deletions
26
lib/phlex_storybook/components/experiments/experiment_editor.rb
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,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module PhlexStorybook | ||
module Components | ||
module Experiments | ||
class ExperimentEditor < ApplicationView | ||
def initialize(name:) | ||
@name = name | ||
end | ||
|
||
def view_template | ||
div id: "source", class: "h-full overflow-auto scroll", data: { code_editor_target: "editor" } | ||
textarea(class: "hidden", data: { copy_target: "source", code_editor_target: "ruby" }, name: "ruby") do | ||
source | ||
end | ||
end | ||
|
||
private | ||
|
||
def source | ||
File.read(PhlexStorybook.configuration.experiment(@name)) | ||
end | ||
end | ||
end | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
lib/phlex_storybook/components/experiments/experiment_preview.rb
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,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'digest' | ||
|
||
module PhlexStorybook | ||
module Components | ||
module Experiments | ||
class ExperimentPreview < ApplicationView | ||
def initialize(name:) | ||
@name = name | ||
end | ||
|
||
def view_template | ||
turbo_frame_tag("experiment_preview") do | ||
div(class: "text-xs bg-slate-500 text-slate-100 w-full p-2") do | ||
path = PhlexStorybook.configuration.experiment @name | ||
"file: #{path}, md5: #{Digest::MD5.hexdigest(File.read(path))}" | ||
end | ||
div(class: "row-span-3 h-full w-full overflow-y-scroll overflow-x-hidden px-2") do | ||
iframe(src: helpers.preview_experiment_path(@name), class: "w-full h-full") | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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