Skip to content

Commit

Permalink
Adding a menu for extra calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
orchestr7 committed Aug 16, 2024
1 parent bad422e commit 1121671
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import react.dom.html.ReactHTML.p
import ru.thetax.calculator.TaxCalculator
import ru.thetax.calculator.TaxDetail
import ru.thetax.calculator.TaxRates
import ru.thetax.views.main.header.SalaryProps
import ru.thetax.views.utils.PeriodEnum
import ru.thetax.views.utils.externals.i18n.TranslationFunction
import ru.thetax.views.utils.externals.i18n.useTranslation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ru.thetax.views.main

import react.*
import react.dom.html.ReactHTML.div
import ru.thetax.views.main.header.headerAndInput
import ru.thetax.views.utils.PeriodEnum
import web.cssom.ClassName

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package ru.thetax.views.main
package ru.thetax.views.main.header

import js.objects.jso
import react.*
import react.dom.html.ReactHTML.a
import react.dom.html.ReactHTML.button
import react.dom.html.ReactHTML.col
import react.dom.html.ReactHTML.div
import react.dom.html.ReactHTML.h1
import react.dom.html.ReactHTML.h5
import react.dom.html.ReactHTML.h6
import react.dom.html.ReactHTML.img
import react.dom.html.ReactHTML.input
import react.dom.html.ReactHTML.option
import react.dom.html.ReactHTML.p
import react.dom.html.ReactHTML.select
import ru.thetax.views.main.HeaderAndInputProps
import ru.thetax.views.main.parseAndCalculateYearSalary
import ru.thetax.views.utils.PeriodEnum
import ru.thetax.views.utils.externals.cookie.cookie
import ru.thetax.views.utils.externals.cookie.getLanguageCode
Expand All @@ -22,7 +20,6 @@ import ru.thetax.views.utils.externals.i18n.PlatformLanguages
import ru.thetax.views.utils.externals.i18n.changeLanguage
import ru.thetax.views.utils.externals.i18n.useTranslation
import web.cssom.*
import web.html.ButtonType

/**
* Header with an input of salary and meta information
Expand Down Expand Up @@ -187,53 +184,6 @@ val headerAndInput = FC<HeaderAndInputProps> { props ->
}
}

val menu = FC<SalaryProps> {
div {
className = ClassName("row mt-3 d-flex justify-content-center")
div {
className = ClassName("border col-xl-8 col-lg-8 col-md-8 col-sm-9 col-xs-10 d-flex justify-content-center px-3")
style = jso {
borderRadius = 10.px
}
menuButton(faEnvelope, "Новый", "НДФЛ", true)
menuButton(faMoneyTrend, "Доход", "снизится?", false)
menuButton(faSack, "Все", "налоги", false)
}
}
}

fun ChildrenBuilder.menuButton(faIconModule: FontAwesomeIconModule, text1: String, text2: String, isActive: Boolean) {
button {
type = ButtonType.button
className = ClassName("${if (isActive) "active" else "hover-button"} my-2 btn btn-outline-light border-0 mx-1")
div {
style = jso {
color = if (isActive) rgb(50,50,50) else rgb(210, 210, 230)
}
className = ClassName("col")
div {
className = ClassName("row d-flex justify-content-center mb-2")
fontAwesomeIcon(faIconModule, "fa-xl mx-2")
}
div {
className = ClassName("row d-flex justify-content-center")
h6 {
className = ClassName("mb-0")
+text1
}
}
div {
className = ClassName("row d-flex justify-content-center")
h6 {
className = ClassName("mb-0")
+text2
}
}
}
}
}


external interface SalaryProps : Props {
var salaryDoubleInternal: Double
var periodInput: PeriodEnum
Expand Down
72 changes: 72 additions & 0 deletions frontend/src/jsMain/kotlin/ru/thetax/views/main/header/Menu.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package ru.thetax.views.main.header

import js.objects.jso
import react.ChildrenBuilder
import react.FC
import react.Props
import react.dom.html.ReactHTML.button
import react.dom.html.ReactHTML.div
import react.dom.html.ReactHTML.h6
import ru.thetax.views.utils.PeriodEnum
import ru.thetax.views.utils.externals.fontawesome.*
import web.cssom.ClassName
import web.cssom.px
import web.cssom.rgb
import web.html.ButtonType

val menu = FC<SalaryProps> {
div {
className = ClassName("row mt-3 d-flex justify-content-center")
div {
className = ClassName("border col-xl-8 col-lg-8 col-md-8 col-sm-9 col-xs-10 d-flex justify-content-center px-3")
style = jso {
borderRadius = 10.px
}
menuButton(faEnvelope, "Новый", "НДФЛ", true)
menuButton(faMoneyTrend, "Доход", "снизится?", false)
menuButton(faSack, "Все", "налоги", false)
}
}
}

fun ChildrenBuilder.menuButton(faIconModule: FontAwesomeIconModule, text1: String, text2: String, isActive: Boolean) {
button {
type = ButtonType.button
className = ClassName("${if (isActive) "active" else "hover-button"} my-2 btn btn-outline-light border-0 mx-1")
div {
style = jso {
color = if (isActive) rgb(50, 50, 50) else rgb(210, 210, 230)
}
className = ClassName("col")
div {
className = ClassName("row d-flex justify-content-center mb-2")
fontAwesomeIcon(faIconModule, "fa-xl mx-2")
}
div {
className = ClassName("row d-flex justify-content-center")
h6 {
className = ClassName("mb-0")
+text1
}
}
div {
className = ClassName("row d-flex justify-content-center")
h6 {
className = ClassName("mb-0")
+text2
}
}
}
}
}

external interface MenuProps : Props {
var setSelectedMenu: Double
var selectedMenu: PeriodEnum
}

enum class Menu {
NEW_TAX,
TAX_DIFFERENCE,
ALL_TAX,
}

0 comments on commit 1121671

Please sign in to comment.