import { computed } from 'vue';
import { createNamespace } from '../utils';
import { BORDER } from '../utils/constant';
import { STEPS_KEY } from '../steps';
import { useParent } from '../composition/use-relation';
import Icon from '../icon';
const [createComponent, bem] = createNamespace('step');
export default createComponent({
setup(props, { slots }) {
const { parent, index } = useParent(STEPS_KEY);
const getStatus = () => {
const active = +parent.props.active;
if (index.value < active) {
return 'finish';
}
if (index.value === active) {
return 'process';
}
};
const isActive = () => getStatus() === 'process';
const lineStyle = computed(() => {
const { activeColor, inactiveColor } = parent.props;
if (getStatus() === 'finish') {
return { background: activeColor };
}
return { background: inactiveColor };
});
const titleStyle = computed(() => {
const { activeColor, inactiveColor } = parent.props;
if (isActive()) {
return { color: activeColor };
}
if (!getStatus()) {
return { color: inactiveColor };
}
});
const onClickStep = () => {
parent.emit('click-step', index.value);
};
const renderCircle = () => {
const { activeIcon, activeColor, inactiveIcon } = parent.props;
if (isActive()) {
if (slots['active-icon']) {
return slots['active-icon']();
}
return (