腾讯omi项目中的omim,基于typescript,pr了omim-tag组件,已被commit。

omim线上体验地址:omim

github地址: mac-tag

个人blog地址: blog

demo:

import '../../src/tag/index.tsx'
import { render, h } from 'omi'function clickHandler() {console.log(1)
}
render(<div><h3>基础用法</h3><m-tag onClick={clickHandler}>default</m-tag><m-tag onClick={clickHandler} type='primary'>primary</m-tag><m-tag onClick={clickHandler} type='danger'>danger</m-tag><m-tag onClick={clickHandler} type='warn'>warn</m-tag><m-tag onClick={clickHandler} type='success'>success</m-tag><h3>带图标</h3><m-tag onClick={clickHandler} icon={{path: 'M923 283.6a260.04 260.04 0 0 0-56.9-82.8 264.4 264.4 0 0 0-84-55.5A265.34 265.34 0 0 0 679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 0 0-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9zM512 814.8S156 586.7 156 385.5C156 283.6 240.3 201 344.3 201c73.1 0 136.5 40.8 167.7 100.4C543.2 241.8 606.6 201 679.7 201c104 0 188.3 82.6 188.3 184.5 0 201.2-356 429.3-356 429.3z',color: '#0052d9',scale: 1.3}}>default</m-tag><m-tag onClick={clickHandler} type='primary' icon={{path: 'M923 283.6a260.04 260.04 0 0 0-56.9-82.8 264.4 264.4 0 0 0-84-55.5A265.34 265.34 0 0 0 679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 0 0-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9zM512 814.8S156 586.7 156 385.5C156 283.6 240.3 201 344.3 201c73.1 0 136.5 40.8 167.7 100.4C543.2 241.8 606.6 201 679.7 201c104 0 188.3 82.6 188.3 184.5 0 201.2-356 429.3-356 429.3z',color: '#0052d9',scale: 1.3}}>primary</m-tag><m-tag onClick={clickHandler} type='danger' icon={{path: 'M923 283.6a260.04 260.04 0 0 0-56.9-82.8 264.4 264.4 0 0 0-84-55.5A265.34 265.34 0 0 0 679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 0 0-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9zM512 814.8S156 586.7 156 385.5C156 283.6 240.3 201 344.3 201c73.1 0 136.5 40.8 167.7 100.4C543.2 241.8 606.6 201 679.7 201c104 0 188.3 82.6 188.3 184.5 0 201.2-356 429.3-356 429.3z',color: '#0052d9',scale: 1.3}}>danger</m-tag><m-tag onClick={clickHandler} type='warn' icon={{path: 'M923 283.6a260.04 260.04 0 0 0-56.9-82.8 264.4 264.4 0 0 0-84-55.5A265.34 265.34 0 0 0 679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 0 0-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9zM512 814.8S156 586.7 156 385.5C156 283.6 240.3 201 344.3 201c73.1 0 136.5 40.8 167.7 100.4C543.2 241.8 606.6 201 679.7 201c104 0 188.3 82.6 188.3 184.5 0 201.2-356 429.3-356 429.3z',color: '#0052d9',scale: 1.3}}>warn</m-tag><m-tag onClick={clickHandler} type='success' icon={{path: 'M923 283.6a260.04 260.04 0 0 0-56.9-82.8 264.4 264.4 0 0 0-84-55.5A265.34 265.34 0 0 0 679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 0 0-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9zM512 814.8S156 586.7 156 385.5C156 283.6 240.3 201 344.3 201c73.1 0 136.5 40.8 167.7 100.4C543.2 241.8 606.6 201 679.7 201c104 0 188.3 82.6 188.3 184.5 0 201.2-356 429.3-356 429.3z',color: '#0052d9',scale: 1.3}}>success</m-tag><h3>不同尺寸</h3><m-tag onClick={clickHandler}>default</m-tag><m-tag onClick={clickHandler} type='danger' size='medium'>medium</m-tag><m-tag onClick={clickHandler} type='warn' size='small'>small</m-tag><m-tag onClick={clickHandler} type='success' size='mini'>mini</m-tag></div>, 'body')
复制代码

源码如下:

index.d.ts文件:

import { WeElement } from 'omi';
import '../icon';
interface Props {type: string;active: boolean;size: string;icon: object;
}
interface Data {
}
export default class Tag extends WeElement<Props, Data> {static css: any;static propTypes: {type: StringConstructor;active: BooleanConstructor;size: StringConstructor;icon: ObjectConstructor;};render(props: any): JSX.Element;
}
export {};复制代码

index.tsx文件:

import { tag, WeElement, h, extractClass } from 'omi'
import * as css from './index.scss'
import '../icon'interface Props {type: string,active: boolean,size: string,icon: object
}interface Data {}@tag('m-tag')
export default class Tag extends WeElement<Props, Data>{static css = cssstatic propTypes = {type: String,active: Boolean,size: String,icon: Object}render(props) {return (<div {...extractClass(props, 'mdc-tag',props.type ? 'mdc-tag--'+`${props.type}` : '',props.size ? 'mdc-tag--' + `${props.size}` : '')}><span><slot></slot></span>{(props.icon) && <m-icon class='m-icon' {...props.icon}></m-icon>}</div>)}
}复制代码

index.scss文件:

@import '../theme';.m-icon {margin-left: 0.6em;text-align: center;display: inline-block;
}.mdc-tag {margin: 5px 5px 0 0;background-color: #fff;color: #000;padding: 0 10px;height: 32px;font-size: 12px;box-sizing: border-box;border: 1px solid rgba(64, 158, 255, 0.2);white-space: nowrap;font-family: Roboto, sans-serif;font-size: 12px;line-height: 2.25rem;font-weight: 500;letter-spacing: 0.08929em;text-decoration: none;text-transform: uppercase;padding: 0 10px;display: inline-flex;position: relative;align-items: center;justify-content: center;box-sizing: border-box;line-height: inherit;user-select: none;overflow: hidden;vertical-align: middle;
}.mdc-tag--active {background-color: #ccc;
}.mdc-tag--success {background-color: rgba(103, 194, 58, 0.1);border-color: rgba(103, 194, 58, 0.2);color: #09bb07 !important;
}
.mdc-tag--primary {background-color: rgba(64, 158, 255, 0.1);border-color: rgba(64, 158, 255, 0.2);color: #0052d9 !important;
}
.mdc-tag--warn {background-color: rgba(230, 162, 60, 0.1);border-color: rgba(230, 162, 60, 0.2);color: #e6a23c !important;
}
.mdc-tag--danger {background-color: rgba(245, 108, 108, 0.1);border-color: rgba(245, 108, 108, 0.2);color: #e64340 !important;
}.mdc-tag--mediun {height: 28px;line-height: 26px;
}.mdc-tag--small {height: 24px;padding: 0 8px;line-height: 22px;
}.mdc-tag--mini {height: 20px;padding: 0 5px;line-height: 19px;
}复制代码

转载于:https://juejin.im/post/5cff20f8f265da1b5e72e9ab

基于omi的omim-tag组件相关推荐

  1. 基于vue element-ui 封装上传图片组件 功能:上传,删除,预览,上传图片水印,拖拽排序,上传进度条等

    学习目标: 我们在开发后台时肯定避免不了上传图片的功能 例如: 上传图片回显 上传完成 : 预览查看 , 删除等 如果是图片列表,还可能让你拖动图片排序 有的后台项目可能要给图片添加水印,添加标记 有 ...

  2. 基于jquery的php分页,基于jQuery封装的分页组件

    前言: 由于项目需要实现分页效果,上jQuery插件库找了下,但是木有找到自己想要的效果,于是自己封装了个分页组件. 思路: 主要是初始化时基于原型建立的分页模板然后绑定动态事件并实现刷新DOM的分页 ...

  3. value数字 vue_基于Vue开发数字输入框组件

    随着 vue 越来越火热, 相关组件库也非常多啦, 只用轮子怎么够, 还是要造起来!!! 1.概述 vue组件开发的api:props.events和slots 2.组件代码 效果: (1)index ...

  4. 实现一个基于Vue的Button小组件

    概述 原生HTML的button只能保证功能存在,样式都不怎么好看.当然也可以通过编写css样式来改变原生HTML中的button显示,但是现在各个UI框架都很流行,也很方便,很多时候都是直接引入框架 ...

  5. vue手机端项目php,MintUI基于Vue.js移动端组件库详解

    Mint UI 包含丰富的 CSS 和 JS 组件,能够满足日常的移动端开发需要.接下来通过本文给大家分享Mint UI 基于 Vue.js 移动端组件库,需要的朋友参考下吧,希望能帮助到大家. 官网 ...

  6. 基于软总线的实时组件调度技术研究

    基于软总线的实时组件调度技术研究 摘要:首先分析组件软件工程模式比面向对象的开发模式更优越:接着讨论了组件软件工程的核心机制--软总线,提供组件通讯机制,保证组件的即插即用等功能:然后讨论了软总线中的 ...

  7. 基于V2EX API的nodejs组件.

    今天又学习到了新的知(zi)识(shi),来给自己做个笔录,也算在这酷热的天气里给自己写了一篇降温的'膏药',话就讲这么多了 ,start off...... 首先 ,依赖选择: /**设置为严格模式 ...

  8. vue结合饿了么_饿了么基于Vue2.0的通用组件开发之路(分享会记录)

    Element:一套通用组件库的开发之路 Element 是由饿了么UED设计.饿了么大前端开发的一套基于 Vue 2.0 的桌面端组件库.今天我们要分享的就是开发 Element 的一些心得. 官网 ...

  9. 基于 next.js + mdx 搭建组件库文档项目(二) -- mdx 控件封装实现组件的演示与 Props 列表

    说明 经过上阶段的配置虽然可以在项目中使用 mdx 语法 来创建页面了,但是我们的组件库有一些定制化的需求:交互式的组件演示.组件 Props 列表展示.这些功能如果可以通过封装来实现,会大大提升开发 ...

  10. 基于 next.js + mdx 搭建组件库文档项目(一) -- 开发环境搭建

    说明 之前使用过 Docz 来作为组件库文档搭建工具,它基于 gatsby , 提供了高度的定制化能力,但是截止 2021-06-22, Docz 停留在 v2.3.1(2020-04-05) 已经一 ...

最新文章

  1. Kaggle泰坦尼克号数据机器学习实战:从缺失值处理、数据探索性分析、组合特征生成到多模型构建
  2. Activity的四种launchMode
  3. Golang gorouting 并发控制 sync.WaitGroup 介绍与使用
  4. 关于思考写程序的意义
  5. python同时监听多个端口_python bottle使用多个端口(多个进程)提高并发
  6. vue根据数组对象中某个唯一标识去重
  7. 计算机用户登录设置成2000,2008计算机等级考试:Windows2000系统选项设置
  8. jps后发现DataNode没有启动
  9. 浅谈HTTP中GET和POST请求方式的区别
  10. 华为紧盯Android专利战: 置身事外几无可能
  11. CentOS安全运维检查命令
  12. 绘本“深阅读’’的教学探索
  13. 服务器硬件配置及RAID配置操作
  14. 倪文迪陪你学蓝桥杯2021寒假每日一题:1.25日(2019省赛A组第3题)
  15. 数字先锋 | 天翼云牵手中能融合
  16. iphone浏览器不支持javascript中的new Date问题
  17. 多进程(Linux)
  18. 二[2-(2,4-二氟苯基)-5-甲基吡啶][2,2‘-联(四叔丁基吡啶)]铱二(六氟磷酸)盐,1335047-34-1
  19. android手机通讯录格式转换,手机通讯录小技巧,安卓手机通讯录转iPhone并不难,换机必学...
  20. 1.《小狗钱钱》读书笔记

热门文章

  1. Vuforia SDK---- AR开发vuforia 问题总结
  2. 测试过程中常见需要考虑的点
  3. 办公软件 office
  4. matlab 柱面投影,图像拼接(不投影到柱面)(渐入渐出融合) matlab程序
  5. 安卓电子书格式_如何将电子书导入kindle App?
  6. 广深IT之行:传统模式与技术创新的融合
  7. unity 控制移动的方法
  8. google网页翻译使用不了的解决方案
  9. 亲爱的老狼-opacity、rgba、transparent的应用
  10. 微积分知识点回顾与总结(八):重积分