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

Rework styling using styled-components #2517

Merged
merged 12 commits into from
Dec 18, 2018
Merged

Rework styling using styled-components #2517

merged 12 commits into from
Dec 18, 2018

Conversation

paulmelnikow
Copy link
Member

The CSS in the project is relatively difficult to change. While it is very DRY, it relies heavily on inheritance. It's difficult to make changes in the markup modal without it also affecting styles elsewhere.

styled-components is one of the leading CSS-in-JS libraries. By reducing dependency on global state and CSS inheritance, styles become explicit and are easier to inspect and change. It's also convenient that styles can be embedded with the components they modify.

At runtime, the library creates CSS classes, so it's pretty efficient.

We were using a little bit of styled-jsx before, which ships with Next.js, though styled-components is more widely used and I've had good experiences with it all around.

In a few cases I've duplicated styles where it feels more natural to do that: for example, text-align: center is duplicated in Main and MarkupModal.

Much of this is a refactor, though there are a few visual changes, particularly in the markup modal and the style examples:

screen shot 2018-12-12 at 4 46 15 pm

screen shot 2018-12-12 at 4 46 48 pm

Blocking further work on #2496.

@paulmelnikow paulmelnikow added frontend The Docusaurus app serving the docs site blocker PRs and epics which block other work labels Dec 12, 2018
@shields-ci
Copy link

shields-ci commented Dec 12, 2018

Messages
📖 ✨ Thanks for your contribution to Shields, @paulmelnikow!
📖

Thanks for contributing to our documentation. We ❤️ our documentarians!

Generated by 🚫 dangerJS against bdb0d6d

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2517 December 12, 2018 22:05 Inactive
@paulmelnikow paulmelnikow mentioned this pull request Dec 13, 2018
12 tasks
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2517 December 13, 2018 21:03 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2517 December 16, 2018 19:57 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2517 December 16, 2018 20:00 Inactive
@chris48s
Copy link
Member

I'll probably need to give this a second read, but here's some feedback after playing with it a bit on staging.


This text should be in the centre instead of off to the left:

screenshot at 2018-12-16 19-52-02


I find this text:

screenshot at 2018-12-16 19-53-54

harder to read than this:

screenshot at 2018-12-16 19-54-29

I think keeping the text left-aligned within the table cells would be better


Truncating this text is unhelpful - it means we can't copy & paste it properly:

screenshot at 2018-12-16 19-57-40


Should this:

screenshot at 2018-12-16 20-15-46

be styled the same as this:

screenshot at 2018-12-16 20-16-07

..and this:

screenshot at 2018-12-16 20-16-19

@paulmelnikow
Copy link
Member Author

paulmelnikow commented Dec 16, 2018

Thanks for digging in. Some of this looks different than what I'm seeing. Which browser are you using? Reproduced in staging. Looks like either I broke something or there's some disparity between dev and staging.

Truncating this text is unhelpful - it means we can't copy & paste it properly:

The truncation happens in CSS so copy and paste should work…

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2517 December 17, 2018 19:24 Inactive
@paulmelnikow
Copy link
Member Author

@chris48s Again, thanks for digging in. Agreed about the rest of your comments; those I've just addressed. I left you a note above about the truncating… let me know if that makes sense.

@@ -42,98 +110,109 @@ export default class Usage extends React.PureComponent {
renderStyleExamples() {
const { baseUrl } = this.props
return (
<table className="badge-img">
<QueryParamTable>
Copy link
Member

Choose a reason for hiding this comment

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

Do you think this one would also look better with textAlign = 'left' ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure!

@chris48s
Copy link
Member

The truncation happens in CSS so copy and paste should work…

Yep. With you.. I still think this one is a bit of an odd design decision.

Now that we're moving away from showing the full URL in the edit box (and in a future PR we'll move away from having an edit box at all), it would be useful to show the full URL of the badge we've generated somewhere in un-tuncated form. i.e: it would be nice to be able to see all of the thing I'm generating without having to copy and paste it into another window.

Also,

This content is really wide, but we're not truncating it:

screenshot at 2018-12-17 20-39-03

This content is really narrow, but we are truncating it:
screenshot at 2018-12-17 20-39-25

If we want to keep the width constrained, perhaps it would be better to wrap it, or allow it to be expanded somehow?

@paulmelnikow
Copy link
Member Author

To evaluate this PR it's important to inspect what's being generated. We've talked about the difference between what's useful as a Shields user and as a Shields dev, since our use cases for this dialog are different.

I'm not sure I see why a Shields user needs to inspect this as it's being built, vs clicking Copy URL or Copy Markdown when they're done.

The truncation isn't new; it's the narrower width and the dots that are. They make it look deliberate instead of an error:

screen shot 2018-12-17 at 3 58 57 pm

Since this is blocking other work and is going to change again, I don't want to get hung up on it. For now how about I make the box wider?

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2517 December 17, 2018 22:27 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2517 December 17, 2018 22:30 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2517 December 17, 2018 22:33 Inactive
@paulmelnikow
Copy link
Member Author

I set the markup back to its original width, and turned off truncate for the built URL.

@chris48s
Copy link
Member

There is one more strange bit of alignment I've noticed:

screenshot at 2018-12-18 19-34-31

screenshot at 2018-12-18 19-32-52

@paulmelnikow
Copy link
Member Author

Huh, strange. None of them are supposed to be over there. Probably the width change caused that.

@paulmelnikow
Copy link
Member Author

Huh, I can't reproduce that.

screen shot 2018-12-18 at 3 55 14 pm

@chris48s
Copy link
Member

chris48s commented Dec 18, 2018

How strange. I've just taken these 2 screenshots on the staging deploy at https://shields-staging-pr-2517.herokuapp.com


Firefox:
screenshot at 2018-12-18 21-06-16


Chromium Stable:
screenshot at 2018-12-18 21-06-52


Is the difference that <WeeSnippet truncate> has some left padding that <WeeSnippet> doesn't?

@paulmelnikow
Copy link
Member Author

I think it only changes the font size. I've done some monkeying around with the display property (inline vs block vs inline-block), though it's hard to know exactly what's causing this.

Does disabling the cache help? If you run locally can you isolate what's different?

@paulmelnikow
Copy link
Member Author

Ahhh actually might it be a window-size issue?

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2517 December 18, 2018 21:22 Inactive
Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

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

sorted - lets get this one merged

@shields-deployment
Copy link

This pull request was merged to master branch. This change is now waiting for deployment, which will usually happen within a few days. Stay tuned by joining our #ops channel on Discord!

After deployment, changes are copied to gh-pages branch:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker PRs and epics which block other work frontend The Docusaurus app serving the docs site
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants