Skip to content

Commit

Permalink
experiment: add LitElement based version of icon (#7263)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki authored Apr 19, 2024
1 parent 03a6d2d commit 0c688b7
Show file tree
Hide file tree
Showing 29 changed files with 918 additions and 688 deletions.
2 changes: 2 additions & 0 deletions packages/icon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"theme",
"vaadin-*.d.ts",
"vaadin-*.js",
"!vaadin-lit-*.d.ts",
"!vaadin-lit-*.js",
"web-types.json",
"web-types.lit.json"
],
Expand Down
88 changes: 88 additions & 0 deletions packages/icon/src/vaadin-icon-mixin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* @license
* Copyright (c) 2017 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import type { Constructor } from '@open-wc/dedupe-mixin';
import type { SlotStylesMixinClass } from '@vaadin/component-base/src/slot-styles-mixin.js';
import type { IconFontSizeMixinClass } from './vaadin-icon-font-size-mixin.js';
import type { IconSvgLiteral } from './vaadin-icon-svg.js';

/**
* A mixin providing common icon functionality.
*/
export declare function IconMixin<T extends Constructor<HTMLElement>>(
base: T,
): Constructor<IconFontSizeMixinClass> & Constructor<IconMixinClass> & Constructor<SlotStylesMixinClass> & T;

export declare class IconMixinClass {
/**
* The name of the icon to use. The name should be of the form:
* `iconset_name:icon_name`. When using `vaadin-icons` it is possible
* to omit the first part and only use `icon_name` as a value.
*
* Setting the `icon` property updates the `svg` and `size` based on the
* values provided by the corresponding `vaadin-iconset` element.
*
* See also [`name`](#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.
*
* @attr {string} icon
*/
icon: string | null;

/**
* The SVG icon wrapped in a Lit template literal.
*/
svg: IconSvgLiteral | null;

/**
* The SVG source to be loaded as the icon. It can be:
* - an URL to a file containing the icon
* - an URL in the format "/path/to/file.svg#objectID", where the "objectID" refers to an ID attribute contained
* inside the SVG referenced by the path. Note that the file needs to follow the same-origin policy.
* - a string in the format "data:image/svg+xml,<svg>...</svg>". You may need to use the "encodeURIComponent"
* function for the SVG content passed
*/
src: string | null;

/**
* The symbol identifier that references an ID of an element contained in the SVG element assigned to the
* `src` property
*/
symbol: string | null;

/**
* Class names defining an icon font and/or a specific glyph inside an icon font.
*
* Example: "fa-solid fa-user"
*
* @attr {string} icon-class
*/
iconClass: string | null;

/**
* A hexadecimal code point that specifies a glyph from an icon font.
*
* Example: "e001"
*/
char: string | null;

/**
* A ligature name that specifies an icon from an icon font with support for ligatures.
*
* Example: "home".
*/
ligature: string | null;

/**
* The font family to use for the font icon.
*
* @attr {string} font-family
*/
fontFamily: string | null;

/**
* The size of an icon, used to set the `viewBox` attribute.
*/
size: number;
}
Loading

0 comments on commit 0c688b7

Please sign in to comment.