-
Notifications
You must be signed in to change notification settings - Fork 4
#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
base: main
Are you sure you want to change the base?
Conversation
|
||
export type DictionaryHeaderProps = { | ||
type DictionaryHeaderProps = { |
There was a problem hiding this comment.
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'} |
There was a problem hiding this comment.
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'}
?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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) + '... '; |
There was a problem hiding this comment.
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
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
DictionaryHeader
which displays current dictionary name, version and descriptionReadiness Checklist
.env.schema
file and documented in the README