Skip to content
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

[docs] Improve fragment links #18667

Closed
wants to merge 9 commits into from
Closed

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Dec 3, 2019

Example: https://deploy-preview-18667--material-ui.netlify.com/api/app-bar/

  1. fragment links are now always displayed
    Affordance was only discoverable with hover (suboptimal). It's now obvious as well as accessible to everyone.
  2. fix hydration mismatch for fragment links while reducing bundle size impact.
    Use <symbol /> to ship (large) path once and reference it multiple times while being able to use :hover styles (which is not available in <img src="*.svg" />. Deduplicates labelling as well.
  3. make props and css classes linkable
  4. Use title for fragment links to explain explicitly where the link goes
  5. Display fragment link to the left of the heading to visually explain that these are not part of the document flow.

@eps1lon eps1lon added new feature New feature or request docs Improvements or additions to the documentation labels Dec 3, 2019
@mui-pr-bot
Copy link

mui-pr-bot commented Dec 3, 2019

Details of bundle changes.

Comparing: b14c7a4...f27b8fe

bundle Size Change Size Gzip Change Gzip
docs.main ▲ +256 B (+0.04% ) 609 kB ▲ +125 B (+0.06% ) 194 kB
@material-ui/core -- 354 kB -- 96.7 kB
@material-ui/core[umd] -- 311 kB -- 89.6 kB
@material-ui/lab -- 173 kB -- 52.2 kB
@material-ui/styles -- 51 kB -- 15.3 kB
@material-ui/system -- 14.8 kB -- 4.06 kB
AppBar -- 62.7 kB -- 19.5 kB
Autocomplete -- 127 kB -- 39.7 kB
Avatar -- 61.7 kB -- 19.3 kB
Backdrop -- 66.6 kB -- 20.5 kB
Badge -- 64.2 kB -- 19.9 kB
BottomNavigation -- 61.3 kB -- 19.1 kB
BottomNavigationAction -- 74.3 kB -- 23.4 kB
Box -- 69.6 kB -- 21 kB
Breadcrumbs -- 66.9 kB -- 20.8 kB
Button -- 78.3 kB -- 23.9 kB
ButtonBase -- 72.8 kB -- 22.7 kB
ButtonGroup -- 80.9 kB -- 24.8 kB
Card -- 61.6 kB -- 19.2 kB
CardActionArea -- 73.9 kB -- 23.2 kB
CardActions -- 60.9 kB -- 19 kB
CardContent -- 60.9 kB -- 19 kB
CardHeader -- 64 kB -- 20 kB
CardMedia -- 61.2 kB -- 19.2 kB
Checkbox -- 80.6 kB -- 25.3 kB
Chip -- 81.4 kB -- 24.8 kB
CircularProgress -- 63 kB -- 19.8 kB
ClickAwayListener -- 3.87 kB -- 1.56 kB
Collapse -- 66.8 kB -- 20.6 kB
colorManipulator -- 3.85 kB -- 1.52 kB
Container -- 62 kB -- 19.3 kB
CssBaseline -- 56.4 kB -- 17.6 kB
Dialog -- 81.5 kB -- 25.4 kB
DialogActions -- 61 kB -- 19 kB
DialogContent -- 61.1 kB -- 19.1 kB
DialogContentText -- 62.9 kB -- 19.7 kB
DialogTitle -- 63.2 kB -- 19.7 kB
Divider -- 61.5 kB -- 19.2 kB
docs.landing -- 52.4 kB -- 11.4 kB
Drawer -- 83.2 kB -- 25.2 kB
ExpansionPanel -- 70.1 kB -- 21.8 kB
ExpansionPanelActions -- 61 kB -- 19 kB
ExpansionPanelDetails -- 60.8 kB -- 19 kB
ExpansionPanelSummary -- 76.9 kB -- 24.2 kB
Fab -- 75.6 kB -- 23.5 kB
Fade -- 22.4 kB -- 7.71 kB
FilledInput -- 72.3 kB -- 22.4 kB
FormControl -- 63.3 kB -- 19.6 kB
FormControlLabel -- 64.4 kB -- 20.1 kB
FormGroup -- 60.9 kB -- 19 kB
FormHelperText -- 62.1 kB -- 19.4 kB
FormLabel -- 62.4 kB -- 19.2 kB
Grid -- 64 kB -- 20 kB
GridList -- 61.4 kB -- 19.2 kB
GridListTile -- 62.6 kB -- 19.5 kB
GridListTileBar -- 62.1 kB -- 19.3 kB
Grow -- 23.1 kB -- 7.83 kB
Hidden -- 64.8 kB -- 20.3 kB
Icon -- 61.7 kB -- 19.2 kB
IconButton -- 75 kB -- 23.3 kB
Input -- 71.3 kB -- 22.1 kB
InputAdornment -- 64 kB -- 20 kB
InputBase -- 69.4 kB -- 21.7 kB
InputLabel -- 64.2 kB -- 20 kB
LinearProgress -- 64.2 kB -- 20 kB
Link -- 65.5 kB -- 20.6 kB
List -- 61.3 kB -- 19 kB
ListItem -- 75.9 kB -- 23.6 kB
ListItemAvatar -- 61 kB -- 19 kB
ListItemIcon -- 61.1 kB -- 19 kB
ListItemSecondaryAction -- 60.9 kB -- 19 kB
ListItemText -- 63.8 kB -- 19.9 kB
ListSubheader -- 61.6 kB -- 19.3 kB
Menu -- 87.1 kB -- 26.8 kB
MenuItem -- 77 kB -- 23.9 kB
MenuList -- 64.9 kB -- 20.2 kB
MobileStepper -- 66.6 kB -- 20.8 kB
Modal -- 14.2 kB -- 4.99 kB
NativeSelect -- 75.6 kB -- 23.7 kB
NoSsr -- 2.19 kB -- 1.03 kB
OutlinedInput -- 72.8 kB -- 22.6 kB
Paper -- 61.1 kB -- 19 kB
Popover -- 81.5 kB -- 25.1 kB
Popper -- 28.6 kB -- 10.2 kB
Portal -- 2.87 kB -- 1.29 kB
Radio -- 81.5 kB -- 25.6 kB
RadioGroup -- 62.1 kB -- 19.4 kB
Rating -- 68.9 kB -- 22.1 kB
RootRef -- 4.43 kB -- 1.67 kB
Select -- 113 kB -- 33.5 kB
Skeleton -- 61.4 kB -- 19.3 kB
Slide -- 24.5 kB -- 8.32 kB
Slider -- 74.5 kB -- 23.3 kB
Snackbar -- 76 kB -- 23.7 kB
SnackbarContent -- 64.5 kB -- 20.2 kB
SpeedDial -- 84.9 kB -- 26.7 kB
SpeedDialAction -- 115 kB -- 36.5 kB
SpeedDialIcon -- 63.5 kB -- 19.9 kB
Step -- 61.5 kB -- 19.2 kB
StepButton -- 81.1 kB -- 25.5 kB
StepConnector -- 61.6 kB -- 19.3 kB
StepContent -- 67.9 kB -- 21.2 kB
StepIcon -- 63.5 kB -- 19.7 kB
StepLabel -- 67.5 kB -- 21.1 kB
Stepper -- 63.6 kB -- 20 kB
styles/createMuiTheme -- 15.6 kB -- 5.47 kB
SvgIcon -- 61.9 kB -- 19.3 kB
SwipeableDrawer -- 90.6 kB -- 28 kB
Switch -- 80 kB -- 25 kB
Tab -- 75.2 kB -- 23.7 kB
Table -- 61.4 kB -- 19.2 kB
TableBody -- 61 kB -- 19 kB
TableCell -- 62.9 kB -- 19.7 kB
TableFooter -- 61 kB -- 19 kB
TableHead -- 61 kB -- 19 kB
TablePagination -- 140 kB -- 40.7 kB
TableRow -- 61.4 kB -- 19.1 kB
TableSortLabel -- 76.2 kB -- 23.9 kB
Tabs -- 84.3 kB -- 26.5 kB
TextareaAutosize -- 5.06 kB -- 2.11 kB
TextField -- 122 kB -- 35.5 kB
ToggleButton -- 75 kB -- 23.7 kB
ToggleButtonGroup -- 62.1 kB -- 19.4 kB
Toolbar -- 61.2 kB -- 19.1 kB
Tooltip -- 99.4 kB -- 31.4 kB
TreeItem -- 72.5 kB -- 22.8 kB
TreeView -- 65.3 kB -- 20.4 kB
Typography -- 62.5 kB -- 19.5 kB
useAutocomplete -- 12.4 kB -- 4.56 kB
useMediaQuery -- 2.49 kB -- 1.05 kB
Zoom -- 22.5 kB -- 7.71 kB

Generated by 🚫 dangerJS against f27b8fe

@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 3, 2019

  1. Do you have examples of great documentations that use this approach?
  2. Smart. Thanks for fixing it! :)
  3. Do you have a specific use case in mind?

@eps1lon
Copy link
Member Author

eps1lon commented Dec 3, 2019

  1. Do you have a specific use case in mind?

When I want to link to a specific prop.

  1. Do you have examples of great documentations that use this approach?

https://css-tricks.com/ does it. But more importantly I can link you many documentations that do it badly: everyone that reveals the links on hover while focus does not reveal them. Reveal on focus is an option but it's simpler to always display them anyway so that we don't have to rely on knowledge of convention.

@oliviertassinari
Copy link
Member

When I want to link to a specific prop.

Interesting, I'm wondering because I tend not to take the time to provide an exact link to the API page, I tend to mention the name of the prop, and move to something else. I'm curious to see how people will use this link.

everyone that reveals the links on hover while focus does not reveal them.

I believe that most remove the anchor from the tab sequence. Is that an acceptable approach? If we do display the anchor, what about reducing its size to minimize the impact on readability? Or maybe reduce its contrast? @mbrookes What do you think?

@eps1lon
Copy link
Member Author

eps1lon commented Dec 3, 2019

I believe that most remove the anchor from the tab sequence. Is that an acceptable approach?

That would be worse. Links should be in tab sequence since that is their default behavior.

@eps1lon
Copy link
Member Author

eps1lon commented Dec 3, 2019

I believe that most remove the anchor from the tab sequence. Is that an acceptable approach?

That would be worse. Links should be in tab sequence since that is their default behavior.

Or maybe reduce its contrast?

Again that is worse. I'm not sure why reducing readability is a target for you. The default target is better readability. You would need to explain how reduced contrast or size improves readability or rather that the content is better perceivable.

@oliviertassinari
Copy link
Member

My assumption is that for 100 given page displays, 1 will be about clicking on a header link to later share it.

I suspect that displaying the anchor reduces readability as somebody would have to process what's this unexpected (as not frequently seen) element is about. It's only later, once he wires a model in his head to automatically ignore the display of the element that the negative impact on readability gets sorted out.

This makes me think of the "Law of Past Experience" in the Gestalt theory, and how this rule take precedence over the other ones. I don't know how reproducible this school of psychology is, but from the examples provided online, I have seen these rules work on myself. I believe that past learning people have built is very hard to break. It's one of the reasons why I love benchmark. Sometime, it's best to go with what the majority does, but not always as the majority !== what is right.

@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 3, 2019

Regarding how GitHub handles markdown's headers, do you think that they should change it?

@mbrookes
Copy link
Member

mbrookes commented Dec 3, 2019

@mbrookes What do you think?

I can't help thinking we've been around this loop before. I recall that when iterating on the TOC, at one point we were setting the hash fragment automatically, as material.io does, but that this was subsequently removed. I can't remember the specific context, but I do know we experimented with displaying the hash symbol by default, and ultimately changed it for the same reason you have given here.

I don't think discoverability of this feature is an issue. The small minority that want to link to a subsection already know how to find it. (Personally, I go as far as finding the id in the source if the site doesn't provide the feature we currently offer).

I had missed the change of icon from the hash to the link icon. No strong preference, but I have a niggling feeling the link icon has a different meaning in other contexts.

  1. make props and css classes linkable

Sorry to say, but this just adds noise. What are these links? Where do they link to? Why does nothing much appear to happen when I click on them (other than the page moving a bit)?

@oliviertassinari
Copy link
Member

I had missed the change of icon from the hash to the link icon.

@mbrookes I did this change recently, to better match the experience on React and GitHub. I have tried to move the anchor from the right to the left too but without much success.

Capture d’écran 2019-12-04 à 00 56 32
Capture d’écran 2019-12-04 à 00 56 51

@eps1lon
Copy link
Member Author

eps1lon commented Dec 4, 2019

What are these links?

I don't understand the question. Unless I interpret this as you asking what a link is this statement is pure provocation. Since I've been asked to reconsider my communication I'd like to extends this to you as well.

I already added one use case (personal communication) and want to add another one: Referencing prop descriptions on other pages to de-duplicate the description. This will be used for the label vs. labelWidth description in #17680

Where do they link to?

They link to prop which is part of the link name.

Why does nothing much appear to happen when I click on them (other than the page moving a bit)?

This is the basic behavior of the platform. Please take a step back and re-examine how you can justify going to the page source to find an id as a good signifier but reject fragment link affordance which is a basic feature of the web since it's inception. Why does this argument not apply to the current fragment links? They don't do much either and don't even have a name.

No strong preference, but I have a niggling feeling the link icon has a different meaning in other contexts.

I agree since I had trouble finding a proper name for that icon. I don't think it's part of the Material icons anyway (the "link" icon looks different). I'd prefer the hash since we then have a 1:1 mapping to link hashs and document fragments.

I suspect that displaying the anchor reduces readability as somebody would have to process what's this unexpected (as not frequently seen) element is about. It's only later, once he wires a model in his head to automatically ignore the display of the element that the negative impact on readability gets sorted out.

I extend a little bit more intelligence to our readers. I think they are capable of processing an icon while reading. This argument is again backwards ("I need to support my feelings so I construct an objective argument"). Why does this not apply to emojis? If this is a concern I'd rather move it to the start and out of the text alignment. Heading and paragraph have the same left alignment but the fragment link is clearly outside of the document flow.

Regarding how GitHub handles markdown's headers, do you think that they should change it?

I repeat what I said before: yes.

Sometime, it's best to go with what the majority does, but not always as the majority !== what is right.

This reveals the fundamental issue with your thought: The majority usage makes no statement what so ever about if it is right. It just means that it is used by many. Nothing more. It may be correlated but not caused. Convention can only be considered a sginifier if it is indeed convention. It is not though. Cherry-picking your side does nothing to advance the discussion. It only tries to win an argument which I don't care about.

- alt in a image within a link should describe the link
- added title to explain purpose for visual browsers
@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 4, 2019

This argument is again backward ("I need to support my feelings so I construct an objective argument")

This is very possible, I think that humans are post rationalizer creatures, we are very rarely rationale, maybe 10% of the time.

I think that the topic we are discussing is mainly on the human psychology level, we are looking for levers to provide the best-perceived experience. In this context, I think that providing the experience readers have learned, in the past, on the others documentations can be very effective. I would recommend going with that: look at what models developers have learned, and provide the same experience. Now, I might not be always ideal, nor right, considering somebody that is willing to invest the cognitive effort to learn a new experience.

If you think that an always visible anchor link is better, I think that we should move it to the left side before deploying the change. So people can start reading just after it.

Regarding how GitHub handles markdown's headers, do you think that they should change it?

I repeat what I said before: yes.

Thanks for the confirmation, the position is very clear.

@oliviertassinari
Copy link
Member

I agree since I had trouble finding a proper name for that icon. I don't think it's part of the Material icons anyway (the "link" icon looks different). I'd prefer the hash since we then have a 1:1 mapping to link hashs and document fragments.

So, should we go with a # icon instead?

@mbrookes
Copy link
Member

mbrookes commented Dec 4, 2019

I don't understand the question.

Then perhaps I should have put them in italicised quotes. This was the imaginary internal dialog of someone using the prop docs, outside the context of this PR. I thought it would be apparent that these were not actual questions. My bad.

I already added one use case (personal communication) and want to add another one: Referencing prop descriptions on other pages to de-duplicate the description.

I'm not at all opposed to the props having fragment identifiers, but I personally think it would both offer a better affordance, and be less visually intrusive, to use the same approach we currently use for the page headings.

reject fragment link affordance which is a basic feature of the web since it's inception.

I'm not rejecting fragment links, I'm asking whether the proposed method for setting them is the best option.

Why does this argument not apply to the current fragment links?

Because the icon indicates that the purpose of the link is to set the fragment id, this being a pattern that is used widely enough to be recognisable to the majority of users.

I did this change recently, to better match the experience on React and GitHub.

Thanks for the background.

@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 5, 2019

  • It seems that the icon can be cut off:

Capture d’écran 2019-12-05 à 17 16 20

fix hydration mismatch for fragment links while reducing bundle size impact.

  • It seems that we have a 2nd hydration issue.

Capture d’écran 2019-12-05 à 17 17 24

I could narrow it down to vercel/next.js#6904, or at least, it's present on a blank page with Next 8.1.0 and solved with 9.1.4. Hopefully, it will be solved with #18441 :).

@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 5, 2019

What do you think of this tradeoff: https://www.telerik.com/kendo-angular-ui/components/inputs/slider/? There is no anchor/link icon, but the headers are links, this looks like an interesting compromise.

@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 7, 2019

@eps1lon What do you think of scoping the changes to the hydration issue (point number 2) in this pull request? I think that the link changes will need further iteration.

@eps1lon
Copy link
Member Author

eps1lon commented Dec 11, 2019

See internal chat.

@eps1lon eps1lon closed this Dec 11, 2019
@eps1lon eps1lon deleted the docs/link-props branch December 11, 2019 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants