Skip to content

Commit

Permalink
feat: add v-model
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnixon committed Jul 31, 2023
1 parent 2e55955 commit 7e8e8ae
Showing 1 changed file with 72 additions and 8 deletions.
80 changes: 72 additions & 8 deletions src/components/CvSearch/CvSearch.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { sbCompPrefix } from '../../global/storybook-utils';
import { SEARCH_SIZES } from './index';
import { action } from '@storybook/addon-actions';
import { ref } from 'vue';
const myValue = ref('searching');

const myValue = ref('searching galaxies');

<Meta title={`${sbCompPrefix}/CvSearch`} component={CvSearch} />

Expand All @@ -26,14 +25,14 @@ export const Template = args => ({
formItem: args.formItem,
expandable: args.expandable,
value: args.value,
myValue: myValue,
onInput: action('input'),
onVModel: action('update:value'),
};
},
template: args.template,
});
const defaultTemplate = `
<cv-search
<cv-search
:light="light"
:label="label"
:placeholder="placeholder"
Expand All @@ -44,16 +43,39 @@ const defaultTemplate = `
:form-item="formItem"
:aria-label="ariaLabel"
:clear-aria-label="clearArialabel"
@input="onInput"
>
</cv-search>
`;
const vModelTemplate = `
<div>
<cv-search
v-model:value="myValue"
:light="light"
:label="label"
:placeholder="placeholder"
:disabled="disabled"
:size="size"
:expandable="expandable"
:form-item="formItem"
:aria-label="ariaLabel"
:clear-aria-label="clearArialabel"
>
</cv-search>
<div style="margin-top:1rem; background-color: #888888; padding:1rem">
<div style="padding:1rem">v-model value: {{ myValue }}</div>
<input type="search" v-model="myValue"/>
</div>
</div>
`;

# CvSearch

Migration notes:

- The `v-model` is different in Vue 3 than Vue 2.If you specify it you will see an error deprecation message in the log.
- The `v-model` is different in Vue 3 than Vue 2. If you specify it you will see an error deprecation message in the log.
Please use `v-model:value=something` instead.
- The "toolbar" mode is removed in this version. Please use the `expandable` mode instead.

<Canvas>
<Story
Expand All @@ -67,7 +89,8 @@ Migration notes:
'update:modelValue',
'update:value',
'large',
'small','toolbarAriaLabel',
'small',
'toolbarAriaLabel',
'kind',
],
},
Expand All @@ -77,7 +100,7 @@ Migration notes:
template: defaultTemplate,
light: false,
disabled: false,
placeholder: 'JWST: search for light from the first stars'
placeholder: 'JWST: search for light from the first stars',
}}
argTypes={{
light: {
Expand All @@ -99,5 +122,46 @@ Migration notes:
# v-model

- The `v-model` is different in Vue 3 than Vue 2.If you specify it you will see an error deprecation message in the log.
Please use `v-model:value=something` instead.
Please use `v-model:value=something` instead.

<Canvas>
<Story
name="v-model"
parameters={{
controls: {
exclude: [
'input',
'modelValue',
'template',
'update:modelValue',
'update:value',
'large',
'small',
'toolbarAriaLabel',
'kind',
],
},
docs: { source: { code: vModelTemplate } },
}}
args={{
template: vModelTemplate,
light: false,
disabled: false,
placeholder: 'JWST: search for light from the first stars',
}}
argTypes={{
light: {
description: '`true` to use the light version.',
table: { category: 'props', defaultValue: { summary: false } },
},
size: {
control: 'select',
default: 'xl',
options: SEARCH_SIZES,
table: { defaultValue: { summary: 'xl' } },
},
}}
>
{Template.bind({})}
</Story>
</Canvas>

0 comments on commit 7e8e8ae

Please sign in to comment.