-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Style calculators constructor show page #984
Changes from 13 commits
70ce755
8744fe7
8a0a37f
3bf95ba
fa90e50
fca482e
6e9fd0d
2a5b0c2
2314773
6944ef3
e50181b
ba40fe9
847f32e
e144e42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
<h2 class="mt-4 text-2xl font-bold text-white underline">Calculation Results</h2> | ||
<div class="mt-2 space-y-2 text-white"> | ||
<% results.each do |result| %> | ||
<div class="flex gap-2 text-lg font-medium"> | ||
<h3> | ||
<%= result[:label] %> | ||
</h3> | ||
= | ||
<p> | ||
<%= result[:result] %> | ||
</p> | ||
</div> | ||
<% end %> | ||
<%# TODO: Delete this and use user provided value%> | ||
<% formula_image = "money_to_spent_2.png" %> | ||
|
||
<div class="calculation-results rounded jumbotron jumbotron-fluid position-relative"> | ||
<h2 class="pt-6 text-2xl font-semibold text-center dynamic-text-color">Calculation Results</h2> | ||
<div class="jumbotron calculation-results result main-result-container result-container"> | ||
<% results.each do |result| %> | ||
<div> | ||
<%= image_tag "#{formula_image}", class: "img-margin", alt: "icon" %> | ||
<p class="dynamic-text-color"><%= result[:result] %></p> | ||
<p class="text-2xl dynamic-text-color"><%= result[:unit] %></p> | ||
<p class="diapers-font-text"><%= result[:label] %></p> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<%# TODO: Delete this if %> | ||
<% if false %> | ||
<section class="description-section"> | ||
<div class="description-block"> | ||
<div class="description-content-box"> | ||
<p data-type="description_block_html" class="description-text"> | ||
<%# TODO: Add description text and links %> | ||
</p> | ||
</div> | ||
<div class="description-btn-box"> | ||
<%# TODO: Add discription btn link here %> | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. має бути один ендпоінт, куди буде закидатися контент, ну я ж казав про це There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. засинкайся з Сашею, вона тобі покаже, що на виході має, ви маєте законектитись |
||
</div> | ||
</section> | ||
<% end %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,40 @@ | ||
<div class="container place-items-center"> | ||
<h1 class="text-4xl font-bold">Calculator <%= @calculator.name %></h1><br> | ||
<%# TODO: Delete this and use user provided value %> | ||
<% color = "#088F8F" %> | ||
|
||
<%= form_with url: calculate_calculator_path(@calculator) do |form| %> | ||
<% @calculator.fields.each do |field| %> | ||
<div class="space-y-4 form-inputs"> | ||
<h1><%= form.label field.var_name, field.label %></h1> | ||
<% if field.kind == 'number' %> | ||
<%= form.number_field "inputs[#{field.var_name}]", placeholder: field.label %> | ||
<% else %> | ||
<%= form.select "inputs[#{field.var_name}]", options_from_collection_for_select(field.categories, :price, :name) %> | ||
<% end %> | ||
</div><br> | ||
<%# TODO: Delete this and use user provided value %> | ||
<% calculator_image = "scales.png" %> | ||
|
||
<div style="--calculator-color: <%= color %>"> | ||
<div class="rounded jumbotron jumbotron-fluid position-relative"> | ||
<h1 class="pt-6 text-2xl font-semibold text-center font-sans dynamic-text-color">Calculator <%= @calculator.name %> <%= @text %></h1> | ||
<div class="flex-wrap d-flex justify-content-around calculator_wrap ms-5"> | ||
|
||
<%= form_with html: { class: "simple_form_calculator"}, url: calculate_calculator_path(@calculator) do |form| %> | ||
<div class="flex-item flex-column"> | ||
<% @calculator.fields.each do |field| %> | ||
<div class="pb-2 input_lable"><%= form.label field.var_name, field.label %></div> | ||
<% if field.kind == 'number' %> | ||
<div class="flex-row rounded flex-item w-100 age_wrapper form_fild"> | ||
<%= form.number_field "inputs[#{field.var_name}]", | ||
placeholder: field.label, | ||
class: "required rounded w-100 calculator-field" | ||
%> | ||
</div> | ||
<% else %> | ||
<%= form.select "inputs[#{field.var_name}]", | ||
options_from_collection_for_select(field.categories, :price, :name), | ||
{}, | ||
class: "flex-row rounded flex-item w-100 form_fild calculator-field" %> | ||
<% end %> | ||
<% end %> | ||
<%= form.submit "Calculate", class: "btn-nonito result-btn dynamic-background-color" %> | ||
</div> | ||
<% end %> | ||
<div class="mt-6 form-actions"> | ||
<%= form.submit "Calculate", class: "bg-blue-500 text-white font-semibold px-4 py-2 rounded hover:bg-blue-700" %> | ||
<%= image_tag calculator_image, class: "scales_img", alt: t(".image_alt") %> | ||
</div> | ||
<% end %> | ||
</div> | ||
|
||
<%= turbo_frame_tag "calc-results" %> | ||
</div> | ||
|
||
<%= render "calculators/partials/show/constructor_calculator_description" %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe Calculators::CalculationService, type: :helper do | ||
let(:calculator) { instance_double("Calculator", formulas: formulas) } | ||
let(:formulas) do | ||
[ | ||
Formula.new(en_label: "Addition", en_unit: "units", uk_label: "Додавання", uk_unit: "одиниці", expression: "x + y"), | ||
Formula.new(en_label: "Multiplication", en_unit: "units", uk_label: "Множення", uk_unit: "одиниці", expression: "x * y") | ||
] | ||
end | ||
let(:inputs) { ActionController::Parameters.new({ x: 5, y: 3 }) } | ||
|
||
before do | ||
allow_any_instance_of(ApplicationHelper).to receive(:current_locale?).with(:en).and_return(locale_en) | ||
end | ||
|
||
describe "#perform" do | ||
subject do | ||
I18n.with_locale(locale_en ? :en : :uk) do | ||
described_class.new(calculator, inputs).perform | ||
end | ||
end | ||
|
||
context "when locale is English" do | ||
let(:locale_en) { true } | ||
|
||
it "returns results with English labels and units" do | ||
expect(subject).to eq([ | ||
{ label: "Addition", result: 8, unit: "units" }, | ||
{ label: "Multiplication", result: 15, unit: "units" } | ||
]) | ||
end | ||
end | ||
|
||
context "when locale is Ukrainian" do | ||
let(:locale_en) { false } | ||
|
||
it "returns results with Ukrainian labels and units" do | ||
expect(subject).to eq([ | ||
{ label: "Додавання", result: 8, unit: "одиниці" }, | ||
{ label: "Множення", result: 15, unit: "одиниці" } | ||
]) | ||
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вирівняй