Skip to content
Open
Show file tree
Hide file tree
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 Mar 14, 2025
5ba6f85
Fixed prettier issues in 2 files
sreidthomas Mar 14, 2025
9f3af58
Updated index-experimental.js file
sreidthomas Mar 14, 2025
44e7bf1
Second attempt to fix experimental-index.js
sreidthomas Mar 14, 2025
78f9f83
3rd attempt to fix experimental-index.js file
sreidthomas Mar 14, 2025
6cabae0
Fourth attempt to fix index-experimental.js file
sreidthomas Mar 14, 2025
43f8982
Fixed prettier issues in 2 files
sreidthomas Mar 14, 2025
cf0cd3e
Added backwards compatibility and changed scss/css back to normal
sreidthomas Mar 18, 2025
1024aab
Fixed prettier issues in 2 files
sreidthomas Mar 18, 2025
b11cc4b
Added switch statement for both fontawesome and bootstrap icons
sreidthomas Mar 21, 2025
0a25e82
Fixed major issues in stories file and library attribute not being us…
sreidthomas Mar 21, 2025
4e14720
Attempt to fix merge issue
sreidthomas Mar 21, 2025
38cdb10
Fixed path for Icon
sreidthomas Mar 21, 2025
bea7ba2
Added slot for Icon SVG. Attempt to add switch for fontawesome and bo…
sreidthomas Mar 25, 2025
af9bf9a
Fixed prettier issues in 1 file
sreidthomas Mar 25, 2025
1c2a952
Removed comment to see if full code gets pushed
sreidthomas Mar 25, 2025
afcdc48
Fixed highlight svg issue. removed unneeded comments
sreidthomas Mar 25, 2025
a98ce94
Fixed prettier issues in 1 file
sreidthomas Mar 25, 2025
0974937
Merge branch 'dev' into feature.issue.295
sreidthomas Apr 9, 2025
7950a22
Added documentation for Icon component. Fixed prettier issues in 1 file
sreidthomas Apr 10, 2025
3d091bb
Moved import from index-experimental.js to index-stable.js
sreidthomas Apr 10, 2025
c044e82
Made renderIcon a private method
sreidthomas Apr 10, 2025
7b2fe38
Made isIconConnected a private method
sreidthomas Apr 10, 2025
4766198
Fixed path in icon.mdx, updated icon.stories.js file because doc cann…
sreidthomas Apr 10, 2025
44880ea
removed aria-label as a fallback
sreidthomas Apr 10, 2025
5542e52
Fixed issues with icon not showing in storybook. removed size attribu…
sreidthomas Apr 10, 2025
e44c9e3
Removed the size attribute
sreidthomas Apr 10, 2025
7b42096
Fixed prettier issues in 2 files
sreidthomas Apr 10, 2025
0600a1d
Added attributes to be reflective and added the font-size feature
sreidthomas Apr 11, 2025
423cf91
Attempt to fix Reflective JS issue
sreidthomas Apr 17, 2025
574f2f9
Attempt to fix Reflective JS issue
sreidthomas Apr 17, 2025
7901637
Fixed prettier issues in 1 file
sreidthomas Apr 17, 2025
70ea206
Added icon code back the way it was. certain features were not workin…
sreidthomas Apr 17, 2025
a85a438
Fixed prettier issues in 1 file
sreidthomas Apr 17, 2025
db8a791
Attempt to add inheritance in stories file. still issues with icon.md…
sreidthomas Apr 24, 2025
3e7d065
Fixed prettier issues in 1 file
sreidthomas Apr 24, 2025
e5f2064
Removed setter for is-hightlighted
sreidthomas Apr 29, 2025
035ae67
Removed custom property and made color inherit
sreidthomas Apr 29, 2025
d75c302
Grouped attributes in documentation
sreidthomas Apr 29, 2025
2d725fa
Updated attributes added deprecated to outdated attributes and reflec…
sreidthomas Apr 29, 2025
b8512bd
Added controls to Icon Story documentation file
sreidthomas Apr 29, 2025
5fa2d7d
Fixed prettier issues in 1 file
sreidthomas Apr 29, 2025
f363cfe
Fixed documentation issues for storybook
sreidthomas Apr 29, 2025
693ba70
Fixed prettier issues in 1 file
sreidthomas Apr 29, 2025
4c94278
Fixed issues with Icon.mdx file and fixed undefined icon issue
sreidthomas Apr 29, 2025
77efc13
Added Size and Color information to documentation
sreidthomas Apr 29, 2025
3cb1754
Removed icon-color inherit from :host rule
sreidthomas May 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
416 changes: 0 additions & 416 deletions src/experimental/components/atoms/Icon/Icon.js

This file was deleted.

1 change: 0 additions & 1 deletion src/experimental/index-experimental.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import './components/atoms/FormCheck/cod-formcheck';
import './components/atoms/FormControl/cod-formcontrol';
import './components/atoms/FormLabel/cod-formlabel';
import './components/atoms/FormSelect/cod-formselect';
import './components/atoms/Icon/cod-icon';
import './components/atoms/Image/cod-image';
import './components/atoms/LegacyButton/cod-legacy-button';
import './components/atoms/LegacyIcon/cod-legacy-icon';
Expand Down
2 changes: 1 addition & 1 deletion src/experimental/stories/actionbutton.stories.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { html } from 'lit-html';
import '../components/atoms/ActionButton/cod-action-button';
import '../components/atoms/Icon/cod-icon';
import '../../stable/components/Icon/cod-icon';
import { COMMON_STORY_ARGS } from '../../shared/js/storybook/args-utils';

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/experimental/stories/actionbuttonV2.stories.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { html } from 'lit-html';
import '../components/atoms/ActionButtonV2/cod-action-button-v2';
import '../components/atoms/Icon/cod-icon';
import '../../stable/components/Icon/cod-icon';
import { COMMON_STORY_ARGS } from '../../shared/js/storybook/args-utils';

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/experimental/stories/button.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '../components/atoms/Button/cod-button';
import '../components/atoms/Icon/cod-icon';
import '../../stable/components/Icon/cod-icon';
import { COMMON_STORY_ARGS } from '../../shared/js/storybook/args-utils';

export default {
Expand Down
36 changes: 0 additions & 36 deletions src/experimental/stories/icon.stories.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/experimental/stories/infobutton.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { html } from 'lit-html';
import '../components/atoms/Icon/cod-icon';
import '../../stable/components/Icon/cod-icon';
import '../components/atoms/InfoButton/cod-info-button';

export default {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/stable/components/Icon/Icon.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

129 changes: 129 additions & 0 deletions src/stable/components/Icon/Icon.js
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() {
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 };
26 changes: 26 additions & 0 deletions src/stable/components/Icon/Icon.scss
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%;
}
Loading
Loading