-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
[next] markdown code block use cases (script, render, story, preview, ...) #315
Comments
|
this get's quite complicated... maybe use a "full" configuration? 🤔
|
follow-up to the discussion #288 my use cases extend the proposal above with the following:
in addition to that I also want to
the syntax it might solve the following cases:
and last, but not least: object syntax will be easier to extend in the future, using real JS pseudo code ---
defaultStoryConfig: { openCode: true, renderMethod: 'iframe' }
---
```js story({ ...defaultStoryConfig, minHeight: '200px' })
export const myStory = () => html`...my-story-code...`;
``` since we have ## Setup
Setup data for demos:
```js script({ showCode: true })
import { html } from `lit`;
const users = [
{ firstName: 'John', lastName: 'Doe' },
{ firstName: 'Jane', lastName: 'Doe' },
];
```
Setup styles for demos:
```html story({ showCode: true })
<style>
/* some basic styles, e.g. for ul and li */
</style>
```
## Demos
### Demo in Light DOM (+ code block open by default)
```js story({ showCode: true, withFrame: true, openCode: true })
export const listOfUsers = () => html`
<ul>
${users.map(user => html`<li>${user.firstName} ${user.lastName}</li>`)}
</ul>
`;
```
### Demo in Shadow DOM
```js story({ showCode: true, withFrame: true, renderMethod: 'ShadowDOM' })
export const listOfUsers = () => html`
<style>
/* some isolated styles */
</style>
<ul>
${users.map(user => html`<li>${user.firstName} ${user.lastName}</li>`)}
</ul>
`;
```
### Demo in Iframe
```js story({ showCode: true, withFrame: true, renderMethod: 'iframe' })
// isolated JS env
import 'path/to/my-user.define.js'
export const listOfUsers = () => {
const localUsers = [...];
return html`
<style>
/* some isolated styles */
</style>
<ul>
${localUsers.map(user => html`<li><my-user user=${user}></my-user></li>`)}
</ul>
`;
}
``` I'd improve the names like this:
I'm just scraping the surface here, but I'll be happy to work on a test suite with many input/output examples for my use cases. Do you already have or are you planning to set smth up? I can either extend it or start making it myself and let you extend with your cases later. |
all your examples are meant to run so it would be Comparing client VS server of
|
puuhhh that is getting more and more complex 😅 I think the workflow should be
so this might be a little bit 😅 as I do not want to block you... here are two ideas |
not really also, why do you want to be explicit about it? I mean your end goal is to render, so if you can prerender on the server, then do it as a perf optimisation, if you can't, leave it to the client, if smth doesn't go right automatically, then forcing client/server via an option can give a way to solve it ```js server render
export const foo = () => html`<p>content</p>`;
```
⤵️
<p>content</p> this example makes me think we are talking about 2 different "server" render:
the 1 is pretty simple to do on the server, even if |
thanks for suggesting a way to unblock me :) I agree it's good to start small and solve the low hanging fruits first, but from my perspective the most valuable low hanging fruits are the ones which would solve my 2 issues here: given the current syntax, I'd introduce 2 new keys as previously discussed in #288, except that after all good input we had here I'd name them differently, currently I like |
sounds good to me 👍 looking forward to a PR 🤗 |
in markdown we currently have this
but we also have more
Markdown
which shows/executes the code at the place of the code block on the client
e.g. the above example would become
HTML
Rendered
Question
now the question is... would that make sense server-side as well? I guess... and what should the key be 🤔
should it retain the
story
? or a complete "new" set?suggestion from the top of my head...
js server
js server inject
js server inject-frame
js client
js client inject
(formerjs story
)js client inject-frame
(formerjs story-preview
)hmmm
inject
,inject-frame
seems not very intuitive... anyone got better ideas? 🤔The text was updated successfully, but these errors were encountered: