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

docs: add tag doc #328

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vuepress-docs/docs/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export default defineUserConfig<DefaultThemeOptions, ViteBundlerOptions>({
'/components/QScrollbar.md',
'/components/QSelect.md',
'/components/QSlider.md',
'/components/QSelect.md',
'/components/QSwitch.md',
'/components/QTabs.md',
'/components/QTag.md',
'/components/QUpload.md'
]
},
Expand Down Expand Up @@ -77,9 +77,9 @@ export default defineUserConfig<DefaultThemeOptions, ViteBundlerOptions>({
'/components/QScrollbar.md',
'/components/QSelect.md',
'/components/QSlider.md',
'/components/QSelect.md',
'/components/QSwitch.md',
'/components/QTabs.md',
'/components/QTag.md',
'/components/QUpload.md'
]
}
Expand Down
79 changes: 79 additions & 0 deletions vuepress-docs/docs/.vuepress/public/QTag/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<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">
<span>Default:</span>
<div>
<q-tag
v-for="tag in tags"
:key="tag"
@close="handleCloseClick(tag)"
>
{{ tag }}
</q-tag>
</div>
</div>
<div class="block">
<span>Closable:</span>
<div>
<q-tag
v-for="tag in tagsClosable"
:key="tag"
:closable="true"
@close="handleCloseClick(tag)"
>
{{ tag }}
</q-tag>
</div>
</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 tags = Vue.ref(['Tag 1', 'Tag 2', 'Tag 3', 'Tag 4', 'Tag 5']);
const tagsClosable = Vue.ref([
'Tag 1',
'Tag 2',
'Tag 3',
'Tag 4',
'Tag 5'
]);

const handleCloseClick = clickedTag => {
console.log('Close tag clicked');
tagsClosable.value = tagsClosable.value.filter(
tag => tag !== clickedTag
);
};

return { tags, tagsClosable, handleCloseClick };
}
});

app.use(QuiMax.default);
app.mount('#app');
</script>
<style>
.block {
display: flex;
flex-direction: column;
justify-content: center;
width: 100%;
padding: 25px 40px 10px;
}
</style>
</html>
61 changes: 61 additions & 0 deletions vuepress-docs/docs/components/QTag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# QTag #️⃣

`QTag` component is used for items that need to be labeled, categorized, or organized using keywords that describe them.
Also `QTag` tag is being used in `QSelect` | `QCascader`

## Examples

All kind of types:

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

Template:

```vue
<template>
<q-tag
v-for="tag in tags"
:key="tag"
@close="handleCloseClick(tag)"
>
{{ tag }}
</q-tag>
</template>
```

Component instance:

```js
export default {
setup() {
const tags = ref(['Tag 1', 'Tag 2', 'Tag 3', 'Tag 4', 'Tag 5']);

const handleCloseClick = clickedTag => {
tags.value = tags.value.filter(tag => tag !== clickedTag);
};

return { tags, handleCloseClick };
}
};
```

## Props

### closable

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

Whether is close button shown.

## Events

### close

Triggers when the close button is clicked.

## Slots

### default

Provide custom content into `QTag`.