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

Fixed responsiveness of buttons in create-collection page #527

Merged
merged 4 commits into from
Nov 24, 2020

Conversation

frappelatte28
Copy link
Contributor

Problem

https://tickets.metabrainz.org/browse/BB-558
WhatsApp Image 2020-10-27 at 2 27 13 PM

Solution

Screenshot from 2020-10-27 18-12-44

Applied top margin for mobile screens using media query.

Areas of Impact

src/client/components/forms/userCollection.js
src/client/stylesheets/style.less

@frappelatte28
Copy link
Contributor Author

@MonkeyDo Please kindly review this PR :)

@coveralls
Copy link

coveralls commented Oct 27, 2020

Coverage Status

Coverage increased (+0.1%) to 60.887% when pulling 8dcdf53 on frappelatte28:uifixes2 into b087f3d on bookbrainz:master.

Copy link
Contributor

@MonkeyDo MonkeyDo left a comment

Choose a reason for hiding this comment

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

Thanks, good find!

I have a suggestion for a different approach:
First of all, let's fix the issue with the overlapping buttons in a way that will fix it across the website. I've identified the issue is coming from the bootstrap theme, but can (and has) been mitigated; see this bit of CSS used previously to sort the issue of horizontal overlap:
https://github.com/bookbrainz/bookbrainz-site/blob/master/src/client/stylesheets/style.less#L83-L87
I propose to change that simply to margin: 0; to fix the overlapping issue vertically as well.

With that out of the way, I think there is a simple way to display our buttons properly using existing css.
We can use bootstrap's responsive grid system by modifying the structure just a bit:

<div class="row">
  <div class="col-sm-6">
    <button type="button" class="btn btn-block btn-primary">Add another collaborator</button>
  </div>
  <div class="col-sm-6">
    <button type="submit" class="btn btn-block btn-success">Create collection</button>
  </div>
</div>
  1. We change the text-center class of the parent element to row
  2. We create two <div class="col-sm-6"> elements around the existing buttons
  3. Profit.

I think it looks quite good like that, with full width buttons in mobile sizes, and better looking as well in desktop sizes I find:

Capture d’écran 2020-10-28 à 14 23 52
Capture d’écran 2020-10-28 à 14 23 35

How does that sound?

@frappelatte28
Copy link
Contributor Author

@MonkeyDo
i think we can achieve the same with little less mess ,
we can use predefined " no-gutters " class on .row to remove negative margin of row and extra gutters of columns .

https://getbootstrap.com/docs/4.0/layout/grid/#no-gutters

also , i think giving space between two buttons will look more nicer so i think we can use above "no-gutter" method and then add the space manually in this section .

what do you think?

@MonkeyDo
Copy link
Contributor

MonkeyDo commented Nov 5, 2020

on .row to remove negative margin of row and extra gutters of columns

I'm not sure I understand your suggestion. Which .row element do you want to modify?
I don't follow how it will solve the issue.

We're using an older version of Bootstrap that doesn't have the no-gutter class, but that's not a huge issue as we can always define some css class for it.

@frappelatte28
Copy link
Contributor Author

We're using an older version of Bootstrap that doesn't have the no-gutter class, but that's not a huge issue as we can always define some css class for it.

yes i agree on this .

also
i have tested this code

<div class="row">
  <div class="col-sm-6">
    <button type="button" class="btn btn-block btn-primary">Add another collaborator</button>
  </div>
  <div class="col-sm-6">
    <button type="submit" class="btn btn-block btn-success">Create collection</button>
  </div>
</div>

looks great to me ,
i should make a commit using this !

@frappelatte28
Copy link
Contributor Author

@MonkeyDo please review the changes !

Copy link
Contributor

@MonkeyDo MonkeyDo left a comment

Choose a reason for hiding this comment

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

It's looking quite good !
A suggestion below to simplify the fix.

Also, currently our continuous integration (CI) tests are failing on simple code style issues, which you can easily fix by running this command: npm run lint -- --fix before committing the changes to the userCollection.js file.

@@ -262,7 +262,8 @@ class UserCollectionForm extends React.Component {
<div className={errorAlertClass}>
<Alert bsStyle="danger">Error: {errorText}</Alert>
</div>
<div className="text-center">
<div className="row">
<div className = "col-sm-6">
Copy link
Contributor

Choose a reason for hiding this comment

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

You can add a simple Bootstrap class to add a space on top of both of these col-sm-6 elements, which will give a bit of space between the buttons when they are on top of each other:

Suggested change
<div className = "col-sm-6">
<div className = "col-sm-6 margin-top-d5">

With that simply change on both elements, you can remove the changes to the style.less file.

@@ -549,3 +550,10 @@ hr.wide {
margin-right: 0.5em !important;;
vertical-align: text-top;
}

@media (max-width: 498px){
.buttons-container > button:nth-child(2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This buttons-container class is not used anywhere, so this code block is unused, and can be removed.

As mentioned in the comment above, we can add a bit of space between the buttons using existing bootstrap classes instead.

@frappelatte28
Copy link
Contributor Author

@MonkeyDo Please review the changes!

Copy link
Contributor

@MonkeyDo MonkeyDo left a comment

Choose a reason for hiding this comment

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

Just two more details and I think this will be perfect :)

src/client/components/forms/userCollection.js Show resolved Hide resolved
src/client/components/forms/userCollection.js Show resolved Hide resolved
>
<FontAwesomeIcon icon="save"/>&nbsp;{submitLabel}
</Button>
<div className="row">
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<div className="row">
<div className="row margin-bottom-2">

This makes sure there's a bit of space between the buttons and the footer.

Comment on lines 284 to 286
{
this.props.collection.id ?
<Button
Copy link
Contributor

Choose a reason for hiding this comment

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

I just noticed the third button ("Delete"), which is only visible when you edit one of your own collections.

It should receive the same changes as the other buttons, meaning it should also be wrapped in a <div> in the same way and the button should have the block attribute.

Here's the full block of code:

{
	this.props.collection.id ?
		<div className="col-sm-6 margin-top-d5">
			<Button
				block
				bsStyle="danger"
				type="button"
				onClick={this.handleShowModal}
			>
				<FontAwesomeIcon icon="trash-alt"/>&nbsp;Delete collection
			</Button>
		</div> : null
}

With three buttons in mind, it's worth you having another pass to see if it looks good with the three buttons.

@frappelatte28
Copy link
Contributor Author

@MonkeyDo Sorry for the late commit, I was occupied with some work, I have made the requested changes, feel free to let me know if you need any further changes.

Copy link
Contributor

@MonkeyDo MonkeyDo left a comment

Choose a reason for hiding this comment

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

Thank you for your PR, this now looks a whole lot better !
🚀

@MonkeyDo MonkeyDo merged commit e463e50 into metabrainz:master Nov 24, 2020
@welcome
Copy link

welcome bot commented Nov 24, 2020

Congratulations on your first merged pull request for BookBrainz! 🎉
We're very thankful for your work, and happy to count you part of our team !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants