staticz 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/helpers.rb +29 -0
- data/lib/manifest/manifest.rb +5 -0
- data/lib/manifest/react.rb +27 -0
- data/lib/manifest/sub.rb +4 -0
- data/lib/server.rb +1 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9df1b15e6569279a80d29e173395fbef21e674f275ff0ab0c50804348d22e272
|
4
|
+
data.tar.gz: a16bcca4068889052fdb41d541ac5c2e9922eb33ed06b36a5dabd5ea6beae12d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7460d6c6052926514f7a0ab771b0954f566f1655b77194ecbb3841ba8717c38d477b0c125519e1dd25fc28978131cb665fbe8a417c2bc8c625155c2a6a2d2c79
|
7
|
+
data.tar.gz: 6b6b5585c23109518bd4130179803c0363cd9ee3ef61930e971c4eebb0075ca5eeb7333d80f8e4e7723270085a021a2eba1ee69d7c184c9bd4d6e351d9bdf75a
|
data/lib/helpers.rb
CHANGED
@@ -24,3 +24,32 @@ end
|
|
24
24
|
def javascript(path)
|
25
25
|
"<script src=\"#{path}\"></script>"
|
26
26
|
end
|
27
|
+
|
28
|
+
def react(*component_file_paths)
|
29
|
+
lines = [
|
30
|
+
"<script crossorigin src=\"https://unpkg.com/react@18/umd/react.development.js\"></script>",
|
31
|
+
"<script crossorigin src=\"https://unpkg.com/react-dom@18/umd/react-dom.development.js\"></script>",
|
32
|
+
component_file_paths.map do |component_file_path|
|
33
|
+
javascript(component_file_path)
|
34
|
+
end
|
35
|
+
].flatten.join("\n")
|
36
|
+
end
|
37
|
+
|
38
|
+
def react_mount(*components)
|
39
|
+
components.map do |component|
|
40
|
+
[
|
41
|
+
"<script>",
|
42
|
+
"document.querySelectorAll('[data-component=\"#{component}\"]')",
|
43
|
+
".forEach(domContainer => {",
|
44
|
+
"console.log('yas')",
|
45
|
+
"const root = ReactDOM.createRoot(domContainer);",
|
46
|
+
"root.render(React.createElement(#{component}));",
|
47
|
+
"});",
|
48
|
+
"</script>"
|
49
|
+
]
|
50
|
+
end.flatten.join("\n")
|
51
|
+
end
|
52
|
+
|
53
|
+
def react_component(name, css_class = nil)
|
54
|
+
"<div data-component=\"#{name}\" class=\"#{css_class}\"></div>"
|
55
|
+
end
|
data/lib/manifest/manifest.rb
CHANGED
@@ -6,6 +6,7 @@ require_relative 'sass'
|
|
6
6
|
require_relative 'scss'
|
7
7
|
require_relative 'js'
|
8
8
|
require_relative 'cs'
|
9
|
+
require_relative 'react'
|
9
10
|
|
10
11
|
module Staticz
|
11
12
|
class Manifest
|
@@ -44,6 +45,10 @@ module Staticz
|
|
44
45
|
elements.push(Staticz::Cs.new(name))
|
45
46
|
end
|
46
47
|
|
48
|
+
def react(name)
|
49
|
+
elements.push(Staticz::React.new(name))
|
50
|
+
end
|
51
|
+
|
47
52
|
def build
|
48
53
|
load "#{Dir.pwd}/manifest.rb"
|
49
54
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'babel/transpiler'
|
2
|
+
|
3
|
+
module Staticz
|
4
|
+
class React
|
5
|
+
include Compilable
|
6
|
+
|
7
|
+
attr_reader :name
|
8
|
+
|
9
|
+
def source_file_ending = "js"
|
10
|
+
|
11
|
+
def build_file_ending = "js"
|
12
|
+
|
13
|
+
def tile_type_name = "React"
|
14
|
+
|
15
|
+
def initialize(name)
|
16
|
+
@name = name
|
17
|
+
end
|
18
|
+
|
19
|
+
def build
|
20
|
+
if exists?
|
21
|
+
engine = Babel::Transpiler.transform File.read(source_path)
|
22
|
+
|
23
|
+
File.write build_path, engine["code"]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/manifest/sub.rb
CHANGED
data/lib/server.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: staticz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipp Schlesinger
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/manifest/haml.rb
|
113
113
|
- lib/manifest/js.rb
|
114
114
|
- lib/manifest/manifest.rb
|
115
|
+
- lib/manifest/react.rb
|
115
116
|
- lib/manifest/sass.rb
|
116
117
|
- lib/manifest/scss.rb
|
117
118
|
- lib/manifest/sub.rb
|
@@ -130,6 +131,7 @@ licenses:
|
|
130
131
|
metadata:
|
131
132
|
documentation_uri: https://github.com/OfficialPhilcomm/staticz
|
132
133
|
source_code_uri: https://github.com/OfficialPhilcomm/staticz
|
134
|
+
changelog_uri: https://github.com/OfficialPhilcomm/staticz/blob/master/changelog.md
|
133
135
|
post_install_message:
|
134
136
|
rdoc_options: []
|
135
137
|
require_paths:
|