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(Props): make large code blocks more legible #2215

Merged
merged 2 commits into from
Oct 22, 2017

Conversation

redbmk
Copy link
Contributor

@redbmk redbmk commented Oct 19, 2017

Components with large blocks of Default code
cause the table to extend beyond the page, making
it difficult to read. Make the code wrap properly
and allow the container to scroll.

As a specific example, this can be seen in the props
for Search.Result.

@@ -124,6 +124,8 @@
font-size: 87.5%;
background-color: rgba(0, 0, 0, 0.04);
border-radius: 3px;
white-space: pre;
display: inline-block;
Copy link
Member

Choose a reason for hiding this comment

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

With proper whitespace, now the padding-top and padding-bottom need to be adjusted to match. The block element now has too much bottom padding.

Let's go with padding: 0.1em 0 instead of the 3 rules currently in place (see line 120-123).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem. After looking at it some more though, it looks like with padding: 0.1em 0, display: inline-block pushes the text up. Try setting both those rules in e.g. the Icon docs, then toggle the display setting on and off in dev tools - you'll see the text bounce up and down. If we use padding: 0 though, the code padding will still look larger but without pushing the text around.

It's your call though - just let me know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went ahead and added the padding: 0.1em 0 as a separate commit. Let me know if you want me to change it or squash them.

Copy link
Member

Choose a reason for hiding this comment

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

I see what you're saying. I think padding: 0; looks great. In fact, removing all padding rules may be the same thing in this case. Try it with no padding rules and see what you think.

I'll let you make the call and we'll ship it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A good point. Let's go with that

@levithomason
Copy link
Member

Nice fix, thanks! I've left one comment. Also, please run yarn test and yarn lint locally to see why tests are failing.

@redbmk
Copy link
Contributor Author

redbmk commented Oct 19, 2017

It looks like all tests are passing. I'm getting a few linting warnings, but not errors, and not in anything I touched.

SUMMARY:
✔ 9319 tests completed

=============================== Coverage summary ===============================
Statements   : 97.08% ( 3362/3463 )
Branches     : 93.93% ( 1610/1714 )
Functions    : 97.27% ( 642/660 )
Lines        : 98.23% ( 3048/3103 )
================================================================================
Done in 159.52s.
yarn run v1.2.1
$ cross-env NODE_ENV=production eslint .

/home/bmk/code/semantic-ui-react/docs/app/utils.js
  19:31  warning  Unexpected unnamed function  func-names

/home/bmk/code/semantic-ui-react/src/collections/Form/FormField.js
  83:9  warning  Form label must have associated control  jsx-a11y/label-has-for

/home/bmk/code/semantic-ui-react/src/elements/Image/Image.js
  94:7  warning  img elements must have an alt prop, either with meaningful text, or an empty string for decorative images  jsx-a11y/alt-text

/home/bmk/code/semantic-ui-react/src/lib/factories.js
  20:8  warning  Function 'createShorthand' has a complexity of 25  complexity

/home/bmk/code/semantic-ui-react/src/modules/Checkbox/Checkbox.js
  244:36  warning  Form label must have associated control  jsx-a11y/label-has-for

/home/bmk/code/semantic-ui-react/src/modules/Embed/Embed.js
  182:25  warning  img elements must have an alt prop, either with meaningful text, or an empty string for decorative images  jsx-a11y/alt-text

/home/bmk/code/semantic-ui-react/src/modules/Rating/RatingIcon.js
  117:9  warning  Elements with the ARIA role "radio" must have the following attributes defined: aria-checked  jsx-a11y/role-has-required-aria-props

✖ 7 problems (0 errors, 7 warnings)

@codecov-io
Copy link

codecov-io commented Oct 19, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@4f29636). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2215   +/-   ##
=========================================
  Coverage          ?   99.73%           
=========================================
  Files             ?      151           
  Lines             ?     2624           
  Branches          ?        0           
=========================================
  Hits              ?     2617           
  Misses            ?        7           
  Partials          ?        0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4f29636...604ae45. Read the comment docs.

@levithomason
Copy link
Member

Once we get final word from @redbmk that he is happy with the code padding, we can ship this one.

@levithomason
Copy link
Member

Oh boy, appears the doc perf refactor just merged gives quite the conflict here. I believe the component which had the inline style has moved. Apologies, you may need to run the docs and see which component that is now.

@redbmk
Copy link
Contributor Author

redbmk commented Oct 20, 2017

Ah, yeah I wasn't expecting that. No worries though, I found where it needs to go.

I took out all the padding rules, which do have the same effect as padding: 0, then I figured I might as well take out the margin rules as well for the same reason.

I merged in with the latest master and squashed it back down to a single commit.

@@ -50,7 +50,7 @@ export default class ComponentProps extends Component {
/>

{activeName && (
<div>
<div style={{ overflowX: 'auto' }}>
Copy link
Member

@layershifter layershifter Oct 20, 2017

Choose a reason for hiding this comment

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

Please extract this style to variable like there. Double curly braces are performance killer as they always return the new object on each render. I'm not sute about this case, possible @levithomason can correct me

Copy link
Contributor Author

@redbmk redbmk Oct 20, 2017

Choose a reason for hiding this comment

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

No problem. I went ahead and moved that into a const. Even if it doesn't make a difference, it couldn't hurt.

Components with large blocks of Default code
cause the table to extend beyond the page, making
it difficult to read. Make the code wrap properly
and allow the container to scroll.

As a specific example, this can be seen in the props
for Search.Result.
@layershifter layershifter changed the title docs: make large code blocks more legible docs(Props): make large code blocks more legible Oct 21, 2017
@levithomason levithomason merged commit deed986 into Semantic-Org:master Oct 22, 2017
@levithomason
Copy link
Member

Released in semantic-ui-react@0.76.0

@redbmk redbmk deleted the large-code-blocks branch February 13, 2018 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants