Skip to content

#261: Implementation of Header Component #284

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

SaqAsh
Copy link

@SaqAsh SaqAsh commented Jun 4, 2025

Summary

Implement dictionary header component, based off of the theming as well as adding in tests to exercise edge cases

Related Issue

Description of Changes

UI

  • Continued the development of new component DictionaryHeader which displays current dictionary name, version and description
  • Added logic to truncate descriptions beyond a character threshold and display a “Show more”/“Read less” toggle
  • Add more exemplars inside of the storybook to exercise the truncation state

Readiness Checklist

  • Self Review
    • I have performed a self review of code
    • I have run the application locally and manually tested the feature
    • I have checked all updates to correct typos and misspellings
  • Formatting
    • Code follows the project style guide
    • Autmated code formatters (ie. Prettier) have been run
  • Local Testing
    • Successfully built all packages locally
    • Successfully ran all test suites, all unit and integration tests pass
  • Updated Tests
    • Unit and integration tests have been added that describe the bug that was fixed or the features that were added
  • Documentation
    • All new environment variables added to .env.schema file and documented in the README
    • All changes to server HTTP endpoints have open-api documentation
    • All new functions exported from their module have TSDoc comment documentation

@SaqAsh SaqAsh requested review from joneubank and ciaranschutte June 4, 2025 16:09

export type DictionaryHeaderProps = {
type DictionaryHeaderProps = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please export component props

<span css={descriptionStyle(theme)}>{textToShow}</span>
{needsToggle && (
<span css={linkStyle(theme)} onClick={() => setIsExpanded((prev) => !prev)}>
{isExpanded ? ' Read less' : ' Show more'}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the empty space preceding the text?
Would you consider instead {' '}{isExpanded ? 'Read less' : 'Show more'}?

Copy link
Author

Choose a reason for hiding this comment

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

Good point, didn't think to do that

justify-content: center;
`;

// These constants can be adjusted based on design requirements
Copy link
Contributor

Choose a reason for hiding this comment

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

All constants can be adjusted ;)

Can we change this comment to instead explain what this threshold is used for and/or why it is set to this default?

I would suggest renaming to DESCRIPTION_LENGTH_THRESHOLD. Specificity + comment description is helpful.

@SaqAsh SaqAsh requested a review from joneubank June 10, 2025 18:06
Comment on lines +121 to +125
const needsToggle = description && description.length > DESCRIPTION_LENGTH_THRESHOLD;
// We want to show all the text if it is not long or if it is already expanded via state variable
const showFull = isExpanded || !needsToggle;
// Based off of showFull, we determine the text to show, either its the full description or a truncated version
const textToShow = showFull ? description : description.slice(0, DESCRIPTION_LENGTH_THRESHOLD) + '... ';
Copy link
Author

@SaqAsh SaqAsh Jun 19, 2025

Choose a reason for hiding this comment

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

Was not too happy with this implementation, I have refactored this into something that appropriately implements this to spec in another branch

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.

2 participants