Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(atomic): add localizedString directive (#4852)
Replace the functional component with a custom lit directive ## In Stencil, we do ```ts render () { return ( <LocalizedString key={i18nKey} i18n={this.bindings.i18n} params={...} /> ): } ``` ## In Lit, we do ```ts render () { return html` ${localizedString({ key: i18nKey, i18n: this.bindings.i18n, params: {...}, })} `; } ``` ### Notes It's hard to make perf adjustments to this code (e.g. using a regex instead of splitting the string) since the directive can also accept DOM values. For example ```ts html`${localizedString({ i18n: i18n, key: "search-instead-for", params: { query: html` <button class="link py-1" part="undo-btn" onClick={() => onClick()} > ${originalQuery} </button>` } ` ``` Which returns something like that ![image](https://github.com/user-attachments/assets/c56ea31a-b563-4832-ac8a-ecd365dad80e) In the code example above, moving out the `<button>` Element from the directive would imply some big refactor on the locales https://coveord.atlassian.net/browse/KIT-3831
- Loading branch information