纯CSS绘制左连接、右连接、内连接、全连接的小圆

该博客介绍了一个名为JointIcon的Vue组件,用于显示不同类型的连接图标。组件根据传入的连接类型(JointType)动态设置左右圆的填充颜色和层级。通过计算属性leftFill和rightFill确定填充状态,同时,当类型为Intersection时,会显示一个椭圆形交叉标记。样式使用了Less进行模块化管理,背景色和边框颜色等样式变量来自外部定义。
摘要由CSDN通过智能技术生成

一、效果

 二、实现

<template>
  <div :class="$style.jointIcon">
    <div
      :class="[
        $style.jointIconLeft,
        leftFill && $style.fillColor,
        leftFill && $style.level,
      ]"
    ></div>
    <div
      :class="[
        $style.jointIconRight,
        rightFill && $style.fillColor,
        { [$style.level]: rightLevel },
      ]"
    ></div>
    <div :class="$style.oval" v-if="type === JointType.Intersection"></div>
  </div>
</template>
<script>
import { Component, Vue, Prop } from 'vue-property-decorator';
import { JointType } from '@/views/data-flow-design/data/utils/enum';

@Component()
export default class JointIcon extends Vue {
  /**@name 连接类型 */
  @Prop({ type: String, default: 'ALL' }) type;

  JointType = JointType;

  /**@name 左圆填充颜色 */
  get leftFill() {
    if (this.type === JointType.All || this.type === JointType.Left)
      return true;
    return false;
  }
  /**@name 右圆填充颜色 */
  get rightFill() {
    if (this.type === JointType.All || this.type === JointType.Right)
      return true;
    return false;
  }
  /**@name 右圆层级高 */
  get rightLevel() {
    if (this.type === JointType.Right) return true;
    return false;
  }
}
</script>
<style lang="less" module>
.jointIcon {
  position: relative;
  width: 36px;
  height: 22px;
}
.jointIconLeft {
  position: absolute;
  top: 0px;
  left: 0px;
  display: inline-block;
  width: 22px;
  height: 22px;
  background-color: var(--btn-border);
  box-shadow: 0 0 1px 0.5px var(--btn-border);
  border-radius: 50px;
  z-index: 1;
}

.jointIconRight {
  display: inline-block;
  top: 0px;
  left: 14px;
  width: 22px;
  height: 22px;
  background-color: var(--btn-border);
  border-radius: 50px;
  position: absolute;
  z-index: 1;
}
.level {
  z-index: 999;
}
.oval {
  display: inline-block;
  position: absolute;
  top: 5px;
  left: 12px;
  width: 12px;
  height: 12px;
  background-color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 12px 0px;
  transform: rotate(-45deg);
  -ms-transform: rotate(-45deg);
  -moz-transform: rotate(-45deg);
  -webkit-transform: rotate(-45deg);
  -o-transform: rotate(-45deg);
  z-index: 999;
}
.fillColor {
  background-color: var(--primary);
}
</style>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值