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

一、效果

 二、实现

<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、付费专栏及课程。

余额充值