Skip to content

Dropdown Alignment for locale names - Fix #19, #127 #159

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

Open
wants to merge 32 commits into
base: master
Choose a base branch
from

Conversation

share-with-me
Copy link
Contributor

This PR aims to fix #19 and #127 . I make use of a bootstrap dropdown to display the locales. This dropdown is visible only on larger (non-mobile devices) and it reverts to the current select feature for displaying the locales while on mobile devices.

Currently, for 3 lanaguages, the bootstrap button does not display the name of the locale. For instance, qaraqalpaksha. I could not find this name (and 2 others) anywhere (neither in languages nor in iso639Codes and hence, am unable to populate this name currently ). How are the select options for these languages getting populated in the current functionality?

@sushain97
Copy link
Member

How are the select options for these languages getting populated in the current functionality?

Probably locales.json.

I make use of a bootstrap dropdown to display the locales.

I don't know how I feel about the styling of that dropdown. Screenshot?

@share-with-me
Copy link
Contributor Author

share-with-me commented Jul 1, 2017

I don't know how I feel about the styling of that dropdown. Screenshot?

Yep, just a second.

screenshot from 2017-07-01 13-22-29

@share-with-me
Copy link
Contributor Author

@sushain97 , After this PR, i would set up travis locally too. Please (pliss) pardon me on this one :P

@share-with-me
Copy link
Contributor Author

Probably locales.json.

On it!

@sushain97
Copy link
Member

@share-with-me it looks a bit too much like a button now and not enough like a select looks. The bootstrap-select2 integration libraries might have some styles you can get inspiration from.

@share-with-me
Copy link
Contributor Author

@sushain97 , I have updated the styling of the dropdown button. It looks like this now:

screenshot from 2017-07-06 20-17-05

@sushain97
Copy link
Member

sushain97 commented Jul 6, 2017 via email

@share-with-me
Copy link
Contributor Author

share-with-me commented Jul 6, 2017

Seems to be center instead of right?

Um, 'English' should appear in the left if that is what you are saying? Should it look something like below?:

screenshot from 2017-07-06 20-30-02

@sushain97
Copy link
Member

sushain97 commented Jul 6, 2017 via email

@share-with-me
Copy link
Contributor Author

Made the changes @sushain97 ! Made some changes in logic too after determining an edge case that was failing.

screenshot from 2017-07-06 23-23-56

@share-with-me
Copy link
Contributor Author

Added the appropriate paddings!

@sushain97
Copy link
Member

It looks good! Some tweaks requested.

image

Let's align both the left edges. Preferably making them the same width c.f. Firefox:

image

Also, let's use the blue from the other dropdowns:

image

Finally, the scrollbar overlaps with these options in Chrome:

image

Let's introduce a right margin?

Copy link
Member

@sushain97 sushain97 left a comment

Choose a reason for hiding this comment

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

Some questions

@@ -115,6 +117,8 @@ $(document).ready(function () {
window.history.replaceState({}, document.title, newURL);
}
}

$('#localeDropdownCaret').css('left', rtlLanguages.indexOf(locale) !== -1 ? '5%' : '90%');
Copy link
Member

Choose a reason for hiding this comment

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

What is this doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the positioning of the caret in the locale dropdown button. I am fixing up the position of localeName and the caret.

screenshot from 2017-07-13 01-01-19

screenshot from 2017-07-13 01-01-31

It is the position of the carets in the above 2 pics.

.text(this[1])
.prop('dir', rtlLanguages.indexOf(this[0]) !== -1 ? 'rtl' : 'ltr')
.css('padding-left', rtlLanguages.indexOf(this[0]) !== -1 ? '115px' : '5px')
.css('padding-right', rtlLanguages.indexOf(this[0]) !== -1 ? '5px' : '115px')
Copy link
Member

Choose a reason for hiding this comment

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

Hm, this seems a bit brittle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Um, by brittle, do you mean that the logic to align the languages could be improved? Um, what suggestions do you have?

$('#localeDropdown').append(
$('<li></li>').append(
$('<a>', {
href: 'index.' + this[0] + '.html'
Copy link
Member

Choose a reason for hiding this comment

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

The current locale dropdown does not do this. We do not want to force a page refresh for switching languages! That's not great UX.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm yes. I would try to use the same logic and update this.

@@ -90,9 +90,11 @@
<p data-text="tagline" class="tagline"></p>
</div>
<div style="width: 35%" class="pull-right hidden-xs">
<!-- <i class="icon-globe localeGlobe pull-right"></i> -->
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:D

@share-with-me
Copy link
Contributor Author

@sushain97 , Made all the changes. Also implemented the functionality where the page is not forced to refresh now. I have emulated the existing functionality :)

Copy link
Member

@sushain97 sushain97 left a comment

Choose a reason for hiding this comment

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

good work switching to the right behavior, some concerns

$('#localeDropdown').append(
$('<li></li>').append(
$('<a>', {
rel: this[0] // eslint-disable-line id-length
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem to be a valid value for the rel attribute per https://www.w3.org/TR/html5/links.html#linkTypes. Have you tried using something like data-locale? Note that jQuery has a helpful $.data().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On it.

.prop('dir', rtlLanguages.indexOf(this[0]) !== -1 ? 'rtl' : 'ltr')
.css('padding-left', rtlLanguages.indexOf(this[0]) !== -1 ? '105px' : '5px')
.css('padding-right', rtlLanguages.indexOf(this[0]) !== -1 ? '5px' : '105px')
.hover(
Copy link
Member

Choose a reason for hiding this comment

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

This should go in CSS if at all possible. Is there a reason you put it here? CSS transitions might be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, yep. It does make sense to put it in CSS. Would change it

.text(this[1])
.prop('dir', rtlLanguages.indexOf(this[0]) !== -1 ? 'rtl' : 'ltr')
.css('padding-left', rtlLanguages.indexOf(this[0]) !== -1 ? '105px' : '5px')
.css('padding-right', rtlLanguages.indexOf(this[0]) !== -1 ? '5px' : '105px')
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to use text-align instead and then add padding on both sides?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

rel: this[0] // eslint-disable-line id-length
})
.text(this[1])
.prop('dir', rtlLanguages.indexOf(this[0]) !== -1 ? 'rtl' : 'ltr')
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it would be worth not exporting rtlLanguages and instead a function like isRtlLanguage or something like that... I don't recall if we use rtlLanguages for any other purpose though.

Copy link
Contributor Author

@share-with-me share-with-me Jul 16, 2017

Choose a reason for hiding this comment

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

Um, would making a function instead serve better? The entire usage of rtlLanguages is to determine if it is present in that particular array. Should I make a function instead?

Something like:

function isRtlLanguage(lang) {
    return rtlLanguages.indexOf(lang) !== -1;
}

@sushain97
Copy link
Member

sushain97 commented Aug 10, 2017 via email

@share-with-me
Copy link
Contributor Author

@sushain97 , referring to this link, I have added the necessary CSS. Could you check how it looks now?

@@ -338,6 +376,18 @@ body {
text-decoration: none;
}

@media(device-width: 768px) and (device-height: 1024px){
Copy link
Member

Choose a reason for hiding this comment

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

Spacing?

Copy link
Member

@sushain97 sushain97 left a comment

Choose a reason for hiding this comment

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

Small concern. I also still think we can get rid of localeToLanguageMap! I think you need to use $('.someElement').data('locale-name', 'blah').

@@ -338,6 +376,18 @@ body {
text-decoration: none;
}

@media(device-width: 768px) and (device-height: 1024px) {
::-webkit-scrollbar {
Copy link
Member

Choose a reason for hiding this comment

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

Actually, this applies to all scrollbars on the page. We only want to affect the language dropdown one!

@share-with-me
Copy link
Contributor Author

Small concern. I also still think we can get rid of localeToLanguageMap! I think you need to use $('.someElement').data('locale-name', 'blah').

Thank you @sushain97 :D. I actually managed to achieve it.

@share-with-me
Copy link
Contributor Author

Implemented both :D

$('<li></li>').append(
$('<a>', {
'data-locale': this[0]
})
Copy link
Member

Choose a reason for hiding this comment

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

Can we use .data('locale', this[0]) for the sake of consistency?

$.each(localePairs, function () {
var isRtlLanguage = (rtlLanguages.indexOf(this[0]) !== -1);
$('.localeSelect').append(
$('<option></option>')
Copy link
Member

@sushain97 sushain97 Aug 19, 2017

Choose a reason for hiding this comment

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

I don't think that "</option>" is required here?

@share-with-me
Copy link
Contributor Author

Made the changes.

.data('locale', this[0])
.text(this[1])
.prop('dir', isRtlLanguage ? 'rtl' : 'ltr')
.css({
Copy link
Member

Choose a reason for hiding this comment

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

Actually, on second thought, this should all go in the stylesheet. All you need to do is #localeDropdown li[dir='rtl'] { ... } .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On 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.

I made the changes but doing a git rebase now is causing conflicts :/ .

@share-with-me
Copy link
Contributor Author

Implemented the CSS changes.

@jonorthwash
Copy link
Member

Screenshot?

@share-with-me
Copy link
Contributor Author

screenshot from 2017-08-21 00-34-46

screenshot from 2017-08-21 00-35-21

@jonorthwash
Copy link
Member

This looks good to me. I guess mostly we need it tested on OS X, though. @sushain97 ?

@sushain97
Copy link
Member

Hm, it appears good to me if I remove:

@media(device-width: 768px) and (device-height: 1024px) {

Why did you add this?

@share-with-me
Copy link
Contributor Author

Why did you add this?

I had referred to some stackoverflow link and I was not sure how to test. I'd remove the media queries and update it now.

@share-with-me
Copy link
Contributor Author

Removed the media queries @sushain97 .

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.

dropdown improvements for RTL localisations
3 participants