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

Elixir code evaluation in Playground attributes #520

Open
xxdavid opened this issue Dec 2, 2024 · 2 comments
Open

Elixir code evaluation in Playground attributes #520

xxdavid opened this issue Dec 2, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@xxdavid
Copy link
Contributor

xxdavid commented Dec 2, 2024

Hi again, @cblavier! For a few weeks, I've been playing with the idea of allowing almost-arbitrary Elixir code to be used as an attribute value in the Playground. It's seems a pity to me that only a subset of attributes can be modified in the Playground, often times the attributes I would like to edit are locked.

What do you think about evaluating the value in case its type is not a string? For example, that it would be possible to pass [%{id: "john", name: "John"}, %{id: "jane", name: "Jane"}] to the rows attribute of the table/1 component from CoreComponents. Or passing %{name: "my-input", disabled: true} to the global rest attribute of an input.

It might be not safe to execute arbitrary code though, because in case the Storybook was running on a public server, this would give a random Storybook visitor full control over the server. Therefore, I suggest keeping this feature opt-in, disabled by default. Additionally, it might be useful to use dune or something like that.

@cblavier
Copy link
Contributor

cblavier commented Dec 2, 2024

Custom code evaluation was indeed limited for security reasons.
I like the idea of using something like dune, I wasn't aware of this lib.

We could also consider implementing custom slot templates.
However, would it be too cumbersome to write them in a textarea?

Let's add it to the backlog! 📚

@cblavier cblavier added the enhancement New feature or request label Dec 2, 2024
@xxdavid
Copy link
Contributor Author

xxdavid commented Dec 2, 2024

Great! For me, it'd be totally fine to use a plain textarea to edit the slots. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants