u
This commit is contained in:
1 parent
b547c12390
commit
c280cbf961
18 files changed
+481
-170
No files matched your search
+21
-1
@@ -1,4 +1,24 @@
|
|||||||
{
|
{
|
||||||
|
"Vue3 SFC with SCSS": {
|
||||||
|
"prefix": "v3",
|
||||||
|
"scope": "vue",
|
||||||
|
"body": [
|
||||||
|
"<script setup lang=\"ts\">",
|
||||||
|
"",
|
||||||
|
"</script>",
|
||||||
|
"",
|
||||||
|
"<template>",
|
||||||
|
" <div>",
|
||||||
|
" ${1:content}",
|
||||||
|
" </div>",
|
||||||
|
"</template>",
|
||||||
|
"",
|
||||||
|
"<style lang=\"scss\" scoped>",
|
||||||
|
"${2}",
|
||||||
|
"</style>"
|
||||||
|
],
|
||||||
|
"description": "Vue 3 SFC template with SCSS (script setup, TypeScript)"
|
||||||
|
},
|
||||||
"Print AoDesignComponent TSX": {
|
"Print AoDesignComponent TSX": {
|
||||||
"scope": "typescriptreact",
|
"scope": "typescriptreact",
|
||||||
"prefix": "atsx",
|
"prefix": "atsx",
|
||||||
@@ -35,5 +55,5 @@
|
|||||||
"}"
|
"}"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10,6 +10,10 @@
|
|||||||
"*": ["./src/*"]
|
"*": ["./src/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"files": [
|
||||||
|
"src/**/*.scss",
|
||||||
|
"src/**/*.ts"
|
||||||
|
],
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@iconify/vue": "5.0.0",
|
"@iconify/vue": "5.0.0",
|
||||||
"vue": "^3.3.0"
|
"vue": "^3.3.0"
|
||||||
|
|||||||
@@ -84,3 +84,9 @@ $shadow-surface: var(--ao-shadow-surface);
|
|||||||
$shadow-popup: var(--ao-shadow-popup);
|
$shadow-popup: var(--ao-shadow-popup);
|
||||||
// 上层投影(警示/弹窗)使用的组件包括:全局提示 / 消息通知
|
// 上层投影(警示/弹窗)使用的组件包括:全局提示 / 消息通知
|
||||||
$shadow-overlay: var(--ao-shadow-overlay);
|
$shadow-overlay: var(--ao-shadow-overlay);
|
||||||
|
|
||||||
|
// 内投影
|
||||||
|
$shadow-inset-top: var(--ao-shadow-inset-top);
|
||||||
|
$shadow-inset-right: var(--ao-shadow-inset-right);
|
||||||
|
$shadow-inset-bottom: var(--ao-shadow-inset-bottom);
|
||||||
|
$shadow-inset-left: var(--ao-shadow-inset-left);
|
||||||
@@ -1 +1,2 @@
|
|||||||
@use './theme/index.scss' as *;
|
@use './theme/index.scss' as *;
|
||||||
|
|
||||||
@@ -63,4 +63,10 @@
|
|||||||
--ao-shadow-popup: 0 8px 10px rgba(0, 0, 0, 12%), 0 3px 14px rgba(0, 0, 0, 10%), 0 5px 5px rgba(0, 0, 0, 16%);
|
--ao-shadow-popup: 0 8px 10px rgba(0, 0, 0, 12%), 0 3px 14px rgba(0, 0, 0, 10%), 0 5px 5px rgba(0, 0, 0, 16%);
|
||||||
// 上层投影(警示/弹窗)使用的组件包括:全局提示 / 消息通知
|
// 上层投影(警示/弹窗)使用的组件包括:全局提示 / 消息通知
|
||||||
--ao-shadow-overlay: 0 16px 24px rgba(0, 0, 0, 14%), 0 6px 30px rgba(0, 0, 0, 12%), 0 8px 10px rgba(0, 0, 0, 20%);
|
--ao-shadow-overlay: 0 16px 24px rgba(0, 0, 0, 14%), 0 6px 30px rgba(0, 0, 0, 12%), 0 8px 10px rgba(0, 0, 0, 20%);
|
||||||
|
|
||||||
|
// 内投影
|
||||||
|
--ao-shadow-inset-top: inset 0 0.5px 0 #5e5e5e;
|
||||||
|
--ao-shadow-inset-right: inset 0.5px 0 0 #5e5e5e;
|
||||||
|
--ao-shadow-inset-bottom: inset 0 -0.5px 0 #5e5e5e;
|
||||||
|
--ao-shadow-inset-left: inset -0.5px 0 0 #5e5e5e;
|
||||||
}
|
}
|
||||||
@@ -66,4 +66,10 @@
|
|||||||
// 上层投影(警示/弹窗)使用的组件包括:全局提示 / 消息通知
|
// 上层投影(警示/弹窗)使用的组件包括:全局提示 / 消息通知
|
||||||
--ao-shadow-overlay:
|
--ao-shadow-overlay:
|
||||||
0 6px 30px 5px rgba(0, 0, 0, 5%), 0 16px 24px 2px rgba(0, 0, 0, 4%), 0 8px 10px -5px rgba(0, 0, 0, 8%);
|
0 6px 30px 5px rgba(0, 0, 0, 5%), 0 16px 24px 2px rgba(0, 0, 0, 4%), 0 8px 10px -5px rgba(0, 0, 0, 8%);
|
||||||
|
|
||||||
|
// 内投影
|
||||||
|
--ao-shadow-inset-top: inset 0 0.5px 0 #dcdcdc;
|
||||||
|
--ao-shadow-inset-right: inset 0.5px 0 0 #dcdcdc;
|
||||||
|
--ao-shadow-inset-bottom: inset 0 -0.5px 0 #dcdcdc;
|
||||||
|
--ao-shadow-inset-left: inset -0.5px 0 0 #dcdcdc;
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { computed, defineComponent } from 'vue'
|
import { computed, defineComponent } from 'vue'
|
||||||
import { getPrefixCls } from '../_utils/getPrefixCls'
|
import { getPrefixCls } from '../_utils/getPrefixCls'
|
||||||
import Icon from '../icon'
|
import Icon from '../icon'
|
||||||
import './index.scss'
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Button',
|
name: 'Button',
|
||||||
|
|||||||
@@ -6,6 +6,12 @@ $icon-prefix: #{$prefix}-icon;
|
|||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
width: 1em;
|
||||||
|
height: 1em;
|
||||||
|
svg {
|
||||||
|
width: 1em;
|
||||||
|
height: 1em;
|
||||||
|
}
|
||||||
&-spin {
|
&-spin {
|
||||||
animation: spin 1s linear infinite;
|
animation: spin 1s linear infinite;
|
||||||
--rotate-angle: 360deg;
|
--rotate-angle: 360deg;
|
||||||
|
|||||||
@@ -2,30 +2,39 @@ import type { PropType } from 'vue'
|
|||||||
import { Icon } from '@iconify/vue'
|
import { Icon } from '@iconify/vue'
|
||||||
import { defineComponent } from 'vue'
|
import { defineComponent } from 'vue'
|
||||||
import { getPrefixCls } from '../_utils/getPrefixCls'
|
import { getPrefixCls } from '../_utils/getPrefixCls'
|
||||||
import './index.scss'
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Icon',
|
name: 'Icon',
|
||||||
props: {
|
props: {
|
||||||
icon: { type: String as PropType<string>, required: true },
|
icon: { type: String as PropType<string>, required: true },
|
||||||
size: { type: Number, default: 16 },
|
size: { type: Number },
|
||||||
color: { type: String, default: 'currentColor' },
|
color: { type: String, default: 'currentColor' },
|
||||||
spin: { type: Boolean, default: false },
|
spin: { type: Boolean, default: false },
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props, { slots }) {
|
||||||
const prefixCls = getPrefixCls('icon')
|
const prefixCls = getPrefixCls('icon')
|
||||||
|
const fontStyle = {
|
||||||
|
...(props.size ? { fontSize: `${props.size}px` } : {}), // size 存在才设置
|
||||||
|
verticalAlign: 'middle',
|
||||||
|
}
|
||||||
return () => (
|
return () => (
|
||||||
<i
|
<i
|
||||||
class={[prefixCls, props.spin && `${prefixCls}-spin`]}
|
class={[prefixCls, props.spin && `${prefixCls}-spin`]}
|
||||||
|
style={fontStyle}
|
||||||
>
|
>
|
||||||
|
{slots.default
|
||||||
|
? (
|
||||||
|
slots.default()
|
||||||
|
)
|
||||||
|
: props.icon
|
||||||
|
? (
|
||||||
<Icon
|
<Icon
|
||||||
icon={props.icon}
|
icon={props.icon}
|
||||||
width={props.size}
|
|
||||||
height={props.size}
|
|
||||||
color={props.color}
|
color={props.color}
|
||||||
style={{ verticalAlign: 'middle' }}
|
style={{ verticalAlign: 'middle' }}
|
||||||
/>
|
/>
|
||||||
|
)
|
||||||
|
: null}
|
||||||
</i>
|
</i>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,5 +4,6 @@
|
|||||||
@use './input/index.scss' as *;
|
@use './input/index.scss' as *;
|
||||||
@use './textarea/index.scss' as *;
|
@use './textarea/index.scss' as *;
|
||||||
@use './group/index.scss' as *;
|
@use './group/index.scss' as *;
|
||||||
@use "./popup/index.scss" as *;
|
@use './popup/index.scss' as *;
|
||||||
|
@use './icon/index.scss' as *;
|
||||||
|
@use './message/index.scss' as *;
|
||||||
@@ -3,6 +3,8 @@ import type { App, Component } from 'vue'
|
|||||||
|
|
||||||
import * as comps from './components'
|
import * as comps from './components'
|
||||||
|
|
||||||
|
import { useMessage } from './message'
|
||||||
|
|
||||||
// 按需导出组件(可单独 import)
|
// 按需导出组件(可单独 import)
|
||||||
export * from './components'
|
export * from './components'
|
||||||
|
|
||||||
@@ -13,7 +15,7 @@ const allComponents = Object.values(comps).filter(
|
|||||||
|
|
||||||
export interface AoDesignOptions {
|
export interface AoDesignOptions {
|
||||||
prefix?: string
|
prefix?: string
|
||||||
components?: Component[] // 按需注册时传入需要注册的组件
|
components?: Component[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const AoDesign = {
|
const AoDesign = {
|
||||||
@@ -38,4 +40,4 @@ const AoDesign = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AoDesign
|
export { AoDesign, useMessage }
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
@use '../_styles/_variables.scss' as *;
|
||||||
|
@use 'sass:color';
|
||||||
|
|
||||||
|
$message-prefix: #{$prefix}-message;
|
||||||
|
|
||||||
|
.#{$message-prefix} {
|
||||||
|
&-wrapper {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 6000;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
&-item {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
outline: 0;
|
||||||
|
width: fit-content;
|
||||||
|
vertical-align: middle;
|
||||||
|
border-radius: $border-radius;
|
||||||
|
padding: 6px 12px;
|
||||||
|
background-color: $bg-color-container;
|
||||||
|
color: $text-color-base;
|
||||||
|
box-shadow: $shadow-overlay;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-family: 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||||
|
}
|
||||||
|
&-content {
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
&-icon {
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-close {
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin-left: 6px;
|
||||||
|
color: $text-color-assist;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
&:hover {
|
||||||
|
background-color: $default-color-hover;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-info {
|
||||||
|
color: $primary-color;
|
||||||
|
}
|
||||||
|
&-success {
|
||||||
|
color: $success-color;
|
||||||
|
}
|
||||||
|
&-warning {
|
||||||
|
color: $warning-color;
|
||||||
|
}
|
||||||
|
&-error {
|
||||||
|
color: $danger-color;
|
||||||
|
}
|
||||||
|
&-loading {
|
||||||
|
color: $primary-color;
|
||||||
|
}
|
||||||
|
&-placement {
|
||||||
|
&-top {
|
||||||
|
top: 20px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
&-bottom {
|
||||||
|
bottom: 20px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
flex-direction: column-reverse;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
&-left {
|
||||||
|
top: 50%;
|
||||||
|
left: 20px;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
&-right {
|
||||||
|
top: 50%;
|
||||||
|
right: 20px;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 组合方向
|
||||||
|
&-top-start {
|
||||||
|
top: 20px;
|
||||||
|
left: 20px;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
&-top-end {
|
||||||
|
top: 20px;
|
||||||
|
right: 20px;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
&-bottom-start {
|
||||||
|
bottom: 20px;
|
||||||
|
left: 20px;
|
||||||
|
flex-direction: column-reverse;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
&-bottom-end {
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
flex-direction: column-reverse;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
&-center {
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,176 @@
|
|||||||
|
import { createApp, h } from 'vue'
|
||||||
|
import { getPrefixCls } from '../_utils/getPrefixCls'
|
||||||
|
import Icon from '../icon/index'
|
||||||
|
|
||||||
|
type Placement
|
||||||
|
= | 'top'
|
||||||
|
| 'bottom'
|
||||||
|
| 'left'
|
||||||
|
| 'right'
|
||||||
|
| 'top-start'
|
||||||
|
| 'top-end'
|
||||||
|
| 'bottom-start'
|
||||||
|
| 'bottom-end'
|
||||||
|
| 'center'
|
||||||
|
|
||||||
|
interface MessageOptions {
|
||||||
|
message: string
|
||||||
|
type?: 'info' | 'success' | 'warning' | 'error' | 'loading'
|
||||||
|
placement?: Placement
|
||||||
|
duration?: number
|
||||||
|
showClose?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MessageHandle {
|
||||||
|
close: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MessageFn {
|
||||||
|
(msg: string | MessageOptions): MessageHandle
|
||||||
|
info: (msg: string | MessageOptions) => MessageHandle
|
||||||
|
success: (msg: string | MessageOptions) => MessageHandle
|
||||||
|
warning: (msg: string | MessageOptions) => MessageHandle
|
||||||
|
error: (msg: string | MessageOptions) => MessageHandle
|
||||||
|
closeAll: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const prefixCls = getPrefixCls('message')
|
||||||
|
const containers: Partial<Record<Placement, HTMLElement>> = {}
|
||||||
|
const instances: MessageHandle[] = []
|
||||||
|
|
||||||
|
function getContainer(placement: Placement = 'top') {
|
||||||
|
if (!containers[placement]) {
|
||||||
|
const wrapper = document.createElement('div')
|
||||||
|
wrapper.className = `${prefixCls}-wrapper ${prefixCls}-placement-${placement}`
|
||||||
|
document.body.appendChild(wrapper)
|
||||||
|
containers[placement] = wrapper
|
||||||
|
}
|
||||||
|
return containers[placement]!
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTransform(placement: Placement, hidden: boolean) {
|
||||||
|
if (placement.startsWith('top'))
|
||||||
|
return hidden ? 'translateY(-10px)' : 'translateY(0)'
|
||||||
|
if (placement.startsWith('bottom'))
|
||||||
|
return hidden ? 'translateY(10px)' : 'translateY(0)'
|
||||||
|
if (placement.startsWith('left'))
|
||||||
|
return hidden ? 'translateX(-10px)' : 'translateX(0)'
|
||||||
|
if (placement.startsWith('right'))
|
||||||
|
return hidden ? 'translateX(10px)' : 'translateX(0)'
|
||||||
|
if (placement === 'center')
|
||||||
|
return hidden ? 'scale(0.8)' : 'scale(1)'
|
||||||
|
return hidden ? 'translateY(-10px)' : 'translateY(0)'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useMessage(): MessageFn {
|
||||||
|
const createMessage = (
|
||||||
|
msg: string | MessageOptions,
|
||||||
|
defaultType: 'info' | 'success' | 'warning' | 'error' | 'loading' = 'info',
|
||||||
|
): MessageHandle => {
|
||||||
|
const opts: MessageOptions = typeof msg === 'string'
|
||||||
|
? { message: msg, type: defaultType }
|
||||||
|
: { ...msg, type: msg.type || defaultType }
|
||||||
|
|
||||||
|
const { message, type, placement = 'top', duration = 3000 } = opts
|
||||||
|
const container = getContainer(placement)
|
||||||
|
|
||||||
|
let timer: number | undefined
|
||||||
|
|
||||||
|
const iconMap: Record<string, string> = {
|
||||||
|
success: 'ix:success-filled',
|
||||||
|
error: 'ix:error-filled',
|
||||||
|
warning: 'ix:warning-filled',
|
||||||
|
info: 'ix:info-filled',
|
||||||
|
loading: 'mingcute:loading-line',
|
||||||
|
}
|
||||||
|
|
||||||
|
let handle: MessageHandle
|
||||||
|
|
||||||
|
const app = createApp({
|
||||||
|
render() {
|
||||||
|
return h(
|
||||||
|
'div',
|
||||||
|
{
|
||||||
|
class: [`${prefixCls}-item`],
|
||||||
|
style: {
|
||||||
|
opacity: 0,
|
||||||
|
transform: getTransform(placement, true),
|
||||||
|
transition: 'all 0.3s ease-in-out',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
[
|
||||||
|
h(Icon, {
|
||||||
|
icon: iconMap[type ?? 'info'],
|
||||||
|
size: 20,
|
||||||
|
class: `${prefixCls}-icon ${prefixCls}-${type ?? 'info'}`,
|
||||||
|
spin: type === 'loading',
|
||||||
|
}),
|
||||||
|
h('span', { class: `${prefixCls}-content` }, message),
|
||||||
|
opts.showClose
|
||||||
|
? h(Icon, {
|
||||||
|
icon: 'ix:close',
|
||||||
|
size: 14,
|
||||||
|
class: `${prefixCls}-close`,
|
||||||
|
onClick: () => handle?.close?.(),
|
||||||
|
})
|
||||||
|
: null,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const vm = app.mount(document.createElement('div'))
|
||||||
|
container.appendChild(vm.$el)
|
||||||
|
|
||||||
|
// 出现动画
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
Object.assign(vm.$el.style, {
|
||||||
|
opacity: '1',
|
||||||
|
transform: getTransform(placement, false),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
handle = {
|
||||||
|
close: () => {
|
||||||
|
if (timer)
|
||||||
|
clearTimeout(timer)
|
||||||
|
|
||||||
|
Object.assign(vm.$el.style, {
|
||||||
|
opacity: '0',
|
||||||
|
transform: getTransform(placement, true),
|
||||||
|
})
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (container.contains(vm.$el))
|
||||||
|
container.removeChild(vm.$el)
|
||||||
|
app.unmount()
|
||||||
|
const index = instances.indexOf(handle)
|
||||||
|
if (index !== -1)
|
||||||
|
instances.splice(index, 1)
|
||||||
|
}, 300)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
instances.push(handle)
|
||||||
|
|
||||||
|
// 自动关闭
|
||||||
|
if (duration > 0) {
|
||||||
|
timer = window.setTimeout(() => {
|
||||||
|
handle.close()
|
||||||
|
}, duration)
|
||||||
|
}
|
||||||
|
|
||||||
|
return handle
|
||||||
|
}
|
||||||
|
|
||||||
|
const api = ((msg: string | MessageOptions) => createMessage(msg)) as MessageFn
|
||||||
|
api.info = msg => createMessage(msg, 'info')
|
||||||
|
api.success = msg => createMessage(msg, 'success')
|
||||||
|
api.warning = msg => createMessage(msg, 'warning')
|
||||||
|
api.error = msg => createMessage(msg, 'error')
|
||||||
|
api.closeAll = () => {
|
||||||
|
instances.slice().forEach(instance => instance.close())
|
||||||
|
}
|
||||||
|
|
||||||
|
return api
|
||||||
|
}
|
||||||
@@ -9,10 +9,11 @@ $popup-prefix: '#{$prefix}-popup';
|
|||||||
color: $text-color-base;
|
color: $text-color-base;
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
border-radius: 2px;
|
border-radius: $border-radius;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
box-shadow: $shadow-popup, $shadow-inset-top, $shadow-inset-right, $shadow-inset-bottom, $shadow-inset-left;
|
||||||
&-arrow {
|
&-arrow {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 8px;
|
width: 8px;
|
||||||
@@ -28,53 +29,38 @@ $popup-prefix: '#{$prefix}-popup';
|
|||||||
transform-origin: center;
|
transform-origin: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 上方弹出,阴影主方向靠下(轻微),边缘明显
|
|
||||||
&[data-popup-placement^='top'] {
|
|
||||||
box-shadow:
|
|
||||||
0 4px 8px rgba(0, 0, 0, 0.06),
|
|
||||||
0 0 4px rgba(0, 0, 0, 0.12); //
|
|
||||||
}
|
|
||||||
|
|
||||||
// 下方弹出,阴影主方向靠上,边缘明显
|
|
||||||
&[data-popup-placement^='bottom'] {
|
|
||||||
box-shadow:
|
|
||||||
0 -4px 8px rgba(0, 0, 0, 0.06),
|
|
||||||
0 0 4px rgba(0, 0, 0, 0.12);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 左侧弹出,阴影主方向靠右,边缘明显
|
|
||||||
&[data-popup-placement^='left'] {
|
|
||||||
box-shadow:
|
|
||||||
4px 0 8px rgba(0, 0, 0, 0.06),
|
|
||||||
0 0 4px rgba(0, 0, 0, 0.12);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 右侧弹出,阴影主方向靠左,边缘明显
|
|
||||||
&[data-popup-placement^='right'] {
|
|
||||||
box-shadow:
|
|
||||||
-4px 0 8px rgba(0, 0, 0, 0.06),
|
|
||||||
0 0 4px rgba(0, 0, 0, 0.12);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 上方弹出,箭头在底部
|
// 上方弹出,箭头在底部
|
||||||
&[data-popup-placement^='top'] > &-arrow {
|
&[data-popup-placement^='top'] > &-arrow {
|
||||||
bottom: -4px;
|
bottom: -4px;
|
||||||
}
|
}
|
||||||
|
&[data-popup-placement^='top'] > &-arrow::before {
|
||||||
|
box-shadow: $shadow-inset-left, $shadow-inset-bottom;
|
||||||
|
}
|
||||||
|
|
||||||
// 下方弹出,箭头在顶部
|
// 下方弹出,箭头在顶部
|
||||||
&[data-popup-placement^='bottom'] > &-arrow {
|
&[data-popup-placement^='bottom'] > &-arrow {
|
||||||
top: -4px;
|
top: -4px;
|
||||||
}
|
}
|
||||||
|
&[data-popup-placement^='bottom'] > &-arrow::before {
|
||||||
|
box-shadow: $shadow-inset-top, $shadow-inset-right;
|
||||||
|
}
|
||||||
|
|
||||||
// 左侧弹出,箭头在右侧
|
// 左侧弹出,箭头在右侧
|
||||||
&[data-popup-placement^='left'] > &-arrow {
|
&[data-popup-placement^='left'] > &-arrow {
|
||||||
right: -4px;
|
right: -4px;
|
||||||
}
|
}
|
||||||
|
&[data-popup-placement^='left'] > &-arrow::before {
|
||||||
|
box-shadow: $shadow-inset-left, $shadow-inset-top;
|
||||||
|
}
|
||||||
|
|
||||||
// 右侧弹出,箭头在左侧
|
// 右侧弹出,箭头在左侧
|
||||||
&[data-popup-placement^='right'] > &-arrow {
|
&[data-popup-placement^='right'] > &-arrow {
|
||||||
left: -4px;
|
left: -4px;
|
||||||
}
|
}
|
||||||
|
&[data-popup-placement^='right'] > &-arrow::before {
|
||||||
|
box-shadow: $shadow-inset-right, $shadow-inset-bottom;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 普通淡入淡出动画 */
|
/* 普通淡入淡出动画 */
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { PropType, VNode } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { arrow, autoUpdate, flip, offset, useFloating } from '@floating-ui/vue'
|
import { arrow, autoUpdate, flip, offset, useFloating } from '@floating-ui/vue'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import type { PropType } from 'vue'
|
|||||||
import { defineComponent } from 'vue'
|
import { defineComponent } from 'vue'
|
||||||
import { getPrefixCls } from '../_utils/getPrefixCls'
|
import { getPrefixCls } from '../_utils/getPrefixCls'
|
||||||
import Icon from '../icon'
|
import Icon from '../icon'
|
||||||
import './index.scss'
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Spin',
|
name: 'Spin',
|
||||||
|
|||||||
@@ -1,145 +1,111 @@
|
|||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineComponent } from 'vue'
|
import { useMessage } from '@ao/ao-design'
|
||||||
|
|
||||||
export default defineComponent({
|
const message = useMessage()
|
||||||
setup() {
|
|
||||||
const placements = [
|
|
||||||
'top',
|
|
||||||
'top-start',
|
|
||||||
'top-end',
|
|
||||||
'right',
|
|
||||||
'right-start',
|
|
||||||
'right-end',
|
|
||||||
'bottom',
|
|
||||||
'bottom-start',
|
|
||||||
'bottom-end',
|
|
||||||
'left',
|
|
||||||
'left-start',
|
|
||||||
'left-end',
|
|
||||||
] as const
|
|
||||||
|
|
||||||
return { placements }
|
function showMessage(placement: any) {
|
||||||
},
|
message.success({
|
||||||
})
|
message: `这里是 ${placement} 提示`,
|
||||||
|
placement,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function closeOne() {
|
||||||
|
const handle = message.success({
|
||||||
|
message: '测试',
|
||||||
|
duration: 0,
|
||||||
|
showClose: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function showMessageType(type: any) {
|
||||||
|
message.success({
|
||||||
|
message: `这里是 ${type} 提示`,
|
||||||
|
type,
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div class="demo">
|
||||||
style="height: 300px; overflow: auto; border: 1px solid #ccc; padding: 20px;"
|
<div class="row">
|
||||||
>
|
<AButton status="primary" @click="showMessage('top-start')">
|
||||||
<div style="height: 600px; position: relative;">
|
Top Start
|
||||||
<APopup
|
</AButton>
|
||||||
trigger="click" placement="top" auto-fit-popup-min-width content="你好"
|
<AButton status="primary" @click="showMessage('top')">
|
||||||
>
|
Top
|
||||||
<AButton status="primary" style="margin-top: 44px;">
|
</AButton>
|
||||||
测试
|
<AButton status="primary" @click="showMessage('top-end')">
|
||||||
|
Top End
|
||||||
</AButton>
|
</AButton>
|
||||||
</APopup>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<AButton status="primary" @click="showMessage('left')">
|
||||||
|
Left
|
||||||
|
</AButton>
|
||||||
|
<AButton status="primary" @click="showMessage('center')">
|
||||||
|
Center
|
||||||
|
</AButton>
|
||||||
|
<AButton status="primary" @click="showMessage('right')">
|
||||||
|
Right
|
||||||
|
</AButton>
|
||||||
</div>
|
</div>
|
||||||
<div class="demo-circle">
|
|
||||||
<h3>12方向Popup示例</h3>
|
<div class="row">
|
||||||
<div class="circle-container">
|
<AButton status="primary" @click="showMessage('bottom-start')">
|
||||||
<div
|
Bottom Start
|
||||||
v-for="placement in placements"
|
</AButton>
|
||||||
:key="placement"
|
<AButton status="primary" @click="showMessage('bottom')">
|
||||||
class="circle-item"
|
Bottom
|
||||||
:class="placement"
|
</AButton>
|
||||||
|
<AButton status="primary" @click="showMessage('bottom-end')">
|
||||||
|
Bottom End
|
||||||
|
</AButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<AButton status="primary" @click="message.closeAll">
|
||||||
|
Close All
|
||||||
|
</AButton>
|
||||||
|
|
||||||
|
<AButton
|
||||||
|
status="primary" @click="closeOne"
|
||||||
>
|
>
|
||||||
<APopup trigger="click" :placement="placement" content="1234567891">
|
Show No Close
|
||||||
<button>{{ placement }}</button>
|
</AButton>
|
||||||
</APopup>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<AButton status="primary" @click="showMessageType('info')">
|
||||||
|
info
|
||||||
|
</AButton>
|
||||||
|
<AButton status="primary" @click="showMessageType('success')">
|
||||||
|
success
|
||||||
|
</AButton>
|
||||||
|
<AButton status="primary" @click="showMessageType('warning')">
|
||||||
|
warning
|
||||||
|
</AButton>
|
||||||
|
<AButton status="primary" @click="showMessageType('error')">
|
||||||
|
error
|
||||||
|
</AButton>
|
||||||
|
<AButton status="primary" @click="showMessageType('loading')">
|
||||||
|
loading
|
||||||
|
</AButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.demo-circle {
|
.demo {
|
||||||
padding: 40px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
margin-top: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.circle-container {
|
.row {
|
||||||
position: relative;
|
display: flex;
|
||||||
width: 400px;
|
gap: 12px;
|
||||||
height: 400px;
|
|
||||||
border: 1px dashed #ccc;
|
|
||||||
border-radius: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 每个方向的按钮位置 */
|
|
||||||
.circle-item {
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 上 */
|
|
||||||
.circle-item.top {
|
|
||||||
top: 0;
|
|
||||||
left: 50%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
}
|
|
||||||
.circle-item.top-start {
|
|
||||||
top: 0;
|
|
||||||
left: 25%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
}
|
|
||||||
.circle-item.top-end {
|
|
||||||
top: 0;
|
|
||||||
left: 75%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 右 */
|
|
||||||
.circle-item.right {
|
|
||||||
top: 50%;
|
|
||||||
right: 0;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
}
|
|
||||||
.circle-item.right-start {
|
|
||||||
top: 25%;
|
|
||||||
right: 0;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
}
|
|
||||||
.circle-item.right-end {
|
|
||||||
top: 75%;
|
|
||||||
right: 0;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 下 */
|
|
||||||
.circle-item.bottom {
|
|
||||||
bottom: 0;
|
|
||||||
left: 50%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
}
|
|
||||||
.circle-item.bottom-start {
|
|
||||||
bottom: 0;
|
|
||||||
left: 25%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
}
|
|
||||||
.circle-item.bottom-end {
|
|
||||||
bottom: 0;
|
|
||||||
left: 75%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 左 */
|
|
||||||
.circle-item.left {
|
|
||||||
top: 50%;
|
|
||||||
left: 0;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
}
|
|
||||||
.circle-item.left-start {
|
|
||||||
top: 25%;
|
|
||||||
left: 0;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
}
|
|
||||||
.circle-item.left-end {
|
|
||||||
top: 75%;
|
|
||||||
left: 0;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
+1
-5
@@ -8,19 +8,15 @@ export {}
|
|||||||
/* prettier-ignore */
|
/* prettier-ignore */
|
||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
A: typeof import('@ao/ao-design')['default']
|
|
||||||
AB: typeof import('@ao/ao-design')['B']
|
|
||||||
AButton: typeof import('@ao/ao-design')['Button']
|
AButton: typeof import('@ao/ao-design')['Button']
|
||||||
AConfigProvider: typeof import('@ao/ao-design')['ConfigProvider']
|
AConfigProvider: typeof import('@ao/ao-design')['ConfigProvider']
|
||||||
AGroup: typeof import('@ao/ao-design')['Group']
|
AGroup: typeof import('@ao/ao-design')['Group']
|
||||||
AIcon: typeof import('@ao/ao-design')['Icon']
|
AIcon: typeof import('@ao/ao-design')['Icon']
|
||||||
AInput: typeof import('@ao/ao-design')['Input']
|
AInput: typeof import('@ao/ao-design')['Input']
|
||||||
ALoading: typeof import('@ao/ao-design')['Loading']
|
ALoading: typeof import('@ao/ao-design')['Loading']
|
||||||
ALoding: typeof import('@ao/ao-design')['Loding']
|
AMessage: typeof import('@ao/ao-design')['Message']
|
||||||
APopup: typeof import('@ao/ao-design')['Popup']
|
APopup: typeof import('@ao/ao-design')['Popup']
|
||||||
ASpin: typeof import('@ao/ao-design')['Spin']
|
ASpin: typeof import('@ao/ao-design')['Spin']
|
||||||
AT: typeof import('@ao/ao-design')['T']
|
|
||||||
ATex: typeof import('@ao/ao-design')['Tex']
|
|
||||||
ATextarea: typeof import('@ao/ao-design')['Textarea']
|
ATextarea: typeof import('@ao/ao-design')['Textarea']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user