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

fix(VMultiSelect): fix label position and fix error style #46

Merged
merged 8 commits into from
Nov 29, 2022
23 changes: 21 additions & 2 deletions docs/components/multi-select.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,35 @@ None
You can also install the `Multi Select` component individually via `@gits-id/multi-select` package:

```bash
yarn install @gits-id/multi-select
npm i @gits-id/multi-select
```

```vue
<script setup lang="ts">
import {ref} from 'vue';
import VMultiSelect from '@gits-id/multi-select';
import '@gits-id/multi-select/dist/style.css';

const items = ref([
{
text: 'Item 1',
value: 1,
},
{
text: 'Item 2',
value: 2,
},
{
text: 'Item 2',
value: 2,
},
]);

const selected = ref();
</script>

<template>
<VMultiSelect :items="items" />
<VMultiSelect v-model="selected" :items="items" />
</template>
```

Expand Down
30 changes: 23 additions & 7 deletions packages/multi-select/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GITS Multi Select Component
# Multi Select

> Reusable Multi Select Component
Vue Multi Select Component.

## Installation

Expand All @@ -26,20 +26,36 @@ pnpm i @gits-id/multi-select

```vue
<script setup lang="ts">
// import styles
import '@gits-id/multi-select/dist/style.css';
// import component
import {ref} from 'vue';
import VMultiSelect from '@gits-id/multi-select';
import '@gits-id/multi-select/dist/style.css';

const items = ref([
{
text: 'Item 1',
value: 1,
},
{
text: 'Item 2',
value: 2,
},
{
text: 'Item 2',
value: 2,
},
]);

const selected = ref();
</script>

<template>
<VMultiSelect />
<VMultiSelect v-model="selected" :items="items" />
</template>
```

## Documentation

View `VMultiSelect` documentation [here](https://gits-ui.web.app/?path=/story/components-multi-select--default).
View full documentation [here](https://gits-ui.web.app/?path=/story/components-multi-select--default).

## License

Expand Down
37 changes: 24 additions & 13 deletions packages/multi-select/src/VMultiSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -370,23 +370,30 @@ watch(
</script>

<template>
<div ref="target" class="v-multi-select" v-bind="$attrs">
<label
v-if="label"
:for="id || name"
class="v-multi-select-label"
:class="labelClass"
>
{{ label }}
</label>
<div
ref="target"
class="v-multi-select"
:class="{
'v-multi-select--error': !!errorMessage || error,
}"
v-bind="$attrs"
>
<div>
<label
v-if="label"
:for="id || name"
class="v-multi-select-label"
:class="labelClass"
>
{{ label }}
</label>
<div class="v-multi-select-panel">
<div
class="v-multi-select-input"
:class="[
error || errorMessage
? `v-multi-select-error`
: 'v-multi-select-normal',
{
'v-multi-select-normal': error || !!errorMessage,
},
wrapperClass,
]"
@click="isOpen = true"
Expand Down Expand Up @@ -543,7 +550,7 @@ watch(
</div>
<ErrorMessage
v-if="errorMessages.length"
class="text-error-600 text-sm"
class="text-error-500 text-sm"
:name="name"
/>
<div v-else-if="errorMessage" :class="errorClass">
Expand Down Expand Up @@ -600,6 +607,10 @@ watch(
@apply relative;
}

.v-multi-select--error {
border-color: var(--v-multi-select-error-border-color);
}

.v-multi-select-error {
border: 1px solid var(--v-multi-select-error-border-color);

Expand Down