Skip to content

Commit

Permalink
added support for sp 8+, removed css files from base example
Browse files Browse the repository at this point in the history
  • Loading branch information
vaukalak committed Jun 11, 2024
1 parent 36f342c commit 74d38ef
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 17 deletions.
3 changes: 1 addition & 2 deletions lib/generators/react_on_rails/base_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def copy_base_files
def copy_js_bundle_files
base_path = "base/base/"
base_files = %w[app/javascript/packs/server-bundle.js
app/javascript/bundles/HelloWorld/components/HelloWorldServer.js
app/javascript/bundles/HelloWorld/components/HelloWorld.module.css]
app/javascript/bundles/HelloWorld/components/HelloWorldServer.js]
base_files.each { |file| copy_file("#{base_path}#{file}", file) }
end

Expand Down
8 changes: 4 additions & 4 deletions lib/generators/react_on_rails/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def invoke_generators
invoke "react_on_rails:react_no_redux"
end

invoke "react_on_rails:adapt_for_older_shakapacker" unless using_shakapacker_7?
invoke "react_on_rails:adapt_for_older_shakapacker" unless using_shakapacker_7_or_above?
end

# NOTE: other requirements for existing files such as .gitignore or application.
Expand Down Expand Up @@ -95,17 +95,17 @@ def add_bin_scripts

def add_post_install_message
message = GeneratorMessages.helpful_message_after_installation
unless using_shakapacker_7?
unless using_shakapacker_7_or_above?
message = message.gsub("config/shakapacker", "config/webpacker")
message = message.gsub("bin/shakapacker", "bin/webpacker")
end

GeneratorMessages.add_info(message)
end

def using_shakapacker_7?
def using_shakapacker_7_or_above?
shakapacker_gem = Gem::Specification.find_by_name("shakapacker")
shakapacker_gem.version.segments.first == 7
shakapacker_gem.version.segments.first >= 7
rescue Gem::MissingSpecError
# In case using Webpacker
false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import PropTypes from 'prop-types';
import React, { useState } from 'react';
import style from './HelloWorld.module.css';

const HelloWorld = (props) => {
const [name, setName] = useState(props.name);
Expand All @@ -10,7 +9,7 @@ const HelloWorld = (props) => {
<h3>Hello, {name}!</h3>
<hr />
<form>
<label className={style.bright} htmlFor="name">
<label className={{ color: "green" }} htmlFor="name">
Say hello to:
<input id="name" type="text" value={name} onChange={(e) => setName(e.target.value)} />
</label>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import PropTypes from 'prop-types';
import React from 'react';
import style from './HelloWorld.module.css';

const HelloWorld = ({ name, updateName }) => (
<div>
Expand All @@ -10,7 +9,7 @@ const HelloWorld = ({ name, updateName }) => (
</h3>
<hr />
<form>
<label className={style.bright} htmlFor="name">
<label className={{ color: "green" }} htmlFor="name">
Say hello to:
<input id="name" type="text" value={name} onChange={(e) => updateName(e.target.value)} />
</label>
Expand Down
3 changes: 0 additions & 3 deletions spec/dummy/client/app/components/HelloWorld.module.scss

This file was deleted.

0 comments on commit 74d38ef

Please sign in to comment.