-
Notifications
You must be signed in to change notification settings - Fork 3
Icon Component Update #310
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
sreidthomas
wants to merge
47
commits into
dev
Choose a base branch
from
feature.issue.295
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
e501b26
Moved Icon from experimental to stable. Working as before
sreidthomas 5ba6f85
Fixed prettier issues in 2 files
sreidthomas 9f3af58
Updated index-experimental.js file
sreidthomas 44e7bf1
Second attempt to fix experimental-index.js
sreidthomas 78f9f83
3rd attempt to fix experimental-index.js file
sreidthomas 6cabae0
Fourth attempt to fix index-experimental.js file
sreidthomas 43f8982
Fixed prettier issues in 2 files
sreidthomas cf0cd3e
Added backwards compatibility and changed scss/css back to normal
sreidthomas 1024aab
Fixed prettier issues in 2 files
sreidthomas b11cc4b
Added switch statement for both fontawesome and bootstrap icons
sreidthomas 0a25e82
Fixed major issues in stories file and library attribute not being us…
sreidthomas 4e14720
Attempt to fix merge issue
sreidthomas 38cdb10
Fixed path for Icon
sreidthomas bea7ba2
Added slot for Icon SVG. Attempt to add switch for fontawesome and bo…
sreidthomas af9bf9a
Fixed prettier issues in 1 file
sreidthomas 1c2a952
Removed comment to see if full code gets pushed
sreidthomas afcdc48
Fixed highlight svg issue. removed unneeded comments
sreidthomas a98ce94
Fixed prettier issues in 1 file
sreidthomas 0974937
Merge branch 'dev' into feature.issue.295
sreidthomas 7950a22
Added documentation for Icon component. Fixed prettier issues in 1 file
sreidthomas 3d091bb
Moved import from index-experimental.js to index-stable.js
sreidthomas c044e82
Made renderIcon a private method
sreidthomas 7b2fe38
Made isIconConnected a private method
sreidthomas 4766198
Fixed path in icon.mdx, updated icon.stories.js file because doc cann…
sreidthomas 44880ea
removed aria-label as a fallback
sreidthomas 5542e52
Fixed issues with icon not showing in storybook. removed size attribu…
sreidthomas e44c9e3
Removed the size attribute
sreidthomas 7b42096
Fixed prettier issues in 2 files
sreidthomas 0600a1d
Added attributes to be reflective and added the font-size feature
sreidthomas 423cf91
Attempt to fix Reflective JS issue
sreidthomas 574f2f9
Attempt to fix Reflective JS issue
sreidthomas 7901637
Fixed prettier issues in 1 file
sreidthomas 70ea206
Added icon code back the way it was. certain features were not workin…
sreidthomas a85a438
Fixed prettier issues in 1 file
sreidthomas db8a791
Attempt to add inheritance in stories file. still issues with icon.md…
sreidthomas 3e7d065
Fixed prettier issues in 1 file
sreidthomas e5f2064
Removed setter for is-hightlighted
sreidthomas 035ae67
Removed custom property and made color inherit
sreidthomas d75c302
Grouped attributes in documentation
sreidthomas 2d725fa
Updated attributes added deprecated to outdated attributes and reflec…
sreidthomas b8512bd
Added controls to Icon Story documentation file
sreidthomas 5fa2d7d
Fixed prettier issues in 1 file
sreidthomas f363cfe
Fixed documentation issues for storybook
sreidthomas 693ba70
Fixed prettier issues in 1 file
sreidthomas 4c94278
Fixed issues with Icon.mdx file and fixed undefined icon issue
sreidthomas 77efc13
Added Size and Color information to documentation
sreidthomas 3cb1754
Removed icon-color inherit from :host rule
sreidthomas 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 was deleted.
Oops, something went wrong.
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
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 was deleted.
Oops, something went wrong.
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
19 changes: 18 additions & 1 deletion
19
...perimental/components/atoms/Icon/Icon.css → src/stable/components/Icon/Icon.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| import styles from '!!raw-loader!./Icon.css'; | ||
| import { getIcon } from './icon-helpers.js'; | ||
|
|
||
| const template = document.createElement('template'); | ||
| template.innerHTML = ` | ||
| <style> | ||
| ${styles} | ||
| </style> | ||
| <div class="icon-container"> | ||
| <slot class="icon"></slot> | ||
| </div> | ||
| `; | ||
|
|
||
| class Icon extends HTMLElement { | ||
| constructor() { | ||
| super(); | ||
| this.attachShadow({ mode: 'open' }); | ||
| this.shadowRoot.appendChild(template.content.cloneNode(true)); | ||
| } | ||
|
|
||
| // Define reflective properties | ||
| static get observedAttributes() { | ||
| return ['name', 'library', 'size', 'label', 'is-highlighted']; | ||
| } | ||
| // Getters and Setters for the attributes | ||
| get name() { | ||
| return this.getAttribute('name'); | ||
| } | ||
|
|
||
| set name(value) { | ||
| this.setAttribute('name', value); | ||
| } | ||
|
|
||
| get library() { | ||
| return this.getAttribute('library'); | ||
| } | ||
|
|
||
| set library(value) { | ||
| this.setAttribute('library', value); | ||
| } | ||
|
|
||
| get size() { | ||
| return this.getAttribute('size'); | ||
| } | ||
|
|
||
| set size(value) { | ||
| this.setAttribute('size', value); | ||
| } | ||
|
|
||
| get isHighlighted() { | ||
| return this.hasAttribute('is-highlighted'); | ||
| } | ||
|
|
||
| connectedCallback() { | ||
| if (this.isIconConnected()) { | ||
| return; | ||
| } | ||
| this._renderIcon(); | ||
| } | ||
|
|
||
| isIconConnected() { | ||
sreidthomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return this.shadowRoot.querySelector('.icon').innerHTML !== ''; | ||
| } | ||
|
|
||
| _renderIcon() { | ||
| const container = this.shadowRoot.querySelector('.icon-container'); | ||
| const iconElement = this.shadowRoot.querySelector('.icon'); | ||
|
|
||
| // Get attributes (using the getter methods) | ||
| const icon = this.name || this.getAttribute('data-icon'); | ||
| const label = this.label || icon; | ||
| let size = this.size || '24'; // Default to 24 if no size provided | ||
| const library = this.library || 'fontawesome'; | ||
|
|
||
| // Check if the font-size is set in the light DOM | ||
| const style = window.getComputedStyle(this); | ||
| const lightDomSize = style.fontSize; | ||
|
|
||
| if (lightDomSize && lightDomSize !== 'auto') { | ||
| size = lightDomSize; // Use the font-size from light DOM if set | ||
| } else { | ||
| switch (size) { | ||
| case 'small': | ||
| size = '16'; | ||
| break; | ||
| case 'medium': | ||
| size = '24'; | ||
| break; | ||
| case 'large': | ||
| size = '36'; | ||
| break; | ||
| case 'x-large': | ||
| size = '54'; | ||
| break; | ||
| default: | ||
| size = '24'; | ||
| } | ||
| } | ||
|
|
||
| // Check if slot has content (SVG provided by the user) | ||
| const slotContent = this.querySelector('svg'); | ||
| if (slotContent) { | ||
| // Return if SVG is provided by the user, as it will render automatically | ||
| return; | ||
| } | ||
|
|
||
| // Set label for accessibility | ||
| if (label) { | ||
| container.setAttribute('aria-label', label); | ||
| } | ||
|
|
||
| // Set icon using getIcon() with the determined size | ||
| iconElement.innerHTML = getIcon(icon, size, library); | ||
|
|
||
| // Handle boolean attribute | ||
| if (this.isHighlighted) { | ||
| container.classList.add('highlighted'); | ||
| } | ||
| } | ||
|
|
||
| // Handle attribute changes for reflective properties | ||
| attributeChangedCallback(name, oldValue, newValue) { | ||
| if (oldValue !== newValue) { | ||
| this._renderIcon(); // Re-render the icon if any of the attributes change | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export { Icon as default }; | ||
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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| :host { | ||
| display: inline-block; | ||
| } | ||
|
|
||
| // /* Highlighted styles */ | ||
| .icon-container { | ||
| display: inline-block; | ||
| color: inherit; | ||
|
|
||
| // Size will be controlled via the element itself or inherited from parent | ||
| svg { | ||
| width: 100%; | ||
| height: 100%; | ||
| // Ensure the SVG also inherits the color | ||
| fill: currentColor; | ||
| stroke: currentColor; | ||
| } | ||
| } | ||
|
|
||
| .icon-container.highlighted { | ||
| background-image: url('data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2049%2019%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cellipse%20cx%3D%2224.5%22%20cy%3D%229.5%22%20rx%3D%2224.5%22%20ry%3D%229.5%22%20fill%3D%22%239FD5B3%22%2F%3E%3C%2Fsvg%3E'); | ||
| background-repeat: no-repeat; | ||
| background-position-y: bottom; | ||
| background-size: 100% auto; | ||
| padding-bottom: 0.9%; | ||
| } |
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
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.