-
-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/node
- Loading branch information
Showing
6 changed files
with
290 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
module ReactOnRails | ||
module ReactComponent | ||
class Options | ||
NO_PROPS = {}.freeze | ||
HIDDEN = "display:none".freeze | ||
|
||
attr_reader :index | ||
|
||
def initialize(name:, index:, options:) | ||
@name = name | ||
@index = index | ||
@options = options | ||
end | ||
|
||
def props | ||
options.fetch(:props) { NO_PROPS } | ||
end | ||
|
||
def name | ||
@name.camelize | ||
end | ||
|
||
def dom_id | ||
options.fetch(:id) { default_dom_id } | ||
end | ||
|
||
def html_options | ||
options[:html_options].to_h | ||
end | ||
|
||
def prerender | ||
retrieve_key(:prerender) | ||
end | ||
|
||
def trace | ||
retrieve_key(:trace) | ||
end | ||
|
||
def replay_console | ||
retrieve_key(:replay_console) | ||
end | ||
|
||
def raise_on_prerender_error | ||
retrieve_key(:raise_on_prerender_error) | ||
end | ||
|
||
def data | ||
{ | ||
component_name: name, | ||
props: props, | ||
trace: trace, | ||
dom_id: dom_id | ||
} | ||
end | ||
|
||
def style | ||
return nil if ReactOnRails.configuration.skip_display_none | ||
HIDDEN | ||
end | ||
|
||
private | ||
|
||
attr_reader :options | ||
|
||
def default_dom_id | ||
"#{@name}-react-component-#{@index}" | ||
end | ||
|
||
def retrieve_key(key) | ||
options.fetch(key) do | ||
ReactOnRails.configuration.public_send(key) | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.