Skip to content

Commit

Permalink
add invalid to dropdown #133
Browse files Browse the repository at this point in the history
  • Loading branch information
atakantepe committed Feb 23, 2024
1 parent b66ee49 commit aa71914
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
8 changes: 4 additions & 4 deletions doc/dropdown/InvalidDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p>Invalid state style is added using the <i>p-invalid</i> class to indicate a failed validation.</p>
</DocSectionText>
<div class="card flex justify-center">
<Dropdown v-model="selectedCity" :options="cities" optionLabel="name" placeholder="Select a City" class="!border !border-red-300 !dark:border-red-400 w-full md:w-[14rem]" />
<Dropdown v-model="selectedCity" :options="cities" optionLabel="name" placeholder="Select a City" class="w-full md:w-[14rem]" invalid />
</div>
<DocSectionCode :code="code" />
</template>
Expand All @@ -22,12 +22,12 @@ export default {
],
code: {
basic: `
<Dropdown v-model="selectedCity" :options="cities" optionLabel="name" placeholder="Select a City" class="!border !border-red-300 !dark:border-red-400 w-full md:w-[14rem]" />
<Dropdown v-model="selectedCity" :options="cities" optionLabel="name" placeholder="Select a City" class="w-full md:w-[14rem]" invalid />
`,
options: `
<template>
<div class="card flex justify-center">
<Dropdown v-model="selectedCity" :options="cities" optionLabel="name" placeholder="Select a City" class="!border !border-red-300 !dark:border-red-400 w-full md:w-[14rem]" />
<Dropdown v-model="selectedCity" :options="cities" optionLabel="name" placeholder="Select a City" class="w-full md:w-[14rem]" invalid />
</div>
</template>
Expand All @@ -51,7 +51,7 @@ export default {
composition: `
<template>
<div class="card flex justify-center">
<Dropdown v-model="selectedCity" :options="cities" optionLabel="name" placeholder="Select a City" class="!border !border-red-300 !dark:border-red-400 w-full md:w-[14rem]" />
<Dropdown v-model="selectedCity" :options="cities" optionLabel="name" placeholder="Select a City" class="w-full md:w-[14rem]" invalid />
</div>
</template>
Expand Down
11 changes: 6 additions & 5 deletions pages/dropdown/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import FilterDoc from '@/doc/dropdown/FilterDoc.vue';
// import FloatLabelDoc from '@/doc/dropdown/FloatLabelDoc.vue';
import GroupDoc from '@/doc/dropdown/GroupDoc.vue';
import ImportDoc from '@/doc/dropdown/ImportDoc.vue';
import InvalidDoc from '@/doc/dropdown/InvalidDoc.vue';
import LazyVirtualScrollDoc from '@/doc/dropdown/LazyVirtualScrollDoc.vue';
import LoadingStateDoc from '@/doc/dropdown/LoadingStateDoc.vue';
import TemplateDoc from '@/doc/dropdown/TemplateDoc.vue';
Expand Down Expand Up @@ -84,11 +85,11 @@ export default {
// label: 'Float Label',
// component: FloatLabelDoc
// },
// {
// id: 'invalid',
// label: 'Invalid',
// component: InvalidDoc
// },
{
id: 'invalid',
label: 'Invalid',
component: InvalidDoc
},
{
id: 'disabled',
label: 'Disabled',
Expand Down
8 changes: 6 additions & 2 deletions presets/lara/dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ export default {

// Color and Background
'bg-surface-0 dark:bg-surface-900',
'border border-surface-300 dark:border-surface-700',
'border',
{ 'border-surface-300 dark:border-surface-600': !props.invalid },

// Invalid State
{ 'border-red-500 dark:border-red-400': props.invalid },

// Transitions
'transition-all',
'duration-200',

// States
'hover:border-primary-500 dark:hover:border-primary-300',
{ 'hover:border-primary-500 dark:hover:border-primary-300': !props.invalid },
{ 'outline-none outline-offset-0 ring ring-primary-400/50 dark:ring-primary-300/50': state.focused },

// Misc
Expand Down
7 changes: 6 additions & 1 deletion presets/wind/dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ export default {
'bg-surface-0 dark:bg-surface-900',

// States
{ 'ring-1 ring-inset ring-surface-300 dark:ring-surface-700': !state.focused, 'ring-2 ring-inset ring-primary-500 dark:ring-primary-400': state.focused },
{ 'ring-1 ring-inset': !state.focused, 'ring-2 ring-inset ring-primary-500 dark:ring-primary-400': state.focused },

{ 'ring-surface-300 dark:ring-surface-600': !props.invalid && !state.focused },

// Invalid State
{ 'ring-red-500 dark:ring-red-400': props.invalid && !state.focused },

// Misc
'cursor-default',
Expand Down

0 comments on commit aa71914

Please sign in to comment.