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

ServiceAccordion の実装 #53

Merged
merged 10 commits into from
Apr 12, 2023
96 changes: 96 additions & 0 deletions src/components/UI/BaseSelect.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<script lang="ts" setup>
import vSelect from 'vue-select'
import 'vue-select/dist/vue-select.css'
import { computed } from 'vue'
import Icon from '/@/components/UI/Icon.vue'

interface Props {
modelValue: string
options: string[]
searchable?: boolean
}

const props = defineProps<Props>()

const emit = defineEmits<{
(e: 'update:modelValue', value: string): void
}>()

const value = computed({
get: () => props.modelValue,
set: v => emit('update:modelValue', v)
})
</script>

<template>
<v-select
v-model="value"
:options="options"
:clearable="false"
:class="$style.select"
:searchable="searchable"
>
<template #option="{ label }">
<div :class="$style.item">
<icon
v-if="value === label"
name="mdi:tick-circle-outline"
:class="$style.icon"
/>
<p :class="$style.label">{{ label }}</p>
</div>
</template>
</v-select>
</template>

<style lang="scss" module>
Copy link
Contributor

Choose a reason for hiding this comment

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

選択したときの選択した感と、カーソル当てたときの検索できる感があんまりない気がするのでcursorを選択肢をホバーしたときにpointer、selectbox自体にカーソル当てたときにtextにするのがいい気がします(これデフォルトでなってた気がするんですけどどこかで消してますっけ)

Copy link
Member Author

Choose a reason for hiding this comment

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

良さそうなのでやっておきます○

(デフォルトで

[aria-controls] {
  cursor: pointer;
}

になってて、これがまずそう?)

.item {
display: grid;
grid-template-columns: 24px 1fr;
gap: 8px;
.icon {
color: $color-primary;
}
.label {
grid-column: 2;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

align-items: center;ほしいです

Copy link
Member Author

@toshi-pono toshi-pono Jan 2, 2023

Choose a reason for hiding this comment

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

どの部分を指してますか?(Homepageとかの文字列が入ってくるlabelの部分ですか?)
勘違いしてました:pray: 解決しました


.select {
--vs-border-radius: 8px;
--vs-border-color: #{$color-primary};

// dropdown のスタイル
:global(.vs__dropdown-menu) {
margin-top: 8px;
border-top-style: solid;
border-radius: var(--vs-border-radius);
--vs-dropdown-option-padding: 4px 8px;

--vs-dropdown-option--active-bg: #{$color-background-dim};
--vs-dropdown-option--active-color: #{$color-text};
}

// combobox のスタイル
:global(.vs__dropdown-toggle) {
--vs-selected-color: #{$color-text};
border-color: $color-secondary;
border-radius: var(--vs-border-radius);

// combobox の右側のアイコン
--vs-actions-padding: 4px 8px 0 3px;
--vs-controls-color: #{$color-secondary-text};
}

// dropdown が開いているときの combobox のスタイル
&:global(.vs--open) {
:global(.vs__dropdown-toggle) {
border-color: var(--vs-border-color);
}

:global(.vs__selected) {
opacity: 1;
}
}
}
</style>
27 changes: 27 additions & 0 deletions src/components/UI/ServiceAccordion.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script lang="ts" setup>
import { computed } from 'vue'
import BaseSelect from '/@/components/UI/BaseSelect.vue'
import { services, serviceNameToType } from '/@/consts/services'
import { AccountType } from '/@/lib/apis'

const options = Array.from(services.values()).map(service => service.name)

interface Props {
modelValue: AccountType
}
const props = defineProps<Props>()

const emit = defineEmits<{
(e: 'update:modelValue', value: AccountType): void
}>()

const value = computed({
get: () => services.get(props.modelValue)?.name ?? '',
set: v =>
emit('update:modelValue', serviceNameToType(v) ?? AccountType.homepage)
})
</script>

<template>
<base-select v-model="value" :options="options" searchable />
Copy link
Contributor

Choose a reason for hiding this comment

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

optionsについてなんですけど、この前同じサービスに対して複数アカウントを登録できなくしたので、既に登録してあるサービスを除外したい感があります

Copy link
Member Author

Choose a reason for hiding this comment

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

登録済みのサービスはdisableな見た目にして選択できない感じですかね?

(もしくは、完全に表示しない)

Copy link
Contributor

Choose a reason for hiding this comment

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

完全に表示しないのを想定していましたが、いい感じのUIにできそうであればdisableな見た目にした方が分かりやすいかもです🤨

</template>
7 changes: 7 additions & 0 deletions src/consts/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,10 @@ export const services: ServiceRecord = new Map([
export const serviceArray: ServiceWithType[] = Array.from(
services.entries()
).map(([type, service]) => ({ ...service, type }))

export const serviceNameToType = (name: string): AccountType | undefined => {
const entry = Array.from(services).find(
([, service]) => service.name === name
)
return entry?.[0]
}