-
Notifications
You must be signed in to change notification settings - Fork 135
feat: added composable Wrap/Collapse controls to CodeBlock that are SSR-safe. some memoizations too for code block #148
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
Conversation
fixed hydration flashing issue on render caused by collapsible component by moving initial state to the root CodeBlock component. i also split the context for code and ui so that the code context can be memoized.
removed the css based approach for collapsing the codeblock
made it a lot more concise
|
@eersnington is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
|
@eersnington awesome work on this PR. unfortunately it's clashed with the previously merged #149 but ill see if we can rework and re-add it in another PR 👍 |
no worries mate, the shiki rewrite was more important 🫡 |
Video Demo
https://github.com/user-attachments/assets/e81dd0a5-5ccf-4a14-ac9e-4cbc1da897a2
Hey, I was inspired by the Wrap and Collapsible buttons from Grok and T3 chat, and saw that the AI-elements version doesn't have them. So I went ahead and created a Wrap button and Collapse button that are composable, SSR-safe (doesn't flash on hydration).
Usage

Notes:
I've had to make some decisions on how the Collapsible prop is handled and create a new context too. This section is to layout my reasonings for why I've made them. Please do grill me if you think there're better ways to do it.