-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
173 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Rate 评分 | ||
|
||
## 基础使用 | ||
|
||
<table class="min-w-full divide-y divide-gray-300"> | ||
<thead class="bg-gray-50"> | ||
<tr> | ||
<th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Name</th> | ||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Title</th> | ||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Email</th> | ||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Role</th> | ||
<th scope="col" class="relative py-3.5 pl-3 pr-4 sm:pr-6"> | ||
<span class="sr-only">Edit</span> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody class="divide-y divide-gray-200 bg-white"> | ||
<tr v-for="person in people" :key="person.email"> | ||
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">{{ person.name }}</td> | ||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{ person.title }}</td> | ||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{ person.email }}</td> | ||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{ person.role }}</td> | ||
<td class="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6"> | ||
<a href="#" class="text-indigo-600 hover:text-indigo-900" | ||
>Edit<span class="sr-only">, {{ person.name }}</span></a | ||
> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
```vue | ||
``` | ||
|
||
## 属性 | ||
|
||
| 名称 | 类型 | 可选值 | 默认值 | 说明 | | ||
| -------------------- | ------- | ------ | ------ | ------ | | ||
| modelValue / v-model | number | - | 0 | 绑定值 | | ||
| disabled | boolean | - | false | 禁用 | | ||
|
||
## 事件 | ||
|
||
| 名称 | 说明 | 参数 | | ||
| ------ | -------------- | -------------- | | ||
| change | 分数改变时触发 | (value:number) | | ||
|
||
<script lang="ts" setup> | ||
import { ref } from "vue"; | ||
const people = [ | ||
{ name: 'Lindsay Walton', title: 'Front-end Developer', email: 'lindsay.walton@example.com', role: 'Member' }, | ||
{ name: 'Lindsay Walton', title: 'Front-end Developer', email: 'lindsay.walton@example.com', role: 'Member' }, | ||
{ name: 'Lindsay Walton', title: 'Front-end Developer', email: 'lindsay.walton@example.com', role: 'Member' }, | ||
{ name: 'Lindsay Walton', title: 'Front-end Developer', email: 'lindsay.walton@example.com', role: 'Member' }, | ||
{ name: 'Lindsay Walton', title: 'Front-end Developer', email: 'lindsay.walton@example.com', role: 'Member' }, | ||
] | ||
|
||
</script> | ||
|
||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import _Table from "./src/rate.vue"; | ||
import { withInstall } from "atomu-utils"; | ||
|
||
const Table = withInstall(_Table); | ||
|
||
export default Table; | ||
|
||
export * from "./src/table"; | ||
|
||
declare module "vue" { | ||
export interface GlobalComponents { | ||
ATable: typeof Table; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ExtractPropTypes, PropType } from 'vue'; | ||
|
||
export const tableProps = { | ||
modelValue: { | ||
type: Number, | ||
default: 0 | ||
}, | ||
disabled: { | ||
type: Boolean, | ||
default: false | ||
} | ||
} as const; | ||
|
||
export type TableProps = ExtractPropTypes<typeof tableProps>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<template> | ||
<div class="a-rate" :class="{ 'is-disabled': disabled }"> | ||
<span | ||
v-for="(item, index) in 5" | ||
:key="index" | ||
class="a-rate__item" | ||
:class="'a-rate__item--' + (currentValue >= item ? 'on' : 'off')" | ||
@mousemove="setCurrentValue(item)" | ||
@mouseleave="resetCurrentValue" | ||
@click="selectValue(item)" | ||
> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
viewBox="0 0 576 512" | ||
> | ||
<path | ||
d="M259.3 17.8L194 150.2L47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103l-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5l105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2L316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z" | ||
fill="currentColor" | ||
></path> | ||
</svg> | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, computed } from 'vue'; | ||
import { tableProps } from './table'; | ||
const props = defineProps(tableProps); | ||
const emit = defineEmits(['update:modelValue', 'change']); | ||
let currentValue = ref(props.modelValue); | ||
const setCurrentValue = (val: number) => { | ||
if (props.disabled) return; | ||
currentValue.value = val; | ||
}; | ||
const resetCurrentValue = () => { | ||
if (props.disabled) return; | ||
currentValue.value = props.modelValue; | ||
}; | ||
const selectValue = (val: number) => { | ||
if (props.disabled) return; | ||
emit('update:modelValue', val); | ||
emit('change', val); | ||
}; | ||
</script> | ||
|
||
<script lang="ts"> | ||
export default { | ||
name: 'ATable', | ||
inheritAttrs: false | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters