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

fix: UIO focus styling (resolves #231) #233

Merged
merged 77 commits into from
Jun 9, 2020

Conversation

TeddTech
Copy link
Contributor

@TeddTech TeddTech commented May 11, 2020

  • This pull request has been linted by running npm run lint without errors
  • This pull request has been tested by running npm run start and reviewing affected routes
  • This pull request has been built by running npm run build without errors
  • This isn't a duplicate of an existing pull request

Description

This PR adds focus and hover styling to uio contrast options.

Steps to test

  1. run npm run start
  2. select a uio contrast option using the uio tab in the top right corner of webpage
  3. focus and hover over different elements on the webpage
  4. repeat step 3 for the other webpages on website

Expected behavior:
Clear and appropriate focus/hover styling should appear on all webpages when uio contrast options are implemented.

Additional information

N/A

Related issues

closes #231

@TeddTech
Copy link
Contributor Author

This PR needs to be merged AFTER PR #230

@TeddTech TeddTech self-assigned this May 11, 2020
@TeddTech TeddTech added the enhancement New feature or request label May 11, 2020
Comment on lines 3 to 10
a:focus,
a:hover,
#defaultContainer header .site-nav-wrapper .site-nav nav a:focus,
#defaultContainer header .site-nav-wrapper .site-nav nav a:hover,
#defaultContainer .content-wrapper .tags-info .tags a:focus,
#defaultContainer .content-wrapper .tags-info .tags a:hover, {
border: rem(2) solid $c;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@greatislander I came up with this solution to get by the linting error that was appearing during check-in. Let me know what you think

Copy link
Member

Choose a reason for hiding this comment

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

Awesome, that was what I was going to suggest!

@TeddTech
Copy link
Contributor Author

TeddTech commented Jun 4, 2020

There is an outstanding error in this PR that I feel should be addressed in a separate issue.

Screen Shot 2020-06-03 at 6 14 54 PM

@TeddTech TeddTech requested a review from cindyli June 4, 2020 01:49
[class^="fl-theme"]:not(.fl-theme-prefsEditor-default) {
// Search icon; IDRC, OCADU and Canada logos
header .site-nav-wrapper .site-nav .search-container svg {
height: 1.5rem;
Copy link
Contributor

Choose a reason for hiding this comment

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

The circle around the search icon on the high contrast is still not a perfect round:

Screen Shot 2020-06-04 at 10 28 35 AM

Reducing the size of the svg seems working better. These are values I tried:

hight: 1.2rem;
margin: -1.6rem;
width: 1.2rem;

Please do use rem() function in scss files rather than the straight rem unit. Thanks.

box-shadow: inset 0 0 0 rem(2) $fColor;
}

#defaultContainer .content-wrapper main .pagination .pagination-list li a[aria-current="page"] {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel it might be better to combine uio-focus-style() and adapt-to-highContrast() functions into one and name it adapt-to-contrastThemes() because:

  1. Some code in uio-focus-style() deals with non-focus stylings such as this section while some code in adapt-to-highContrast() deals with focus stylings such as line 41 but not in uio-focus-style() function;
  2. It's hard to separate out focus/hover code when it is part of an element handling. The styles for social media icons at line 35 is an example.

Please add code comments to each section in the combined function to explain what's handled by that section. Thanks.

button:hover,
li .pagination-link,
li .pagination-link::before {
box-shadow: inset 0 0 0 rem(2) $fColor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Replacing $fColor with currentColor works the same way. This change will help to move this section of code out of the function into the more generic handling within [class^="gpii-ext-theme"], [class^="fl-theme"]:not(.fl-theme-prefsEditor-default). This move will help to reduce the size of the generated css.

background-image: none;
}

footer .funders .footer-logos a {
Copy link
Contributor

Choose a reason for hiding this comment

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

.footer-logos is not a child of .funders. This css doesn't apply to logo svgs on the footer. The focus/hover styling on these logos are broken now.

color: $bColor !important; // Enactors.css in infusion uses !important on this element
}

#defaultContainer .content-wrapper main .pagination .pagination-list li a[aria-current="page"]:hover,
Copy link
Contributor

Choose a reason for hiding this comment

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

This focus/hover styling is for the same element above at line 19. Can you move it in there in the format of:

	#defaultContainer .content-wrapper main .pagination .pagination-list li a[aria-current="page"] {
		// regular styles

		&:hover,
		&:focus {
			// focus/hover styles
	}

Thanks.

[class^="gpii-ext-theme"],

// TODO: Address style lint errors when line below is uncommented
// [class^="gpii-ext-theme"],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When including the selector .gpii-ext-theme-#{$theme} for UIO + themes the following linting errors occur:

✖ stylelint found some errors. Please fix them and try committing again.
 
src/scss/vendors/_vendors.scss
20:3  ✖  Expected selector "[class^="gpii-ext-theme"] footer .footer-logos a" to come before selector "[class^="fl-theme"]:not(.fl-theme-prefsEditor-default) footer .funders a"                                                                                            no-descending-specificity
27:2  ✖  Expected selector "[class^="gpii-ext-theme"] #defaultContainer a:hover" to come before selector "[class^="fl-theme"]:not(.fl-theme-prefsEditor-default) #defaultContainer a:focus"                                                                                 no-descending-specificity
29:2  ✖  Expected selector "[class^="gpii-ext-theme"] #defaultContainer header .site-nav-wrapper .site-nav nav a:hover" to come before selector "[class^="fl-theme"]:not(.fl-theme-prefsEditor-default) #defaultContainer header .site-nav-wrapper .site-nav nav a:focus"   no-descending-specificity
30:2  ✖  Expected selector "[class^="gpii-ext-theme"] #defaultContainer .content-wrapper .tags-info .tags a:focus" to come before selector "[class^="fl-theme"]:not(.fl-theme-prefsEditor-default) #defaultContainer header .site-nav-wrapper .site-nav nav a:focus"        no-descending-specificity
30:2  ✖  Expected selector "[class^="gpii-ext-theme"] #defaultContainer .content-wrapper .tags-info .tags a:focus" to come before selector "[class^="fl-theme"]:not(.fl-theme-prefsEditor-default) #defaultContainer header .site-nav-wrapper .site-nav nav a:hover"        no-descending-specificity
31:2  ✖  Expected selector "[class^="gpii-ext-theme"] #defaultContainer .content-wrapper .tags-info .tags a:hover" to come before selector "[class^="fl-theme"]:not(.fl-theme-prefsEditor-default) #defaultContainer header .site-nav-wrapper .site-nav nav a:focus"        no-descending-specificity
31:2  ✖  Expected selector "[class^="gpii-ext-theme"] #defaultContainer .content-wrapper .tags-info .tags a:hover" to come before selector "[class^="fl-theme"]:not(.fl-theme-prefsEditor-default) #defaultContainer header .site-nav-wrapper .site-nav nav a:hover"        no-descending-specificity
31:2  ✖  Expected selector "[class^="gpii-ext-theme"] #defaultContainer .content-wrapper .tags-info .tags a:hover" to come before selector "[class^="fl-theme"]:not(.fl-theme-prefsEditor-default) #defaultContainer .content-wrapper .tags-info .tags a:focus"             no-descending-specificity
34:2  ✖  Expected selector "[class^="gpii-ext-theme"] .card:hover" to come before selector "[class^="fl-theme"]:not(.fl-theme-prefsEditor-default) .card:focus"                                                                                                             no-descending-specificity
36:2  ✖  Expected selector "[class^="gpii-ext-theme"] button:hover" to come before selector "[class^="fl-theme"]:not(.fl-theme-prefsEditor-default) button:focus" 

Copy link
Contributor

Choose a reason for hiding this comment

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

While working on #266, I found CSS attached with the generic selector [class^="gpii-ext-theme"], [class^="fl-theme"]:not(.fl-theme-prefsEditor-default) sometimes are not applied when another UIO style that is attached with a specific theme selector kicks in. The solution (#269) is to hook up CSS with each specific theme selector.

From the lesson learnt there, I feel the same rule applies to other CSS you have here too. It means to move all css inside [class^="gpii-ext-theme"], [class^="fl-theme"]:not(.fl-theme-prefsEditor-default) to the mixin function. This change will fix this linting error too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cindyli I have moved only the selectors with a currentColor value to _mixins.scss file. Let me now if this is a valid a solution for this linting problem and I will request another review

Copy link
Contributor

Choose a reason for hiding this comment

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

I tested with your update. Unfortunately, the similar issue as #266 appears with other css that are not moved from the generic theme into specific theme selector.

Using hiding background image of home page cards as an example:

Turn on "enhance inputs" -> switch to another theme -> the background images of cards show up

These images should not be shown on contrast themes.

Screen Shot 2020-06-08 at 2 01 37 PM

@TeddTech
Copy link
Contributor Author

TeddTech commented Jun 8, 2020

@cindyli there are inconsistent hover/focus colours for the last 3 uio contrast themes. Buttons, links, and uio preference panel have different hover/focus colours. I am thinking about addressing this issue in a separate PR. What are your thoughts?

Screen Shot 2020-06-08 at 10 00 00 AM

Screen Shot 2020-06-08 at 10 00 35 AM

@cindyli
Copy link
Contributor

cindyli commented Jun 8, 2020

@cindyli there are inconsistent hover/focus colours for the last 3 uio contrast themes. Buttons, links, and uio preference panel have different hover/focus colours. I am thinking about addressing this issue in a separate PR. What are your thoughts?

Screen Shot 2020-06-08 at 10 00 00 AM Screen Shot 2020-06-08 at 10 00 35 AM

@TeddTech I agree this could be addressed separately if it is an issue.

From what I learnt from @jobara about the last three low contrast themes is they are designed with different set of colors for links, selected texts etc to match contrast themes on Windows (See @jobara's reply on SJRK pull request).

It feels to me the hover/focus style for links is correct. But the hover/focus style for UIO buttons ("show perferences", "hide preferences" and "reset") is in question.

@jobara and @lliskovoi, what do you think?

stroke-width: rem(3);
}
}

// For styles that require foreground and background colors from each theme
@each $theme, $fColor, $bColor in $UIOThemes {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to move this section to before the line 94 since this style belongs to the generic css outside of any specific media query breakpoint. After the change, the structure of this file will be more structured with the media query breakpoints.

@TeddTech TeddTech requested a review from cindyli June 8, 2020 20:27
[class^="gpii-ext-theme"],
[class^="fl-theme"]:not(.fl-theme-prefsEditor-default) {
// Search icon; IDRC, OCADU and Canada logos
header .site-nav-wrapper .site-nav .search-container svg {
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this css needs to be moved out of the generic selector into theme specific selectors too. Seems you need another loop on $UIOThemes here.

@TeddTech TeddTech requested a review from cindyli June 8, 2020 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add focus/hover styling to uio contrast options
4 participants