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

Make tags and tag suggestions able to be styled by add-ons #2941

Merged
merged 3 commits into from Jan 18, 2024

Conversation

glutanimate
Copy link
Contributor

I would like to extend Colorful Tags with the ability to also render user-selected tag colors in the editor. Right now this is not really possible as there is no stable & performant way to target individual tags and suggestion components.

This PR introduces two new data attributes, data-suggestion and data-tag-name that are applied to the corresponding elements, making them very easy to target via CSS or JS.

A couple of thoughts:

  • I was thinking of perhaps renaming the attributes to use a common data-addon prefix, e.g. data-addon-tag and data-addon-suggestion. That might be a more expressive way of highlighting that these are consumed by add-ons while also making it easier to grep for add-ons that might be accessing the attributes in the future. WDYT?
  • Do you think it would be prudent to escape some characters in the tag content? I wasn't able to find any Svelte-specific recommendations here. Given that Svelte seems to render the attributes double-quoted, it seems like replacing potentially ambiguous & and " would be the spec-conformant way. However, it doesn't look like we're doing this anywhere else and in some places we already are setting some attributes to values that could contain both " and & (e.g. button.title on Tag.svelte).

@dae
Copy link
Member

dae commented Jan 12, 2024

  • data-addon-* seems reasonable, but I don't have a strong preference
  • I'm guessing that because Svelte sets the attributes via Javascript instead of raw HTML, ampersands/etc probably won't break, so I don't have much of a preference here either.

@glutanimate
Copy link
Contributor Author

Cheers, I switched to data-addon-* and, having confirmed that & and " work, will leave the attribute handling as is then to remain consistent with other code.

@dae dae merged commit db9aaba into ankitects:main Jan 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants