diff --git a/index.html b/index.html index cafc7819..cb7ec4cb 100644 --- a/index.html +++ b/index.html @@ -1634,24 +1634,14 @@

Drawer

Open Drawer -
+

Tooltip

Hover me - - - - - + + - - - - + ${newVersion}, but <${name}>${existingVersion} has already been registered.` // ); } - + /** @internal */ static dependencies: Record = {}; constructor() { diff --git a/src/components/Icon/icon.css b/src/components/Icon/icon.css index 6565401a..5f523beb 100644 --- a/src/components/Icon/icon.css +++ b/src/components/Icon/icon.css @@ -1,5 +1,6 @@ :host { color: inherit; + display: inline-block; } :host([size="sm"]) svg { width: var(--sgds-icon-size-sm); @@ -27,7 +28,7 @@ } svg { - display: block; + display: inline-block; width: var(--sgds-icon-size-lg); height: var(--sgds-icon-size-lg); } \ No newline at end of file diff --git a/src/components/Icon/sgds-icon.ts b/src/components/Icon/sgds-icon.ts index 52a2980e..97223df8 100644 --- a/src/components/Icon/sgds-icon.ts +++ b/src/components/Icon/sgds-icon.ts @@ -5,10 +5,7 @@ import { unsafeSVG } from "lit/directives/unsafe-svg.js"; import iconStyles from "./icon.css"; /** - * @summary Icons offer a form of visual shorthand that we are all familiar with. They can label, inform and aid navigation quickly and effectively in minimal space. Icons must first and foremost communicate meaning. By default, the icon component renders icons form SgdsIcon library set - * - * @event sgds-blur - Emitted when the button is blurred. - * @event sgds-focus - Emitted when the button is focused. + * @summary Icons offer a form of visual shorthand that we are all familiar with. They can label, inform and aid navigation quickly and effectively in minimal space. Icons must first and foremost communicate meaning. By default, the icon component renders icons from `SgdsIcon` library set */ export class SgdsIcon extends SgdsElement { static styles = [...SgdsElement.styles, iconStyles]; @@ -25,14 +22,12 @@ export class SgdsIcon extends SgdsElement { async updated(changedProperties: Map) { if (changedProperties.has("name")) { - await this.loadSvg(this.name); + await this._loadSvg(this.name); } - this.style.display = this._svgContent ? "" : "none"; } - async loadSvg(name: string): Promise { + private async _loadSvg(name: string): Promise { if (name) { - // Dynamically import the SVG if not cached const pascalName = name .split("-") .map(name => String(name).charAt(0).toUpperCase() + String(name).slice(1)) @@ -43,7 +38,7 @@ export class SgdsIcon extends SgdsElement { if (svg) { this._svgContent = svg; } else { - throw new Error("Icon `name` is undefined"); + throw new Error("icon `name` not found"); } } catch (error) { console.error(`Unable to load icon: ${name}.`, error); diff --git a/src/components/QuantityToggle/sgds-quantity-toggle.ts b/src/components/QuantityToggle/sgds-quantity-toggle.ts index 84754e92..9f5bb9d6 100644 --- a/src/components/QuantityToggle/sgds-quantity-toggle.ts +++ b/src/components/QuantityToggle/sgds-quantity-toggle.ts @@ -12,7 +12,6 @@ import { SgdsFormValidatorMixin } from "../../utils/validatorMixin"; import SgdsIconButton from "../IconButton/sgds-icon-button"; import SgdsInput from "../Input/sgds-input"; import quantityToggleStyle from "./quantity-toggle.css"; -import SgdsIcon from "../Icon/sgds-icon"; /** * @summary The quantity toggle component is used to increase or decrease an incremental venue, best used when the user needs to enter or adjust the quantity of a selected item. * diff --git a/src/components/Tooltip/sgds-tooltip.ts b/src/components/Tooltip/sgds-tooltip.ts index 5ec84849..e4a38ca7 100644 --- a/src/components/Tooltip/sgds-tooltip.ts +++ b/src/components/Tooltip/sgds-tooltip.ts @@ -112,7 +112,7 @@ export class SgdsTooltip extends SgdsElement { render() { return html` -
+
`; diff --git a/src/components/Tooltip/tooltip.css b/src/components/Tooltip/tooltip.css index 76d80ad3..f4e5dc7b 100644 --- a/src/components/Tooltip/tooltip.css +++ b/src/components/Tooltip/tooltip.css @@ -1,3 +1,9 @@ +:host { + display: contents; +} +.tooltip-placeholder{ + display: inline-block; +} .tooltip { word-wrap: break-word; display: block; diff --git a/stories/templates/Icon/additional.mdx b/stories/templates/Icon/additional.mdx new file mode 100644 index 00000000..b89fee34 --- /dev/null +++ b/stories/templates/Icon/additional.mdx @@ -0,0 +1,15 @@ +## Sizes + +SgdsIcons offer a variety of sizes : `sm` , `md` , `lg` , `xl` , `2-xl` , `3-xl`. By default, the icon size is `lg` + + + + + +## Color + +The color of the icons is inherited from its parent container + + + + diff --git a/stories/templates/Icon/additional.stories.js b/stories/templates/Icon/additional.stories.js new file mode 100644 index 00000000..ab9c7e9e --- /dev/null +++ b/stories/templates/Icon/additional.stories.js @@ -0,0 +1,35 @@ +import { html } from "lit-html"; + +const SizeTemplate = args => { + const sizes = ["sm", "md", "lg", "xl", "2-xl", "3-xl"]; + return html`${sizes.map(s => html` `)} `; +}; + +const ColorTemplate = args => { + const colors = ["red", "blue", "green", "purple", "pink"]; + return html` + ${colors.map( + c => html` + + + + ` + )} + `; +}; + +export const Size = { + render: SizeTemplate.bind({}), + name: "Size", + args: {}, + parameters: {}, + tags: ["!dev"] +}; + +export const Color = { + render: ColorTemplate.bind({}), + name: "Color", + args: {}, + parameters: {}, + tags: ["!dev"] +}; diff --git a/stories/templates/Icon/basic.js b/stories/templates/Icon/basic.js index cb0b598e..6e8de81e 100644 --- a/stories/templates/Icon/basic.js +++ b/stories/templates/Icon/basic.js @@ -1,7 +1,306 @@ import { html } from "lit-html"; +import * as icons from "../../../src/components/Icon/icon-registry"; +import { pascalToKebab } from "../../../scripts/shared.mjs"; -export const Template = args => html``; +export const Template = args => { + const iconNames = Object.keys(icons).map(i => pascalToKebab(i)); + return html`
+ ${iconNames.map( + i => html` + + + + ` + )} +
`; +}; export const args = {}; -export const parameters = {}; +export const parameters = { + docs: { + source: { + code: ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ` + } + } +}; diff --git a/test/icon-button.test.ts b/test/icon-button.test.ts index a2bbe51f..88bfc2c5 100644 --- a/test/icon-button.test.ts +++ b/test/icon-button.test.ts @@ -12,6 +12,7 @@ describe("", () => { ); const el = await fixture(html``); + await el.updateComplete; assert.shadowDom.equal( el, ` @@ -20,7 +21,7 @@ describe("", () => { class="btn btn-icon btn-primary btn-md" tabindex="0" type="button"> - + ` ); diff --git a/test/icon-list.test.ts b/test/icon-list.test.ts index 94888e52..9e68a048 100644 --- a/test/icon-list.test.ts +++ b/test/icon-list.test.ts @@ -12,7 +12,6 @@ describe("", () => {
diff --git a/test/overflow-menu.test.ts b/test/overflow-menu.test.ts index dd63c58b..53286f37 100644 --- a/test/overflow-menu.test.ts +++ b/test/overflow-menu.test.ts @@ -10,7 +10,7 @@ describe("", () => { `