diff options
| author | mo khan <mo@mokhan.ca> | 2017-03-03 21:01:01 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2017-03-03 21:01:01 -0700 |
| commit | 97b6774bec4e64fed894841be4849ec386d0ceaf (patch) | |
| tree | c19e16fae6e0dad94bc7137d0b5d34cd2c7251db | |
| parent | 14436face91aba044ac07f3be03395ec3d8d2b25 (diff) | |
add react version.
| -rw-r--r-- | Gemfile | 1 | ||||
| -rw-r--r-- | Gemfile.lock | 12 | ||||
| -rw-r--r-- | app/assets/javascripts/application.js | 32 | ||||
| -rw-r--r-- | app/assets/javascripts/application.js.coffee | 36 | ||||
| -rw-r--r-- | app/assets/javascripts/components.js | 1 | ||||
| -rw-r--r-- | app/assets/javascripts/components/.gitkeep | 0 | ||||
| -rw-r--r-- | app/assets/javascripts/components/recovery_day.js.jsx | 45 | ||||
| -rw-r--r-- | app/views/programs/texas_method.html.erb | 62 |
8 files changed, 124 insertions, 65 deletions
@@ -50,6 +50,7 @@ source "https://rubygems.org" do gem "rails-erd", group: :development gem "rails-i18n", "~> 4.0.0" gem "rails_12factor", group: :production + gem "react-rails" gem "redis", "~> 3.0" gem "rspec-rails", group: :test gem "rubyzip", require: "zip" diff --git a/Gemfile.lock b/Gemfile.lock index 80bd41e..4f944b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -48,6 +48,10 @@ GEM descendants_tracker (~> 0.0.4) ice_nine (~> 0.11.0) thread_safe (~> 0.3, >= 0.3.1) + babel-source (5.8.35) + babel-transpiler (0.7.0) + babel-source (>= 4.0, < 6) + execjs (~> 2.0) bcrypt (3.1.11) brakeman (3.3.2) builder (3.2.3) @@ -317,6 +321,13 @@ GEM ffi (>= 0.5.0) rdoc (4.2.2) json (~> 1.4) + react-rails (1.10.0) + babel-transpiler (>= 0.7.0) + coffee-script-source (~> 1.8) + connection_pool + execjs + railties (>= 3.2) + tilt redis (3.3.0) ref (2.0.0) rspec-core (3.5.1) @@ -495,6 +506,7 @@ DEPENDENCIES rails-erd! rails-i18n (~> 4.0.0)! rails_12factor! + react-rails! redis (~> 3.0)! rspec-rails! rubyzip! diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js deleted file mode 100644 index 6e8bec4..0000000 --- a/app/assets/javascripts/application.js +++ /dev/null @@ -1,32 +0,0 @@ -// This is a manifest file that'll be compiled into application.js, which will include all the files -// listed below. -// -// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. -// -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// compiled file. -// -// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details -// about supported directives. -// -//= require clipboard -//= require lodash -//= require moment -//= require jquery -//= require jquery_ujs -//= require ractive -//= require backbone -//= require ractive-backbone -//= require Chart.bundle -//= require chartkick -//= require fullcalendar -//= require vue -//= require_self -//= require_tree . -//= require turbolinks - -var Stronglifters = Stronglifters || {}; -$(document).on('turbolinks:load', function(){ - new Stronglifters.Startup().start(); -}); diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee new file mode 100644 index 0000000..f8269ba --- /dev/null +++ b/app/assets/javascripts/application.js.coffee @@ -0,0 +1,36 @@ +# This is a manifest file that'll be compiled into application.js, which will include all the files +# listed below. +# +# Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +# or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. +# +# It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +# compiled file. +# +# Read Sprockets README (https:#github.com/sstephenson/sprockets#sprockets-directives) for details +# about supported directives. +# +#= require clipboard +#= require lodash +#= require moment +#= require jquery +#= require jquery_ujs +#= require ractive +#= require backbone +#= require ractive-backbone +#= require Chart.bundle +#= require chartkick +#= require fullcalendar +#= require vue +#= require react +#= require react_ujs +#= require components + +#= require_self +#= require_tree . +#= require turbolinks + +window.Stronglifters ?= {} + +$(document).on 'turbolinks:load', () => + new Stronglifters.Startup().start() diff --git a/app/assets/javascripts/components.js b/app/assets/javascripts/components.js new file mode 100644 index 0000000..9ce7a4f --- /dev/null +++ b/app/assets/javascripts/components.js @@ -0,0 +1 @@ +//= require_tree ./components diff --git a/app/assets/javascripts/components/.gitkeep b/app/assets/javascripts/components/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/components/.gitkeep diff --git a/app/assets/javascripts/components/recovery_day.js.jsx b/app/assets/javascripts/components/recovery_day.js.jsx new file mode 100644 index 0000000..688c326 --- /dev/null +++ b/app/assets/javascripts/components/recovery_day.js.jsx @@ -0,0 +1,45 @@ +var RecoveryDay = React.createClass({ + propTypes: { + squat: React.PropTypes.number, + benchPress: React.PropTypes.number, + overheadPress: React.PropTypes.number + }, + + render: function() { + return ( + <div> + <h1 className="title">Wednesday</h1> + <h2 className="subtitle">Recovery Day</h2> + <table className="table"> + <tbody> + <tr> + <td><strong>Squat</strong> 2x5 @ 80% of Monday's work weight</td> + <td>{this.rounded(this.rounded(this.props.squat * 0.9) * 0.8)}lbs</td> + </tr> + <tr> + <td><strong>*Bench Press</strong> (3x5 @ 90% 5RM)</td> + <td>{this.props.bench_press * 0.9}lbs</td> + </tr> + <tr> + <td>*<strong>Overhead Press</strong> 3x5 @ 90% 5RM</td> + <td>{this.props.overhead_press * 0.9}lbs</td> + </tr> + <tr> + <td><strong>Chin-up</strong> 3 x body weight</td> + <td></td> + </tr> + <tr> + <td><strong>Back Extension</strong> or <strong>Glute Ham Raise</strong> 5x10</td> + <td></td> + </tr> + </tbody> + </table> + <p className="content is-small">*Bench press if you overhead pressed on Monday.</p> + </div> + ); + }, + + rounded: function(n) { + return n - (n % 5); + } +}); diff --git a/app/views/programs/texas_method.html.erb b/app/views/programs/texas_method.html.erb index 7134848..d27a0b2 100644 --- a/app/views/programs/texas_method.html.erb +++ b/app/views/programs/texas_method.html.erb @@ -7,60 +7,34 @@ </div> <div class="columns"> - <div class="column is-4"> + <div id="volume" class="column is-4"> <h1 class="title">Monday</h1> <h2 class="subtitle">Volume Day</h2> <table class="table"> <tbody> <tr> <td><strong>Squat</strong> (5x5 @ 90% 5RM)</td> - <td><%= rounded(@squat * 0.9) %>lbs</td> + <td>{{squat}}lbs</td> </tr> <tr> <td>*<strong>Bench Press</strong> (5x5 @ 90% 5RM)</td> - <td><%= rounded(@bench_press * 0.9) %>lbs</td> + <td>{{bench_press}}lbs</td> </tr> <tr> <td>*<strong>Overhead Press</strong> (5x5 @ 90% 5RM)</td> - <td><%= rounded(@overhead_press * 0.9) %>lbs</td> + <td>{{overhead_press}}lbs</td> </tr> <tr> <td><strong>Barbell Row</strong> (5x3 or 6x2)</td> - <td></td> + <td>{{barbell_row}}</td> </tr> </tbody> </table> <p class="content is-small">*Complete either Bench Press or Overhead Press.</p> </div> - <div class="column is-4"> - <h1 class="title">Wednesday</h1> - <h2 class="subtitle">Recovery Day</h2> - <table class="table"> - <tbody> - <tr> - <td><strong>Squat</strong> 2x5 @ 80% of Monday's work weight</td> - <td><%= rounded(rounded(@squat * 0.9) * 0.8) %>lbs</td> - </tr> - <tr> - <td><strong>*Bench Press</strong> (3x5 @ 90% 5RM)</td> - <td><%= rounded(@bench_press * 0.9) %>lbs</td> - </tr> - <tr> - <td>*<strong>Overhead Press</strong> 3x5 @ 90% 5RM</td> - <td><%= rounded(@overhead_press * 0.9) %>lbs</td> - </tr> - <tr> - <td><strong>Chin-up</strong> 3 x body weight</td> - <td></td> - </tr> - <tr> - <td><strong>Back Extension</strong> or <strong>Glute Ham Raise</strong> 5x10</td> - <td></td> - </tr> - </tbody> - </table> - <p class="content is-small">*Bench press if you overhead pressed on Monday.</p> + <div className="column is-4"> + <%= react_component('RecoveryDay', squat: @squat, bench_press: @bench_press, overhead_press: @overhead_press) %> </div> <div class="column is-4"> @@ -108,3 +82,25 @@ </div> </div> </div> + +<% content_for :javascript do %> + $(function(){ + window.volume = new Vue({ + el: '#volume', + data: { + squat_pr: <%= @squat %>, + bench_press_pr: <%= @bench_press %>, + overhead_press_pr: <%= @overhead_press %>, + barbell_row: 0, + }, + computed: { + squat: function() { return this.rounded(this.squat_pr * 0.9); }, + bench_press: function() { return this.rounded(this.bench_press_pr * 0.9); }, + overhead_press: function() { return this.rounded(this.overhead_press_pr * 0.9); }, + }, + methods: { + rounded: function(n) { return n - n % 5; } + } + }); + }); +<% end %> |
