-
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 #6 from jrogers-hedgeye/188233440-finalize-add-aut…
…o-storybook-to-phlex_preview-engine DSL for registering and configuring components
- Loading branch information
Showing
22 changed files
with
213 additions
and
169 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
32 changes: 23 additions & 9 deletions
32
app/javascript/phlex_storybook/controllers/story_display_controller.js
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 |
---|---|---|
@@ -1,19 +1,33 @@ | ||
import { Controller } from "@hotwired/stimulus"; | ||
|
||
export default class extends Controller { | ||
static targets = ["previewBtn", "codeBtn", "preview", "code"]; | ||
static targets = ["previewBtn", "codeBtn", "sourceBtn", "preview", "code", "source"]; | ||
|
||
showCode() { | ||
this.previewTarget.classList.add('hidden'); | ||
this.codeTarget.classList.remove('hidden'); | ||
this.previewBtnTarget.classList.remove('story-preview-active'); | ||
this.codeBtnTarget.classList.add('story-code-active'); | ||
this.activate({displayTarget: this.codeTarget, buttonTarget: this.codeBtnTarget}); | ||
this.deactivate({displayTarget: this.previewTarget, buttonTarget: this.previewBtnTarget}); | ||
this.deactivate({displayTarget: this.sourceTarget, buttonTarget: this.sourceBtnTarget}); | ||
} | ||
|
||
showComponentSource() { | ||
this.activate({displayTarget: this.sourceTarget, buttonTarget: this.sourceBtnTarget}); | ||
this.deactivate({displayTarget: this.codeTarget, buttonTarget: this.codeBtnTarget}); | ||
this.deactivate({displayTarget: this.previewTarget, buttonTarget: this.previewBtnTarget}); | ||
} | ||
|
||
showPreview() { | ||
this.previewTarget.classList.remove('hidden'); | ||
this.codeTarget.classList.add('hidden'); | ||
this.previewBtnTarget.classList.add('story-preview-active'); | ||
this.codeBtnTarget.classList.remove('story-code-active'); | ||
this.activate({displayTarget: this.previewTarget, buttonTarget: this.previewBtnTarget}); | ||
this.deactivate({displayTarget: this.codeTarget, buttonTarget: this.codeBtnTarget}); | ||
this.deactivate({displayTarget: this.sourceTarget, buttonTarget: this.sourceBtnTarget}); | ||
} | ||
|
||
activate({displayTarget, buttonTarget}) { | ||
displayTarget.classList.remove('hidden'); | ||
buttonTarget.classList.add('story-button-active'); | ||
} | ||
|
||
deactivate({displayTarget, buttonTarget}) { | ||
displayTarget.classList.add('hidden'); | ||
buttonTarget.classList.remove('story-button-active'); | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,25 +1,15 @@ | ||
require_relative "story_component" | ||
|
||
module PhlexStorybook | ||
class Configuration | ||
attr_accessor :component_directories | ||
attr_reader :components | ||
|
||
def initialize | ||
@component_directories = %w[app/components] | ||
end | ||
|
||
def components | ||
component_directories.flat_map do |dir| | ||
Dir.glob("#{dir}/**/*.rb").select { |f| File.file?(f) }.map do |file| | ||
StoryComponent.new File.basename(file, ".rb").camelize.constantize, file | ||
end | ||
end | ||
end | ||
|
||
def component_directories | ||
@component_directories.map { |dir| Rails.root.join dir } | ||
@components = {} | ||
end | ||
|
||
def component_directories=(directories) | ||
@component_directories = directories | ||
def register(component, location) | ||
@components[component] = StoryComponent.new(component, location: location) | ||
end | ||
end | ||
end |
Oops, something went wrong.