manuel
(Manuel Kostka)
7월 29, 2022, 2:58오후
1
현재 태그의 이름은 data-tag-name 데이터 속성에 저장되어 있습니다:
data-tag-group 속성도 추가할 수 있을까요? 이를 통해 UX에서 서로 다른 그룹의 태그를 스타일링하고 구별하는 것이 쉬워집니다. 특히 태그만 사용하는 환경에서 이 기능이 특히 유용하다고 생각합니다. 이러한 환경에서는 보통 최상위 태그가 존재하며, 해당 그룹의 태그가 독특한 외관으로 눈에 띄면 내비게이션이 더 직관적이 됩니다.
몇 년 전에 CSS 클래스 추가 요청 이 있었음을 확인했습니다. 상황이 변했을 수 있고, 데이터 속성을 사용하면 구현이 더 간단해질 수 있으므로 이 주제를 다시 꺼내 봅니다.
13개의 좋아요
이 기능을 태그 그룹에 따라 태그 아이콘을 할당하는 데에도 사용할 수 있을까요? 현재 제 태그 아이콘 설정이 꽤나 복잡해서, 이를 간소화할 수 있는 기능이 있다면 정말 좋겠습니다.
3개의 좋아요
manuel
(Manuel Kostka)
6월 23, 2024, 4:19오후
3
그렇게 생각됩니다. 또한 태그 스타일을 변경하는 다른 컴포넌트들도 마찬가지입니다. 예를 들어 Discourse Coloring Tag 또는 Colored Tag Styles 같은 경우요.
이를 구현하려면 해당 컴포넌트들을 조정해야 합니다. 태그 스타일의 경우라면 꽤 간단하게 처리할 수 있을 것입니다.
2개의 좋아요
저도 마찬가지입니다. 거의 천 줄에 달하는 설정이 8줄로 줄어들 것 같습니다.
2개의 좋아요
이 작업은 진행되었으나 변경 사항이 너무 크다는 이유로 폐기되었습니다. 좋은 아이디어이지만, 불행히도 팀이 가까운 시일 내에 이를 진행할지는 불확실합니다.
main ← add-tag-groups-for-tag
closed 08:53AM - 31 Jul 24 UTC
## Overview
This commit adds the `data-tag-groups` attribute to tags, making … it easier to use CSS selectors to batch select tags belonging to certain tag groups.
An example:
```html
<a href="/tag/hidden" data-tag-name="hidden" data-tag-groups="Hidden Tag Group, non-hidden tags" class="discourse-tag box">hidden</a>
```
Related meta topic: https://meta.discourse.org/t/add-a-data-tag-group-attribute-for-tags/234410
## Detailed changes
Add data-groups to these...
- [ ] Tags for topics
- [x] The effect has been shown
- [ ] Tests already written
- [ ] Confirms that there are no performance issues
- [ ] TagChooser at the top of TopicList
- [x] The effect has been shown
- [x] Tests already written
- [ ] Confirms that there are no performance issues
- [ ] Tags on the sidebar
- [x] The effect has been shown
- [ ] Tests already written
- [ ] Confirms that there are no performance issues
- [ ] Tags on the `/tags` page
- [x] The effect has been shown
- [ ] Tests already written
- [ ] Confirms that there are no performance issues
- [ ] Search bar tags
- [x] The effect has been shown
- [ ] Tests already written
- [ ] Confirms that there are no performance issues
- [ ] Composer tags chooser
- [x] The effect has been shown
- [ ] Tests already written
- [ ] Confirms that there are no performance issues
- [ ] ~~Tags in the post body~~ Maybe next PR
## DEV Improvements
Partially rewrote `defaultRenderTag` for better scalability and clarity:
The new `defaultRenderTag` reserves an interface for theme components to avoid the need for components to completely rewrite `defaultRenderTag` to provide custom tag renderer.
For example, you can now replace the tagRenderer like this:
```javascript
api.replaceTagRenderer((tag, params) => {
return defaultRenderTag(tag, params, {
extraClass: "custom-tag-class",
contentFn(old) {
return `${iconHTML("tag")}${old}`;
},
});
});
```
This has a significant benefit for discourse tag icons. Since the [old way of code](https://github.com/discourse/discourse-tag-icons/blob/main/javascripts/discourse/initializers/tag-icons.js#L9-L84) the changes made by this PR will be completely overwritten by discourse tag icons, and the theme component must be updated accordingly.
After applying the new interface, it can automatically synchronize changes with the `defaultRendererTag` in core.
4개의 좋아요