-
Notifications
You must be signed in to change notification settings - Fork 33
GAUD-8850: Remove select.scss #7155
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
Changes from all commits
0b77aad
7c63fc8
a281487
21ea095
41f07fd
a1b7f07
92ee5bf
abaf9fa
1251a94
3bfff70
d9008b4
6e4cfbf
965c997
612d1f3
03b9ae6
71d1cf8
7f3956f
3f5012c
d282cfa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,46 @@ | ||
| import './input-styles.js'; | ||
| import { css, unsafeCSS } from 'lit'; | ||
| import { getFocusRingStyles, getFocusVisibleStyles } from '../../helpers/focus.js'; | ||
| import { _isValidCssSelector } from '../../helpers/internal/css.js'; | ||
| import { getFocusPseudoClass } from '../../helpers/focus.js'; | ||
| import { registerSemanticVariableForSvgImageUrl } from '../colors/colors.js'; | ||
|
|
||
| const focusClass = unsafeCSS(getFocusPseudoClass()); | ||
|
|
||
| registerSemanticVariableForSvgImageUrl( | ||
| '--d2l-input-select-chevron-image', | ||
| `<svg width="11" height="7" viewBox="0 0 11 7" xmlns="http://www.w3.org/2000/svg"> | ||
| <path d="M1 2l4.5 4M10 2L5.5 6" stroke="var(--d2l-theme-icon-color-standard)" stroke-width="2" fill="none" fill-rule="evenodd" stroke-linecap="round"/> | ||
| </svg>` | ||
| ); | ||
|
|
||
| function _getSelectFocusStyles(selector) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm personally finding the addition of this helper really confusing to follow the before & after, vs. just calling into
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. imo i think should be pretty straight forward. what I did was only to group styles and selectors into this function, and then use the returned object there. I decided to created this helper function to encapsulate the logic that replaces the |
||
| const notDisabledSelector = (focusSelector) => ` | ||
| ${selector}:not([disabled]):hover, | ||
| ${selector}:not([disabled]):${focusSelector}`; | ||
| const ariaInvalidSelector = (focusSelector) => ` | ||
| ${selector}[aria-invalid="true"], | ||
| ${selector}[aria-invalid="true"]:${focusSelector}, | ||
| ${selector}[aria-invalid="true"]:hover`; | ||
|
|
||
| return { | ||
| notDisabled: getFocusRingStyles(notDisabledSelector, { | ||
| extraStyles: css` | ||
| box-shadow: inset var(--d2l-theme-shadow-inset-offset-x) var(--d2l-theme-shadow-inset-offset-y) var(--d2l-theme-shadow-inset-blur-radius) 2px var(--d2l-theme-shadow-inset-color); | ||
|
|
||
| --d2l-focus-ring-offset: -2px;`, | ||
| preferContrastMediaQueryExtraStyles: css`box-shadow: none;` | ||
| }), | ||
| ariaInvalid: getFocusVisibleStyles(ariaInvalidSelector, (selector) => css`${selector} { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This rule is being used both inside and outside the media query, so just added it once |
||
| outline-color: var(--d2l-theme-status-color-error); | ||
| }`) | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * A private helper method that should not be used by general consumers | ||
| */ | ||
| export function _generateSelectStyles(selector) { | ||
| if (!_isValidCssSelector(selector)) return ''; | ||
| const finalSelector = unsafeCSS(selector); | ||
| const selectFocusStyles = _getSelectFocusStyles(finalSelector); | ||
|
|
||
| return css` | ||
| ${finalSelector} { | ||
|
|
@@ -51,23 +73,16 @@ export function _generateSelectStyles(selector) { | |
| vertical-align: middle; | ||
| } | ||
|
|
||
| ${finalSelector}:not([disabled]):hover, | ||
| ${finalSelector}:not([disabled]):${focusClass} { | ||
| box-shadow: inset var(--d2l-theme-shadow-inset-offset-x) var(--d2l-theme-shadow-inset-offset-y) var(--d2l-theme-shadow-inset-blur-radius) 2px var(--d2l-theme-shadow-inset-color); | ||
| outline: 2px solid var(--d2l-theme-border-color-focus); | ||
| outline-offset: -2px; | ||
| } | ||
| ${selectFocusStyles.notDisabled} | ||
|
|
||
| ${finalSelector}[aria-invalid="true"] { | ||
| background-image: var(--d2l-input-select-chevron-image), var(--d2l-input-invalid-image); | ||
| background-position: center var(--d2l-inline-end, right) 17px, center var(--d2l-inline-end, right) calc(1px + 11px + 17px); | ||
| background-repeat: no-repeat, no-repeat; | ||
| background-size: 11px 7px, 0.8rem 0.8rem; | ||
| } | ||
| ${finalSelector}[aria-invalid="true"], | ||
| ${finalSelector}[aria-invalid="true"]:${focusClass}, | ||
| ${finalSelector}[aria-invalid="true"]:hover { | ||
| outline-color: var(--d2l-theme-status-color-error); | ||
| } | ||
| ${selectFocusStyles.ariaInvalid} | ||
|
|
||
| ${finalSelector}:disabled { | ||
| opacity: var(--d2l-theme-opacity-disabled-control); | ||
| } | ||
|
|
@@ -87,12 +102,6 @@ export function _generateSelectStyles(selector) { | |
| padding-inline: 0.6rem 16px; | ||
| } | ||
|
|
||
| ${finalSelector}:not([disabled]):${focusClass}, | ||
| ${finalSelector}:not([disabled]):hover { | ||
| box-shadow: none; | ||
| outline: 2px solid Highlight; | ||
| } | ||
|
|
||
| ${finalSelector}:disabled { | ||
| outline: 1px solid GrayText; | ||
| } | ||
|
|
@@ -104,11 +113,7 @@ export function _generateSelectStyles(selector) { | |
| background-size: 0.8rem 0.8rem; | ||
| } | ||
|
|
||
| ${finalSelector}[aria-invalid="true"], | ||
| ${finalSelector}[aria-invalid="true"]:${focusClass}, | ||
| ${finalSelector}[aria-invalid="true"]:hover { | ||
| outline-color: var(--d2l-theme-status-color-error); | ||
| } | ||
| ${selectFocusStyles.ariaInvalid} | ||
| } | ||
| `; | ||
| }; | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added back the code in the vdiffs just to make sure they are still looking as expected. Here is the report. this will be reverted once we are happy (get some thumbs up) with the changes and their results
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, give me a bit longer to review this before reverting. |
Uh oh!
There was an error while loading. Please reload this page.