-
Notifications
You must be signed in to change notification settings - Fork 455
✨(frontend) improve mobile UX by showing subdocs count #1540
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
helps users notice root documents have children in mobile view Signed-off-by: Cyril <c.gromoff@gmail.com>
e79dba5 to
050189f
Compare
| {isDesktop ? ( | ||
| <> | ||
| <Text | ||
| $variation="600" | ||
| $size="s" | ||
| $weight="bold" | ||
| $theme={isEditable ? 'greyscale' : 'warning'} | ||
| > | ||
| {transRole( | ||
| isEditable ? doc.user_role || doc.link_role : Role.READER, | ||
| )} | ||
| · | ||
| </Text> | ||
| <Text $variation="600" $size="s"> | ||
| {dateToDisplay} | ||
| </Text> | ||
| </> | ||
| ) : ( | ||
| <> | ||
| <Text $variation="400" $size="s"> | ||
| {hasChildren ? relativeOnly : dateToDisplay} | ||
| </Text> | ||
| {hasChildren ? ( | ||
| <Text $variation="400" $size="s"> | ||
| • | ||
| {t('Contains {{count}} sub-documents', { | ||
| count: childrenCount, | ||
| })} | ||
| </Text> | ||
| ) : null} | ||
| </> |
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.
@AntoLC I was hesitating to create DocHeaderInfoDesktop and DocHeaderInfoMobile components to make this component clearer and more readable. We would just have a bit of props drilling, what do you think?
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.
I think it is ok, but to improve a bit readability you can maybe do:
if(isDesktop){
return ...
}
return ...|
Size Change: +232 B (+0.01%) Total Size: 3.68 MB
|
| {hasChildren ? ( | ||
| <Text $variation="400" $size="s"> | ||
| • | ||
| {t('Contains {{count}} sub-documents', { | ||
| count: childrenCount, | ||
| })} | ||
| </Text> | ||
| ) : null} |
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.
| {hasChildren ? ( | |
| <Text $variation="400" $size="s"> | |
| • | |
| {t('Contains {{count}} sub-documents', { | |
| count: childrenCount, | |
| })} | |
| </Text> | |
| ) : null} | |
| {hasChildren && ( | |
| <Text $variation="400" $size="s"> | |
| • | |
| {t('Contains {{count}} sub-documents', { | |
| count: childrenCount, | |
| })} | |
| </Text> | |
| )} |
| const { data: childrenPage } = useDocChildren( | ||
| { docId: doc.id, page_size: 1 }, | ||
| { enabled: true }, | ||
| ); | ||
| const countFromTreeContext = | ||
| treeContext?.root?.id === doc.id | ||
| ? treeContext?.treeData?.nodes?.length | ||
| : undefined; | ||
|
|
||
| const childrenCount = | ||
| countFromTreeContext ?? | ||
| childrenPage?.count ?? | ||
| doc.numchild ?? | ||
| tree?.children?.length ?? | ||
| 0; | ||
|
|
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.
Do we really need all that ? Why is doc.numchild not enough ?
| let dateToDisplay = t('Last update: {{update}}', { | ||
| update: relativeDate(doc.updated_at), | ||
| }); | ||
| const relativeOnly = relativeDate(doc.updated_at); | ||
|
|
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.
| let dateToDisplay = t('Last update: {{update}}', { | |
| update: relativeDate(doc.updated_at), | |
| }); | |
| const relativeOnly = relativeDate(doc.updated_at); | |
| const relativeOnly = relativeDate(doc.updated_at); | |
| let dateToDisplay = t('Last update: {{update}}', { | |
| update: relativeOnly, | |
| }); | |
| {isDesktop ? ( | ||
| <> | ||
| <Text | ||
| $variation="600" | ||
| $size="s" | ||
| $weight="bold" | ||
| $theme={isEditable ? 'greyscale' : 'warning'} | ||
| > | ||
| {transRole( | ||
| isEditable ? doc.user_role || doc.link_role : Role.READER, | ||
| )} | ||
| · | ||
| </Text> | ||
| <Text $variation="600" $size="s"> | ||
| {dateToDisplay} | ||
| </Text> | ||
| </> | ||
| ) : ( | ||
| <> | ||
| <Text $variation="400" $size="s"> | ||
| {hasChildren ? relativeOnly : dateToDisplay} | ||
| </Text> | ||
| {hasChildren ? ( | ||
| <Text $variation="400" $size="s"> | ||
| • | ||
| {t('Contains {{count}} sub-documents', { | ||
| count: childrenCount, | ||
| })} | ||
| </Text> | ||
| ) : null} | ||
| </> |
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.
I think it is ok, but to improve a bit readability you can maybe do:
if(isDesktop){
return ...
}
return ...
Purpose
Improve mobile user experience by indicating when a document or a subdocument has children.
issue : 1314
Proposal