From db375629fc690e3b3e1e8d62cd9e971ca29b9570 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sun, 11 Apr 2021 20:35:18 +0200 Subject: [PATCH] Add nami field --- app/Member/MemberResource.php | 2 +- resources/css/app.css | 1 + resources/css/base.css | 18 ++++ resources/css/switch.css | 112 ++++++++++++++++++++++++ resources/js/app.js | 2 + resources/js/components/FSelect.vue | 6 +- resources/js/components/FSwitch.vue | 131 ++-------------------------- resources/js/components/FText.vue | 4 +- resources/js/views/member/Edit.vue | 3 + resources/js/views/member/Index.vue | 2 +- webpack.mix.js | 2 +- 11 files changed, 150 insertions(+), 133 deletions(-) create mode 100644 resources/css/switch.css diff --git a/app/Member/MemberResource.php b/app/Member/MemberResource.php index 0677fc35..9dc9763e 100644 --- a/app/Member/MemberResource.php +++ b/app/Member/MemberResource.php @@ -34,7 +34,6 @@ class MemberResource extends JsonResource 'email' => $this->email, 'email_parents' => $this->email_parents, 'fax' => $this->fax, - 'nami_id' => $this->nami_id, 'country_id' => $this->country_id, 'region_id' => $this->region_id, 'nationality_id' => $this->nationality_id, @@ -43,6 +42,7 @@ class MemberResource extends JsonResource 'letter_address' => $this->letter_address, 'bill_kind_id' => $this->bill_kind_id, 'bill_kind_name' => optional($this->billKind)->name, + 'has_nami' => $this->nami_id !== null, ]; } } diff --git a/resources/css/app.css b/resources/css/app.css index c53a4fe3..12181874 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -2,3 +2,4 @@ @import "tailwindcss/components"; @import "tailwindcss/utilities"; @import "base"; +@import "switch"; diff --git a/resources/css/base.css b/resources/css/base.css index a5f9fa6f..169cdfb7 100644 --- a/resources/css/base.css +++ b/resources/css/base.css @@ -84,3 +84,21 @@ input, select { outline: none; } + +input[type="date"], +input[type="datetime-local"], +input[type="time"], +input[type="month"], +select, +input[type="week"] { + height: 37px; + &::-webkit-inner-spin-button { + display: none; + } +} + +input[type="date"]::-webkit-inner-spin-button, +input[type="date"]::-webkit-calendar-picker-indicator { + display: none; + -webkit-appearance: none; +} diff --git a/resources/css/switch.css b/resources/css/switch.css new file mode 100644 index 00000000..4708ff0c --- /dev/null +++ b/resources/css/switch.css @@ -0,0 +1,112 @@ +:root { + --margin: 0.2rem; + --n-width: 37px; + --sm-width: 35px; + --sm-margin: 0.2rem; + --xs-width: 23px; + --xs-margin: 0.2rem; +} + +.field-switch { + input:checked + span { + transition: background 0.3s; + } + + .display { + width: calc(var(--n-width) * 2); + height: var(--n-width); + border-radius: 0.3rem; + var { + width: calc(var(--n-width) - var(--margin) * 2); + height: calc(var(--n-width) - var(--margin) * 2); + top: var(--margin); + left: var(--margin); + transition: left 0.3s; + } + & > span:nth-of-type(1) { + position: absolute; + width: calc(var(--n-width) - var(--margin)); + height: calc(var(--n-width) - var(--margin) * 2); + top: var(--margin); + left: var(--margin); + display: flex; + justify-content: center; + align-items: center; + } + & > span:nth-of-type(2) { + position: absolute; + width: calc(var(--n-width) - var(--margin)); + height: calc(var(--n-width) - var(--margin) * 2); + top: var(--margin); + left: calc(100% - var(--n-width)); + display: flex; + justify-content: center; + align-items: center; + } + } + + input:checked + .display var { + left: calc(var(--n-width) + var(--margin)); + transition: left 0.3s; + } + + /* --------------------------------- small size ---------------------------------- */ + .inner-field.h-field-sm { + input:checked + .display var { + left: calc(var(--sm-width) + var(--sm-margin)); + } + + .display { + width: calc(var(--sm-width) * 2); + height: var(--sm-width); + var { + width: calc(var(--sm-width) - var(--sm-margin) * 2); + height: calc(var(--sm-width) - var(--sm-margin) * 2); + top: var(--sm-margin); + left: var(--sm-margin); + } + & > span:nth-of-type(1) { + width: calc(var(--sm-width) - var(--sm-margin)); + height: calc(var(--sm-width) - var(--sm-margin) * 2); + top: var(--sm-margin); + left: var(--sm-margin); + } + & > span:nth-of-type(2) { + width: calc(var(--sm-width) - var(--sm-margin)); + height: calc(var(--sm-width) - var(--sm-margin) * 2); + top: var(--sm-margin); + left: calc(100% - var(--sm-width)); + } + } + } + + /* ------------------------------ very small size -------------------------------- */ + .inner-field.h-field-xs { + input:checked + .display var { + left: calc(var(--xs-width) + var(--xs-margin)); + } + + .display { + width: calc(var(--xs-width) * 2); + height: var(--xs-width); + var { + width: calc(var(--xs-width) - var(--xs-margin) * 2); + height: calc(var(--xs-width) - var(--xs-margin) * 2); + top: var(--xs-margin); + left: var(--xs-margin); + } + & > span:nth-of-type(1) { + width: calc(var(--xs-width) - var(--xs-margin)); + height: calc(var(--xs-width) - var(--xs-margin) * 2); + top: var(--xs-margin); + left: var(--xs-margin); + } + & > span:nth-of-type(2) { + width: calc(var(--xs-width) - var(--xs-margin)); + height: calc(var(--xs-width) - var(--xs-margin) * 2); + top: var(--xs-margin); + left: calc(100% - var(--xs-width)); + } + } + } +} diff --git a/resources/js/app.js b/resources/js/app.js index 5d63dc9c..4447ecee 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -6,6 +6,7 @@ window.io = require('socket.io-client'); import Sprite from './components/Sprite.js'; import FText from './components/FText.vue'; +import FSwitch from './components/FSwitch.vue'; import FSelect from './components/FSelect.vue'; import FTextarea from './components/FTextarea.vue'; import Pages from './components/Pages.vue'; @@ -14,6 +15,7 @@ import App from './layouts/App.vue'; Vue.use(plugin) Vue.component('f-text', FText); +Vue.component('f-switch', FSwitch); Vue.component('f-select', FSelect); Vue.component('f-textarea', FTextarea); Vue.component('sprite', Sprite); diff --git a/resources/js/components/FSelect.vue b/resources/js/components/FSelect.vue index e659cb37..e773cf21 100644 --- a/resources/js/components/FSelect.vue +++ b/resources/js/components/FSelect.vue @@ -1,7 +1,7 @@