1 Star 0 Fork 0

LS/ls-design

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.tsx 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
LS 提交于 2023-10-22 11:36 +08:00 . feat: init project
import { Property, CustomElement, LSElement } from '@ls-design/core';
import '@ls-design/icons/dist/es/arrow-right';
import cellStyle from './cellStyle.css';
import cellGroupCss from './cellGroupStyle.css';
export interface Props {
title: string;
desc?: string;
to?: string;
islink?: boolean;
icon?: string;
}
@CustomElement({
tag: 'ls-cell',
style: cellStyle,
})
class LSCell extends LSElement {
@Property()
title = '';
@Property()
icon = '';
@Property()
desc = '';
@Property()
to = '';
@Property({
type: Boolean,
})
islink = false;
handleNavigation = () => {
if (this.to) {
window.location.href = this.to;
}
};
renderIcon = () => {
if (this.icon && this.icon.includes('http')) {
return <img src={this.icon} class="ls-cell-icon" style={{ marginRight: 4 }} />;
}
return null;
};
render() {
return (
<div class="ls-cell" onClick={this.handleNavigation}>
<slot name="icon">{this.renderIcon()}</slot>
<div class="ls-cell-title" id="title">
<slot name="title">{this.title}</slot>
</div>
<slot>
{this.desc && (
<div class="ls-cell-desc" id="desc">
{this.desc}
</div>
)}
{this.islink && <ls-icon-arrow-right id="arrow" />}
</slot>
</div>
);
}
}
export default LSCell;
@CustomElement({
tag: 'ls-cell-group',
style: cellGroupCss,
})
class LSCellGroup extends LSElement {
render() {
return <slot></slot>;
}
}
export { LSCellGroup };
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LShere/ls-design.git
git@gitee.com:LShere/ls-design.git
LShere
ls-design
ls-design
master

搜索帮助