-
Notifications
You must be signed in to change notification settings - Fork 11
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 8 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,19 @@ | ||
<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 %> | ||
<% color = "#088F8F" %> | ||
|
||
<%# TODO: Delete this and use user provided value%> | ||
<% formula_image = "money_to_spent_2.png" %> | ||
|
||
<div style="--calculator-color: <%= color %>" 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> | ||
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> | ||
<% end %> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<%# TODO: Delete this and use user provided value %> | ||
<% color = "#088F8F" %> | ||
|
||
<section style="--calculator-color: <%= color %>" class="description-section"> | ||
<div class="description-block"> | ||
<div class="description-content-box"> | ||
<p data-type="description_block_html" class="description-text"> | ||
<%# TODO: Change description text and links %> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus faucibus arcu iaculis placerat euismod. Pellentesque nibh arcu, varius ac arcu a, eleifend semper leo. Aliquam ultricies lacus at mi ornare, sit amet vestibulum est fermentum. Praesent sed dapibus elit. Curabitur congue ante non metus posuere porttitor. Etiam non lacus imperdiet turpis pellentesque viverra. Nulla in velit mi. Suspendisse molestie tempor ornare. | ||
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, в який потім передадуть контент одною строкою |
||
<%= link_to_external(text: "Calculate Method", url: t("layouts.description_block.method_link"), class: "dynamic-text-color") %> or | ||
<%= link_to_external(text: "Contact Us", url: t("layouts.description_block.contact_link"), class: "dynamic-text-color") %> | ||
</p> | ||
</div> | ||
<div class="description-btn-box"> | ||
<%# TODO: Change link here %> | ||
<%= link_to_external(text: t('layouts.description_block.use_less'), | ||
url: t("layouts.description_block.use_less_link"), | ||
class: "action-button rounded dynamic-background-color text-white") %> | ||
</div> | ||
</div> | ||
</section> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,39 @@ | ||
<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| %> | ||
<%# TODO: Delete this and use user provided value %> | ||
<% calculator_image = "scales.png" %> | ||
|
||
<div style="--calculator-color: <%= color %>" 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="space-y-4 form-inputs"> | ||
<h1><%= form.label field.var_name, field.label %></h1> | ||
<div class="pb-2 input_lable"><%= form.label field.var_name, field.label %></div> | ||
<% if field.kind == 'number' %> | ||
<%= form.number_field "inputs[#{field.var_name}]", placeholder: field.label %> | ||
<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) %> | ||
<%= 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 %> | ||
</div><br> | ||
<% 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" %> | ||
<%= form.submit "Calculate", class: "btn-nonito result-btn dynamic-background-color" %> | ||
</div> | ||
<% end %> | ||
<%= image_tag "#{calculator_image}", class: "scales_img", alt: "Scales" %> | ||
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. alt через I18n пиши |
||
|
||
<%= turbo_frame_tag "calc-results" %> | ||
</div> | ||
</div> | ||
|
||
<%= turbo_frame_tag "calc-results" %> | ||
|
||
<%= 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.
а навіщо тут також колір передавати? він зверху передається та й все, ну на шоу пейджі