Skip to content

Conversation

@nhivpham
Copy link
Contributor

@nhivpham nhivpham commented Jan 20, 2026

Overview

Adds an internal detailed code component for code examples that run longer.

PR Checklist

  • Related to designs:
  • Related to JIRA ticket: GMT-257
  • I have run this code to verify it works
  • This PR includes unit tests for the code change
  • This PR includes testing instructions tests for the code change
  • The alpha package of this PR is passing end-to-end tests in all relevant Codecademy repositories

Testing Instructions

Don't make me tap the sign.

  1. Go to /?path=/docs/organisms-connectedform-connectedform--docs#example-code
  2. View example code preview
  3. Click on code drop down
  4. Close code drop down
  5. Finish and do a celebratory dance

PR Links and Envs

Repository PR Link
Monolith Monolith PR
Mono Mono PR

@nhivpham nhivpham requested a review from a team as a code owner January 20, 2026 18:34
@nhivpham nhivpham marked this pull request as draft January 20, 2026 18:35
@nx-cloud
Copy link

nx-cloud bot commented Jan 20, 2026

View your CI Pipeline Execution ↗ for commit 2711ba7


☁️ Nx Cloud last updated this comment at 2026-01-20 21:35:29 UTC

@codecademydev
Copy link
Collaborator

📬 Published Alpha Packages:

@codecademy/gamut@67.6.4-alpha.94f59d.0
@codecademy/gamut-kit@0.6.577-alpha.94f59d.0
@codecademy/styleguide@78.5.6-alpha.94f59d.0

@github-actions
Copy link
Contributor

Copy link
Contributor

@LinKCoding LinKCoding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like what you've done!

I've added some notes to polish up the PR, but would love to hear your thoughts :)
Thanks for taking this on!

language,
}) => {
return (
<DetailedCodeBodyWrapper column>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this Wrapper is already using CSS on a FlexBox, I think you can instead add a flexDirection: 'column' to the object passed into the css() function.

};

return (
<FlexBox>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this parent FlexBox needed?

width="100%"
>
<FlexBox alignItems="center" columnGap={12}>
{heading && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: when would a heading be provided? i.e. what is a heading used for?

export const DetailedCodeButton: React.FC<DetailedCodeButtonProps> = ({
heading,
isExpanded,
language,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider defaulting to tsx

import { FlexBox } from '../Box';

export const DetailedCodeWrapper = styled(FlexBox)(
css({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: here's where FlexDirection could be added

Comment on lines +30 to +33
'& > div': {
borderRadius: 'none',
padding: 0,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this could be omitted and the .docblock-source could get a borderRadius: 'none'

? getPreviewCode(code, normalizedPreviewLines)
: code;

// Show the button to expand the code if there is more code than the preview lines, and hide the button if there is no more code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very much a nit, but I don't think you need this comment

@@ -0,0 +1,67 @@
export const codeExample = `import {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file could be renamed to examples.ts to follow the naming convention of other examples in this repo

Comment on lines +62 to +64
<Rotation height={16} rotated={isExpanded} width={16}>
<MiniChevronDownIcon aria-hidden size={16} />
</Rotation>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like we should have something more overt to indicate that this button will "show more code"

Or that there is more code to display.

My first thought is to have something shown right under the code snippet that is a TextButton that has ... show more code" that also has the same handleClick`

but would want to hear your thoughts

borderRadius: 'none',
padding: 0,
},
'& .docblock-source': {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also did some styling testing and it seems like targeting the .docblock-source is the most consistent want to apply the styling :\ so that seems to be just the way to do it.

but I think it warrants adding a note for why it has to be done this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants