Skip to content
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

入出金作成ページを Figma に合わせる #168

Merged
merged 8 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&display=swap"
href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap"
rel="stylesheet" />
</head>
<body>
Expand Down
36 changes: 12 additions & 24 deletions src/components/newTransaction/NewTransactionTarget.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<script lang="ts" setup>
import { PlusCircleIcon, MinusCircleIcon } from '@heroicons/vue/24/solid'
import { useToast } from 'vue-toastification'

import InputText from '/@/components/shared/InputText.vue'
import { PlusIcon, TrashIcon } from '@heroicons/vue/24/outline'

interface Props {
targets: string[]
Expand All @@ -11,8 +9,6 @@ interface Props {
const props = defineProps<Props>()
const emit = defineEmits<{ (e: 'input', value: string[]): void }>()

const toast = useToast()

function handleEditTarget(index: number, value: string) {
emit(
'input',
Expand All @@ -24,10 +20,6 @@ function handleAddTarget() {
emit('input', [...props.targets, ''])
}
function handleRemoveTarget(index: number) {
if (props.targets.length === 1) {
toast.warning('取引相手は1人以上必要です')
return
}
emit(
'input',
props.targets.filter((_, i) => i !== index)
Expand All @@ -36,25 +28,21 @@ function handleRemoveTarget(index: number) {
</script>

<template>
<div class="flex flex-col">
<label>取引相手</label>
<ul>
<li
v-for="(target, i) in targets"
:key="target"
class="mb-2 flex w-2/3 items-center gap-4">
<InputText
:model-value="target"
placeholder="取引相手"
<div class="flex flex-col gap-2">
<label class="text-sm font-medium" for="target">取引相手</label>
<ul class="flex flex-col gap-2">
<li v-for="(target, i) in targets" :key="target" class="flex items-center gap-3">
<InputText class="flex-grow" :model-value="target" placeholder="取引相手"
@update:model-value="handleEditTarget(i, $event)" />
<button class="flex" @click="handleRemoveTarget(i)">
<MinusCircleIcon class="w-6" />
<button v-if="props.targets.length > 1" class="flex" @click="handleRemoveTarget(i)">
<TrashIcon class="w-6 text-red-400" />
</button>
</li>
</ul>
<div class="w-2/3 text-center">
<button @click="handleAddTarget">
<PlusCircleIcon class="w-8" />
<div class="ml-3">
<button class="flex items-center p-2 border rounded" @click="handleAddTarget">
<PlusIcon class="w-5 mr-2" />
取引相手を追加
</button>
Comment on lines +43 to 46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

できればSimpleButton使ってほしいです

</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/components/shared/InputNumber.vue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minとかも明示してたのでどっちでもいいのですが、一応Vueの場合はpropsで明示していないものでも<input-number id="aaa" />ってしたらInputNumberの一番上の要素(今回はinput要素)に勝手に受け継いでくれる気がします

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

僕の環境だと受け継がなくて入れた覚えがあります

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface Props {
placeholder?: string
min?: number
autoFocus?: boolean
id?: string
}
const model = defineModel<number>({ required: true })
const props = withDefaults(defineProps<Props>(), {
Expand All @@ -30,6 +31,7 @@ onMounted(() => {

<template>
<input
:id="props.id"
ref="inputRef"
class="bg-background rounded border border-gray-300 py-1 px-2"
:min="props.min"
Expand Down
5 changes: 4 additions & 1 deletion src/components/shared/InputRadioButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ const props = defineProps<Props>()

<template>
<div class="space-x-4">
<label v-for="option in props.options" :key="option.key">
<label
v-for="option in props.options"
:key="option.key"
class="cursor-pointer">
<input v-model="model" type="radio" :value="option.value" />
{{ option.key }}
</label>
Expand Down
2 changes: 2 additions & 0 deletions src/components/shared/InputSelectMultiple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface Props {
isDropdownAbove?: boolean
/* [optionsのkey, modelValueのkey] modelValueをselectedValuesに適用するときに使う*/
uniqKeys?: [string, string]
id?: string
/* デフォルト幅を設定するため */
class?: string
}
Expand Down Expand Up @@ -284,6 +285,7 @@ onUnmounted(() => {
<button type="button" @click="removeValue(selectedValue)">×</button>
</div>
<input
:id="props.id"
ref="inputRef"
v-model="searchQuery"
class="flex-grow bg-transparent pl-1 focus:outline-none"
Expand Down
2 changes: 2 additions & 0 deletions src/components/shared/InputSelectSingle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface Props {
disabled?: boolean
isDropdownAbove?: boolean
uniqKeys?: [string, string]
id?: string
class?: string
}

Expand Down Expand Up @@ -191,6 +192,7 @@ onUnmounted(() => {
{{ selectedValue.key }}
</span>
<input
:id="props.id"
ref="inputRef"
v-model="searchQuery"
class="flex-grow bg-transparent focus:outline-none"
Expand Down
39 changes: 20 additions & 19 deletions src/pages/NewTransactionPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,50 +41,51 @@ if (!isTagFetched.value) {

<template>
<div v-if="!isAdmin">権限がありません。</div>
<div class="min-w-160 mx-auto flex w-2/3 flex-col px-12 pt-8">
<div class="pb-8">
<h1 class="text-center text-3xl">入出金記録の新規作成</h1>
<div v-else class="min-w-160 mx-auto mb-5 flex w-2/3 flex-col px-12 pt-8">
<div class="pb-6">
<h1 class="text-2xl">入出金記録の新規作成</h1>
</div>
<form class="flex flex-col gap-2">
<div class="flex flex-col">
<label>金額</label>
<form class="flex flex-col gap-6">
<div class="flex flex-col gap-2">
<label class="text-sm font-medium" for="amount">金額</label>
<div>
<InputNumber
id="amount"
v-model="transaction.amount"
auto-focus
class="mr-1"
class="mr-2"
:min="1" />円
</div>
</div>
<div class="flex flex-col">
<label>入出金</label>
<div class="flex flex-col gap-2">
<label class="text-sm font-medium">入出金の方向</label>
<InputRadioButton
v-model="moneyDirection"
:options="directionOptions" />
</div>
<NewTransactionTarget
:targets="transaction.targets"
@input="transaction.targets = $event" />
<div class="flex flex-col">
<label>グループ</label>
<div class="flex flex-col gap-2">
<label class="text-sm font-medium" for="group">グループ</label>
<InputSelectSingle
id="group"
v-model="transaction.group"
class="!w-2/3"
class="w-full"
:options="groupOptions"
placeholder="グループを選択" />
</div>
<div class="flex flex-col">
<label>タグ</label>
<InputSelectTagWithCreation v-model="transaction.tags" class="!w-2/3" />
<div class="flex flex-col gap-2">
<label class="text-sm font-medium" for="tag">タグ</label>
<InputSelectTagWithCreation id="tag" v-model="transaction.tags" />
</div>
<div class="text-right">
<SimpleButton
class="mb-4 w-64"
:disabled="isSending"
font-size="xl"
padding="sm"
font-size="md"
padding="md"
@click.stop="postTransaction">
入出金記録を作成する
入出金記録を作成
</SimpleButton>
</div>
</form>
Expand Down