Skip to content

Commit

Permalink
docs: textarea (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesytim authored Sep 20, 2022
1 parent c640616 commit 8b23a47
Show file tree
Hide file tree
Showing 4 changed files with 238 additions and 2 deletions.
2 changes: 2 additions & 0 deletions vuepress-docs/docs/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default defineUserConfig<DefaultThemeOptions, ViteBundlerOptions>({
'/components/QSwitch.md',
'/components/QTabs.md',
'/components/QTag.md',
'/components/QTextarea.md',
'/components/QUpload.md'
]
},
Expand Down Expand Up @@ -80,6 +81,7 @@ export default defineUserConfig<DefaultThemeOptions, ViteBundlerOptions>({
'/components/QSwitch.md',
'/components/QTabs.md',
'/components/QTag.md',
'/components/QTextarea.md',
'/components/QUpload.md'
]
}
Expand Down
75 changes: 75 additions & 0 deletions vuepress-docs/docs/.vuepress/public/QTextarea/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<html>
<head>
<meta charset="UTF-8" />
<!-- import CSS -->
<link
rel="stylesheet"
href="https://unpkg.com/@qvant/qui-max/dist/style.css"
/>
</head>

<body>
<div id="app">
<div class="block">
<q-row>
<q-col cols="6">
<p>Default</p>
<q-textarea
v-model="value"
placeholder="Input Text"
></q-textarea>
<p>Autosize: "{ minRows: 6, maxRows: 8 }"</p>
<q-textarea
v-model="value2"
:autosize="{ minRows: 6, maxRows: 8 }"
placeholder="Input Text"
>
</q-textarea>
</q-col>
<q-col cols="6">
<p>Disabled</p>
<q-textarea
v-model="value3"
disabled
></q-textarea>
<p>Show symbol limit</p>
<q-textarea
v-model="value4"
:show-symbol-limit="true"
maxlength="100"
placeholder="Input 100 symbols max"
></q-textarea>
</q-col>
</q-row>
</div>
</div>
</body>
<!-- import Vue before Qui -->
<script src="https://unpkg.com/vue@latest"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/@qvant/qui-max@latest"></script>
<script>
const app = Vue.createApp({
setup() {
const value = Vue.ref('');
const value2 = Vue.ref('');
const value3 = Vue.ref('');
const value4 = Vue.ref('');
return {
value,
value2,
value3,
value4
};
}
});

app.use(QuiMax.default);
app.mount('#app');
</script>
<style>
.block {
margin: 20px;
}
</style>
</html>
4 changes: 2 additions & 2 deletions vuepress-docs/docs/components/QInput.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ Binding value.

### disabled

- Type: `String`
- Default: `null`
- Type: `Boolean`
- Default: `false`

Whether input is disabled.

Expand Down
159 changes: 159 additions & 0 deletions vuepress-docs/docs/components/QTextarea.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# QTextarea 📝

The `QTextarea` is a component that is used to get user input in a multi-line text field.

## Examples

<iframe height="360" style="width: 100%;" scrolling="no" frameborder="no" src="/QTextarea/main.html"></iframe>

Template:

```vue
<template>
<q-textarea v-model="value" />
</template>
```

Component instance:

```js
export default {
setup() {
const value = ref('');
return {
value
};
}
};
```

## Props

### modelValue

- Type: `String`
- Default: `null`

Binding value.

### disabled

- Type: `Boolean`
- Default: `false`

Whether textarea is disabled.

```vue {3}
<template>
<q-textarea
v-model="value"
disabled
/>
</template>
```

### autosize

- Type: `Boolean` | `Object`
- Default: `true`

Whether textarea has an adaptive height. Helps to control min and max rows count.

```ts
type QTextareaPropAutosize = Nullable<
boolean | { minRows: number; maxRows: number }
>;
```

```vue {4}
<template>
<q-textarea
v-model="value"
:autosize="{ minRows: 6, maxRows: 8 }"
/>
</template>
```

### resize

- Type: `'vertical' | 'horizontal' | 'both' | 'none'`
- Default: `'vertical'`

Control the resizability. As native `resize` attribute.

::: tip NOTE
The `resize` works only if `autosize` is `false`:
:::

```vue {4,5}
<template>
<q-textarea
v-model="value"
resize="horizontal"
:autosize="false"
>
</template>
```

### showSymbolLimit

- Type: `Boolean`
- Default: `false`

Shows the symbol's counter.

::: tip NOTE
The `maxlength` attribute is required:
:::

```vue {4,5}
<template>
<q-textarea
v-model="value"
maxlength="100"
show-symbol-limit
>
</template>
```

### validateEvent

- type `boolean`
- Default `false`

If textarea wrapped in `QFormItem`, prop `validateEvent` defines if textarea `change` event will be validated immediately

## Attributes

`QTextarea` support native `textarea` attrubutes:

- placeholder
- maxlength
- autocomplete
- readonly

.. and [others](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attributes)

p.s `textarea` has a lot of attributes, we can't claim `QTextarea` well supported all of them, but mostly true. Feel free to fix and contribute bugs [here](https://github.com/Qvant-lab/qui-max)

## Events

### update:modelValue

Triggers when the model is being updated.

### change

Alias for [update:modelValue](#update-modelvalue)

### input

Triggers when native input event fires.

### focus

Triggers when input gets focus.

### blur

Triggers when input gets blur.

0 comments on commit 8b23a47

Please sign in to comment.