feature: implement text component

This commit is contained in:
Sagi 2022-09-28 18:01:52 +08:00
parent bf0090858b
commit 4dc7ac3e83
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,41 @@
import { computed, defineComponent, ref, SetupContext } from 'vue';
import { TextProps, textProps } from './text.props';
export default defineComponent({
name: 'FText',
props: textProps,
emits: [],
setup(props: TextProps, context: SetupContext) {
const isTextArea = ref(true);
const autoSize = ref(true);
const textAlginment = ref('');
const height = ref(0);
const maxHeight = ref(0);
const textClass = computed(() => ({
'f-form-control-text': !isTextArea.value,
'f-form-context-textarea': isTextArea,
'f-component-text-auto-size': autoSize.value,
}));
const textStyle = computed(() => ({
textalign: textAlginment.value,
height: !autoSize.value && height.value > 0 ? `${height.value}px` : '',
'min-height': !autoSize.value && height.value > 0 ? `${height.value}px` : '',
'max-height': !autoSize.value && maxHeight.value > 0 ? `${maxHeight.value}px` : '',
}));
const text = computed(() => {
// text && text.length > 0 ? text : control
return '';
});
return () => {
return (
<span class={textClass.value} style={textStyle.value}>
{text.value}
</span>
);
};
},
});

View File

@ -0,0 +1,4 @@
import { ExtractPropTypes } from 'vue';
export const textProps = {};
export type TextProps = ExtractPropTypes<typeof textProps>;