feature: implement according component

This commit is contained in:
Sagi 2022-09-28 17:31:55 +08:00
parent 6b3dd22821
commit 431239b8a4
6 changed files with 139 additions and 32 deletions

View File

@ -0,0 +1,25 @@
import { isContext } from 'vm';
import { computed, defineComponent, SetupContext } from 'vue';
import { AccordingProps, accordingProps } from './according.props';
import './according.css';
export default defineComponent({
name: 'FAccording',
props: accordingProps,
emits: [],
setup(props: AccordingProps, context: SetupContext) {
const accordingStyle = computed(() => ({
height: props.height ? `${props.height}px` : '',
width: props.width ? `${props.width}px` : '',
}));
return () => {
return (
<div class={`farris-panel accoriding ${props.customClass.join(' ')}`} style={accordingStyle.value}>
{context.slots.default && context.slots.default()}
</div>
);
};
},
});

View File

@ -0,0 +1,4 @@
/* 很重要 */
.farris-panel {
border: 1px solid rgba(0, 0, 0, .125)
}

View File

@ -0,0 +1,10 @@
import { ExtractPropTypes } from 'vue';
export const accordingProps = {
customClass: { type: Array<string>, default: [] },
height: { type: Number },
width: { type: Number },
enableFold: { type: Boolean, default: true },
expanded: { type: Boolean, default: false },
};
export type AccordingProps = ExtractPropTypes<typeof accordingProps>;

View File

@ -0,0 +1,58 @@
import { computed, defineComponent, ref, SetupContext } from 'vue';
export default defineComponent({
name: 'FAccordingItem',
props: {},
emits: [],
setup(props, context: SetupContext) {
const title = ref('');
const isActive = ref(false);
const isDisabled = ref(false);
function selectAccordingItem() {}
function onClick($event: Event) {
selectAccordingItem();
}
const accordingItemClass = computed(() => ({
'f-state-disable': isDisabled.value,
card: true,
'farris-panel-item': true,
'f-state-selected': isActive.value,
}));
const shouldShowHeader = computed(() => {
return true;
});
const shouldShowCustomHeader = computed(() => {
return false;
});
const headIconClass = computed(() => ({
'f-icon': true,
'f-according-collapse': !isActive.value,
'f-according-expand': isActive.value,
}));
return () => {
return (
<div class={accordingItemClass.value}>
<div class="card-header" onClick={onClick}>
<div class="panel-item-title">
{shouldShowHeader.value && <span>{title.value}</span>}
{shouldShowCustomHeader.value && context.slots.head && context.slots.head()}
<span class={headIconClass.value}></span>
</div>
<div class="panel-item-tool">{context.slots.toolbar && context.slots.toolbar()}</div>
<div class="panel-item-clear"></div>
</div>
<div dropAnimation="active?'active':'inactive'">
<div class="card-body">{context.slots.content && context.slots.content()}</div>
</div>
</div>
);
};
},
});

View File

@ -0,0 +1,10 @@
import { ExtractPropTypes } from 'vue';
export const accordingItemProps = {
width:{type:Number},
height:{type:Number},
title:{type:String,default:''},
disable:{type:Boolean,default:false}
};
export type AccordingItemProps = ExtractPropTypes<typeof accordingItemProps>;

View File

@ -3,38 +3,38 @@ import { ExtractPropTypes, PropType } from 'vue';
type AvatarShap = 'square' | 'circle';
export const avatarProps = {
/**
*
*/
avatarWidth: { type: Number, default: 100 },
/**
*
*/
avatarHeight: { type: Number, default: 100 },
/**
*
*/
cover: { type: String },
/**
*
*/
readonly: { type: Boolean, default: false },
/**
*
*/
shape: { type: String as PropType<AvatarShap>, default: 'circle' },
/**
* , MB
*/
maxSize: { type: Number, default: 1 },
/**
*
*/
tile: { type: String, default: '' },
/**
*
*/
type: { type: Array<string>, default: [] },
/**
*
*/
avatarWidth: { type: Number, default: 100 },
/**
*
*/
avatarHeight: { type: Number, default: 100 },
/**
*
*/
cover: { type: String },
/**
*
*/
readonly: { type: Boolean, default: false },
/**
*
*/
shape: { type: String as PropType<AvatarShap>, default: 'circle' },
/**
* , MB
*/
maxSize: { type: Number, default: 1 },
/**
*
*/
tile: { type: String, default: '' },
/**
*
*/
type: { type: Array<string>, default: [] },
};
export type AvatarProps = ExtractPropTypes<typeof avatarProps>;