Conversation
9ae228e to
6ee35c1
Compare
…zammi/feat/code-tabs
|
I'm happy with this PR! Before marking it as Ready for Review, I just want to mention something. I plan to add two new remark plugins that will also use the
Example usage for :::tabs items=["hono", "express.js", "fastify"] defaultValue=hono persistId=selected_server
```ts tab=hono // We could skip adding `tab=tabname` if the content always follows the order of the items above
// hono code
```
```ts tab=express.js
// express.js code
```
```ts tab=fastify
// fastify code
```
:::Questions:
Please let me know what you think. If you’d prefer we handle this in separate PRs, I’ll go ahead and mark this one as Ready for Review. |
|
I just played with the demo, very nice!
Love it 💯
That sounds awesome.
Yes, in general, let's avoid duplication of code and logic. Instead, let's try to cover all requirements with a one or two features, and with one cohesive piece of code. Actually, I wonder whether/how we can consolidate some of our previous work about the JS toggle with this PR. But, before that, let's first focus on the overall design. I wonder if tabs are the best solution here. One neat thing about tabs is that the user sees all options at a glance. One issue with tabs is that we cannot have two sets of tabs. I remember we had some discussions about this (I believe it was on Discord) — let me re-read the discussion again and circle back on the overall design (IIRC we came to the conclusion that there aren't any use cases for two sets of tabs). In the meantime, feel free to bounce back ideas. |
So, yea, that was the conclusion of our discussion. |
|
I'm thinking maybe we can replace tabs with following idea. How about, when With "clean dropdown" I mean something visually appealing, e.g. the same as the JS toggle but vertical instead of horizontal. I think we can then have a single feature that covers all use cases. WDYT? |
I think so. We can do something similar to https://github.com/mrazauskas/docusaurus-remark-plugin-tab-blocks?tab=readme-ov-file#span |
|
How about this? ```bash choice=hono,npm |
|
Since we're going to create the remarkPkgManager plugin, which:
So, what about something like the following: The Later, ```shell tab=hono tab-children=2
npm i hono @photonjs/hono
```
```ts
// server/index.ts
import { Hono } from 'hono'
import { apply, serve } from 'vike-photon/hono'
function startServer() {
const app = new Hono()
apply(app)
return serve(app)
}
export default startServer()
```
```shell tab=express tab-children=2
npm i express @photonjs/express
```
```ts
// server/index.ts
import express from 'express'
import { apply, serve } from 'vike-photon/express'
function startServer() {
const app = express()
apply(app)
return serve(app)
}
export default startServer()
``` |
|
We can also have So far, I still prefer ```shell choice=hono
npm i hono @photonjs/hono
```
```shell choice=express
npm i express @photonjs/express
```
```ts choice=hono
// server/index.ts
import { Hono } from 'hono'
import { apply, serve } from 'vike-photon/hono'
function startServer() {
const app = new Hono()
apply(app)
return serve(app)
}
export default startServer()
```
```ts choice=express
// server/index.ts
import express from 'express'
import { apply, serve } from 'vike-photon/express'
function startServer() {
const app = express()
apply(app)
return serve(app)
}
export default startServer()
```Note how the shell commands are co-located. (Another advantage is that we can have multiple choices if we need to in the future.) I don't see advantages of Also, if we go with this design then |
- TODO: refactor to replace CodeTabs with a non-Tabs component
- refactor `remarkPkgManager` to use CodeGroup instead of CodeTabs
…zammi/feat/code-tabs
What do you think of these ? |
|
👍 I think I like it. Little nitpick: I think we can remove some of the code introduced by a58173a. |
Like this : keep using I also make sure to hide the select dropdown for single choice, do you think that's okay ? |
|
Yes, that's actually what I was thinking. (Maybe there is more potential to remove code, but I didn't dig much into it.) |
👍 Sounds good. |
I like your ideas and think they’re doable, but are we sure we want to include them in this PR? I’m worried it might get confusing. |
|
👍 You're right, let's do it in a separate PR. |
|
This PR doesn't change So we can merge this PR, release a new version, then |
Great 👍.
Correct, I’m sure it won’t. I think the last thing to do in this PR is |
I think we can keep it. Actually, let's add some tests before merging. The tests will be extremely helpful for our subsequent refactor PR.
If you want, I can do it (as you wish) after we have some tests. |
Ah, actually, how about remarkPkgManager? I think that's a breaking change? |
Ah, yes — you’re right. My bad, I forgot about that. |
|
It isn't that bad though, right? We just need to update the few places where it would break After we have tests, feel free to go ahead and merge, release, and update |
Okay 👍 |
|
What do you think of the tests (add tests). Are they sufficient, or is it too much? |
|
Nice. I definitely wouldn't say too much. If anything I'd recommend to make them cover more aspects of the implementation, so that you can refactor everything without testing manually (or just occasionally to double check). But as you wish. Little nitpick: the last part of the test is difficult to understand (e.g not sure what the for-loop does, and not sure why you discriminate dev/prod). (But tbh I frequently write unclear test myself. Tests can be dirty, that's okay — bad tests don't jeopardize the overall structure of the program.) |
|
Thanks! Ready to squash and merge now. |
|
💯 Feel free to self squash, merge, and release. |
|
Released as |


closes #52,
closes #53
This pull request introduces:
<ChoiceGroup>remarkChoiceGroupwhich collects and groups code blocks by choice and wraps them with theChoiceGroupcomponent.remarkPkgManagerwhich convertsnpm/npxcommands to theirpnpm,yarn, andbunequivalents, then wraps them with theChoiceGroupcomponent.