mrbbot / slshx

⚔️ Strongly-typed Discord commands on Cloudflare Workers
MIT License
210 stars 9 forks source link

Suggestion: Line component #6

Closed solaris7x closed 2 years ago

solaris7x commented 2 years ago

It is common to write multi-line messages and the current way to add newline {"\n"} doesn't play nice with prettier formatter. image

The current workaround I am using to keep my message in code and in discord look visually the same is wrapping each line into a Fragment and adding {"\n"} between fragments. This stops prettier from squashing all the line and each fragment gets it own separate line. image

Thus I propose to add a <Line> component that work as Fragment with newline , essentially giving a html block like feel and keep message in code visually similar to that in final output.

mrbbot commented 2 years ago

Hey! 👋 Nice idea, however I think this is best suited to user code instead. You should be able to do:

function Line({ children }) {
  return <>{children}{"\n"}</>;
}

...then use <Line> like a regular component.

solaris7x commented 2 years ago

That's one clean way to use it. As it is used to frequently , I suggested to add it as a helper component.