-
Notifications
You must be signed in to change notification settings - Fork 106
fix: #1490: Make pfe-icon set CSS properties instead of overriding local var #1491
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
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
8d91d72
fix: #1490: Make pfe-icon set CSS properties instead of overriding lo…
wesruv 9633cde
Update elements/pfe-icon/src/pfe-icon.scss
wesruv 1987edc
Update elements/pfe-icon/src/pfe-icon.scss
wesruv 926f97c
Branch was auto-updated with the latest.
github-actions[bot] 6ec316e
fix: #1490: Fixing bugs and updating more areas where local vars are …
wesruv a802e86
Merge branch '1490-make-pfe-icon-respect-local-vars' of github.com:pa…
wesruv 5a079eb
Code legibility improvements
wesruv 77ee8aa
Update elements/pfe-icon/demo/index.html
wesruv b8a3c6e
Branch was auto-updated with the latest.
github-actions[bot] a4e7155
Branch was auto-updated with the latest.
github-actions[bot] d36b03f
Branch was auto-updated with the latest.
github-actions[bot] 10891e5
Branch was auto-updated with the latest.
github-actions[bot] c299eaf
Branch was auto-updated with the latest.
github-actions[bot] 2cde045
Branch was auto-updated with the latest.
github-actions[bot] 37e4a41
Branch was auto-updated with the latest.
github-actions[bot] b696f8d
Branch was auto-updated with the latest.
github-actions[bot] 2db64f0
Issue #1490: Added changelog.md
wesruv c7c370b
Merge branch '1490-make-pfe-icon-respect-local-vars' of github.com:pa…
wesruv b77fc07
Merge branch 'master' into 1490-make-pfe-icon-respect-local-vars
wesruv 7f5713f
Branch was auto-updated with the latest.
github-actions[bot] 0c579f7
Issue #1490: Adding test to check legacy CSS var and fixing tests
wesruv c6cd517
Merge branch '1490-make-pfe-icon-respect-local-vars' of github.com:pa…
wesruv f226f03
Removing pfe-icon CHANGELOG and uncommenting tests that shouldn't hav…
wesruv 65be451
Merge branch 'master' into 1490-make-pfe-icon-respect-local-vars
castastrophe 50d8756
Update baseline image for pfe-icon
a344ed0
Updating pfe-icon-panel with updated icon rendering
6cf6958
Issue #1490: Fixing pfe-icon stretch sizing with conten-box on host
wesruv 0c3f9e0
Merge branch '1490-make-pfe-icon-respect-local-vars' of github.com:pa…
wesruv 012c33a
Update baseline
castastrophe 05551d1
Merge branch 'master' of github.com:patternfly/patternfly-elements in…
castastrophe 3c5e3c6
Update elements/pfe-icon/src/pfe-icon.scss
wesruv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,19 +2,26 @@ | |
| @include pfe-contexts; | ||
|
|
||
| $LOCAL: icon; | ||
|
|
||
| $LOCAL-VARIABLES: ( | ||
| context: light, | ||
| size: pfe-var(icon-size), | ||
| spacing: pfe-var(container-spacer), | ||
| color: transparent, | ||
| Padding: 0, | ||
| BackgroundColor: transparent, | ||
| BorderWidth: 0, | ||
| // Legacy variable for changing icon color | ||
| Color: pfe-broadcasted(text), | ||
| ); | ||
|
|
||
| // Nested internal variables (pfe-local calls), maps cannot "self-reference" | ||
| $LOCAL-VARIABLES: map-deep-merge($LOCAL-VARIABLES, ( | ||
| Color: pfe-local(color, $fallback: pfe-broadcasted(text)), | ||
| // Current variable for updating icon color | ||
| color: pfe-local(Color), | ||
| )); | ||
|
|
||
| // Nested internal variables (pfe-local calls), maps cannot "self-reference" | ||
| $LOCAL-VARIABLES: map-deep-merge($LOCAL-VARIABLES, ( | ||
| BorderColor: pfe-local(color), | ||
| )); | ||
|
|
||
|
|
@@ -31,15 +38,16 @@ $LOCAL-VARIABLES: map-deep-merge($LOCAL-VARIABLES, ( | |
| } | ||
|
|
||
| :host { | ||
| --context: #{pfe-local(context)}; | ||
| --context: #{pfe-local(context)}; | ||
|
|
||
| position: relative; | ||
| display: inline-block; | ||
|
|
||
| // Supports sizing while preserving aspect ratio (despite layout) | ||
| max-width: calc(#{pfe-local(size)} + #{pfe-local(Padding)} * 2); | ||
| // Content-box model supports sizing while preserving aspect ratio (despite layout) | ||
| box-sizing: content-box!important; | ||
|
Contributor
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. Great use-case for content-box and !important; thanks for digging into that! |
||
| max-width: pfe-local(size); | ||
| width: fit-content !important; | ||
| max-height: calc(#{pfe-local(size)} + #{pfe-local(Padding)} * 2); | ||
| max-height: pfe-local(size); | ||
| height: fit-content !important; | ||
| line-height: 0; | ||
|
|
||
|
|
@@ -83,7 +91,7 @@ $LOCAL-VARIABLES: map-deep-merge($LOCAL-VARIABLES, ( | |
| } | ||
|
|
||
| filter feFlood { | ||
| flood-color: pfe-local(Color); | ||
| flood-color: pfe-local(color); | ||
| } | ||
|
|
||
| .pfe-icon--fallback { | ||
|
|
@@ -107,13 +115,26 @@ $sizing: ( | |
| // @TODO: Sort out sizing | ||
| @each $label, $size in $sizing { | ||
| :host([size="#{$label}"]) { | ||
| --pfe-icon--size: #{$size}; | ||
| // Respect var if user set CSS var, but fallback to sizing property map | ||
| $desired-size: pfe-local(size, $fallback: $size); | ||
| max-width: $desired-size; | ||
| max-height: $desired-size; | ||
|
|
||
| svg { | ||
| width: $desired-size; | ||
| height: $desired-size; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @each $level in (critical, important, moderate, success, info, default) { | ||
| :host([color="#{$level}"]) { | ||
| --pfe-icon--color: #{pfe-var(feedback--#{$level})}; | ||
| filter feFlood { | ||
| flood-color: pfe-local( | ||
| color, | ||
| $fallback: pfe-var(feedback--#{$level}) | ||
| ); | ||
| } | ||
| @if $level != "moderate" { | ||
| --pfe-icon--context: dark; | ||
| } | ||
|
|
@@ -122,19 +143,48 @@ $sizing: ( | |
|
|
||
| @each $color in (lightest, base, darker, darkest, complement, accent) { | ||
| :host([color="#{$color}"]) { | ||
| --pfe-icon--color: #{pfe-var(surface--#{$color})}; | ||
| --pfe-icon--context: #{pfe-var(surface--#{$color}--context)}; | ||
|
|
||
| filter feFlood { | ||
| flood-color: pfe-local( | ||
| color, | ||
| $fallback: pfe-var(surface--#{$color}) | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // May need Feedback Darkest colors too. | ||
|
|
||
| :host([circled]:not([circled="false"])) { | ||
| --pfe-icon--BackgroundColor: #{pfe-local(color, $fallback: pfe-var(surface--lightest))}; | ||
| --pfe-icon--Color: #{pfe-broadcasted(text)}; | ||
| --pfe-icon--Padding: .5em; | ||
| --pfe-icon--BorderWidth: #{pfe-var(ui--border-width)}; | ||
| --pfe-icon--BorderColor: #{pfe-local(color, $fallback: pfe-var(surface--border))}; | ||
| padding: pfe-local(Padding, $fallback: .5em); | ||
| border-width: pfe-local(BorderWidth, $fallback: pfe-var(ui--border-width)); | ||
| border-color: pfe-local(color, $fallback: pfe-var(surface--border)); | ||
| background-color: pfe-local(BackgroundColor, pfe-local(color, $fallback: pfe-var(surface--lightest))); | ||
|
|
||
| filter feFlood { | ||
| flood-color: pfe-local(color); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Override circled items with color set to named property | ||
| */ | ||
| @each $color in (lightest, base, darker, darkest, complement, accent) { | ||
| :host([color=#{$color}][circled]:not([circled="false"])) { | ||
| // Respect var if user set CSS var, but fallback to property | ||
| $desired-color: pfe-local(color, $fallback: pfe-var(surface--#{$color})); | ||
| background-color: $desired-color; | ||
| border-color: $desired-color; | ||
| } | ||
| } | ||
| @each $level in (critical, important, moderate, success, info, default) { | ||
| :host([color="#{$level}"][circled]:not([circled="false"])) { | ||
| // Respect var if user set CSS var, but fallback to property | ||
| $desired-color: pfe-local(backgroundColor, $fallback: pfe-var(feedback--#{$level})); | ||
| background-color: $desired-color; | ||
| border-color: $desired-color; | ||
| } | ||
| } | ||
|
|
||
| :host(.load-failed) svg image { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.