Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cell] 外部样式类t-class-title划分不合理 #2428

Closed
Oreslok opened this issue Nov 4, 2023 · 5 comments · Fixed by #2439
Closed

[cell] 外部样式类t-class-title划分不合理 #2428

Oreslok opened this issue Nov 4, 2023 · 5 comments · Fixed by #2439
Labels
question This is a question, not a bug

Comments

@Oreslok
Copy link

Oreslok commented Nov 4, 2023

tdesign-miniprogram 版本

2.8.3-1

重现链接

No response

重现步骤

<t-cell title="我是标题">
<view slot="note">
<t-button>选择1</t-button>
<t-button>选择2</t-button>
</view>
</t-cell>

上述代码,在微信开发者工具中,将解析为

<view class="t-class t-cell t-middle">
<view class="t-cell__left t-class-left"></view>
<view class="t-cell__title">
<view class="t-cell__title-text t-class-title"></view>
</view>
<view class="t-cell__note t-class-note"></view>
<view class="t-cell__right t-class-right"></view>
</view>
</view>

这么一看发现问题了吗? t-class-left t-class-note t-class-right 都位于第二层,但偏偏 t-class-title在第三层
如果我想控制title这一层的样式,依靠t-class-title可不行,得使用t-cell__title,所以建议把t-class-title放到t-cell__title后

期望结果

No response

实际结果

No response

基础库版本

No response

补充说明

No response

Copy link
Contributor

github-actions bot commented Nov 4, 2023

👋 @Oreslok,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@anlyyao
Copy link
Collaborator

anlyyao commented Nov 8, 2023

@Oreslok 微信开发工具解析出来的结构只是一部分,整个组件的dom结构建议查看源码,整体上看位置暂时不会调整。然后,你直接使用t-class-title无效的本质原因和位置无关,是优先级问题。 组件中title样式写在 x__title-text选择器上,而外部样式类t-class-titlex__title-text优先级是未定义的。所以建议你提高t-class-title的优先级,这边提供一个代码片段给可供参考。

@anlyyao anlyyao added the question This is a question, not a bug label Nov 8, 2023
@Oreslok
Copy link
Author

Oreslok commented Nov 13, 2023

@anlyyao 我觉得你可能没有理解我意思。我目的就是控制title区域的样式。举个例子吧,我想调整title的flex。

<t-cell title="详细地址" t-class-title="my-title"></t-cell>
.my-title { flex: none !important; }

你看,基于上述代码,并不能达到我设置flex: none的目的,我必须通过.t-cell__title才能实现

@anlyyao
Copy link
Collaborator

anlyyao commented Nov 15, 2023

@anlyyao 我觉得你可能没有理解我意思。我目的就是控制title区域的样式。举个例子吧,我想调整title的flex。

<t-cell title="详细地址" t-class-title="my-title"></t-cell>
.my-title { flex: none !important; }

你看,基于上述代码,并不能达到我设置flex: none的目的,我必须通过.t-cell__title才能实现

image
我想表达的是源码中类__title包含的不止是title内容,t-class-title的位置没有问题不会做出调整,你这个需求应该是在新增一个外部样式 t-class-center ,让你外部可控中间整块内容

@Oreslok
Copy link
Author

Oreslok commented Nov 20, 2023

@anlyyao 我觉得你可能没有理解我意思。我目的就是控制title区域的样式。举个例子吧,我想调整title的flex。

<t-cell title="详细地址" t-class-title="my-title"></t-cell>
.my-title { flex: none !important; }

你看,基于上述代码,并不能达到我设置flex: none的目的,我必须通过.t-cell__title才能实现

image 我想表达的是源码中类__title包含的不止是title内容,t-class-title的位置没有问题不会做出调整,你这个需求应该是在新增一个外部样式 t-class-center ,让你外部可控中间整块内容

点赞!

@Oreslok Oreslok closed this as completed Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This is a question, not a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants