Skip to content

Commit

Permalink
Add turbolinks
Browse files Browse the repository at this point in the history
  • Loading branch information
mizchi committed Oct 12, 2017
1 parent 49db97f commit 447a91e
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/assets/stylesheets/about.scss
@@ -0,0 +1,3 @@
// Place all the styles related to the about controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
4 changes: 4 additions & 0 deletions app/controllers/about_controller.rb
@@ -0,0 +1,4 @@
class AboutController < ApplicationController
def index
end
end
2 changes: 2 additions & 0 deletions app/helpers/about_helper.rb
@@ -0,0 +1,2 @@
module AboutHelper
end
5 changes: 5 additions & 0 deletions app/javascript/components/About.js
@@ -0,0 +1,5 @@
import React from 'react'

export default function About(props) {
return <p>This is about page.</p>
}
6 changes: 6 additions & 0 deletions app/javascript/components/Header.js
Expand Up @@ -5,6 +5,12 @@ export default function Header(props) {
<header>
<h1>Packnova</h1>
<p>Rails/Webpacker/Hypernova example</p>
<div>
Links:
<a href="/">home</a>
/
<a href="/about">about</a>
</div>
<hr />
</header>
)
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/exposeComponents.js
@@ -1,6 +1,8 @@
import { renderReact } from 'hypernova-react'
import _App from './components/App'
import _About from './components/About'
import _Header from './components/Header'

export const App = renderReact('App', _App)
export const About = renderReact('About', _About)
export const Header = renderReact('Header', _Header)
3 changes: 3 additions & 0 deletions app/javascript/packs/application.js
@@ -1 +1,4 @@
import '../exposeComponents'
import Turbolinks from 'turbolinks'

Turbolinks.start()
2 changes: 2 additions & 0 deletions app/views/about/index.html.erb
@@ -0,0 +1,2 @@
<%= render_react_component('Header') %>
<%= render_react_component('About') %>
1 change: 1 addition & 0 deletions config/routes.rb
@@ -1,3 +1,4 @@
Rails.application.routes.draw do
get 'about', to: 'about#index'
root 'home#index'
end
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -10,7 +10,8 @@
"hypernova": "^2.1.3",
"hypernova-react": "^2.0.0",
"react": "^16.0.0",
"react-dom": "^16.0.0"
"react-dom": "^16.0.0",
"turbolinks": "^5.0.3"
},
"devDependencies": {
"babel-preset-react": "^7.0.0-beta.2",
Expand Down
9 changes: 9 additions & 0 deletions test/controllers/about_controller_test.rb
@@ -0,0 +1,9 @@
require 'test_helper'

class AboutControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get about_index_url
assert_response :success
end

end
4 changes: 4 additions & 0 deletions yarn.lock
Expand Up @@ -5274,6 +5274,10 @@ tunnel-agent@^0.6.0:
dependencies:
safe-buffer "^5.0.1"

turbolinks@^5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/turbolinks/-/turbolinks-5.0.3.tgz#c8ce128cfc9be1d691a1e41ffa858a5a5ee86a02"

tweetnacl@^0.14.3, tweetnacl@~0.14.0:
version "0.14.5"
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
Expand Down

0 comments on commit 447a91e

Please sign in to comment.