-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use the icon element instead of just the icon function fix(icon): remove faulty paths
- Loading branch information
Showing
21 changed files
with
187 additions
and
132 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -135,7 +135,3 @@ | |
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
|
||
.icon svg { | ||
display: block; | ||
} |
This file contains 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,47 @@ | ||
import { html, svg, LitElement } from "lit" | ||
import styles from "./icon.css" | ||
import { paths } from "./paths.js" | ||
|
||
/** | ||
* A component to render all defined zhWeb icons. | ||
* The `fill` of the icon is set to `currentColor` and | ||
* can be overriden by setting the css `color` property. | ||
* | ||
* @tagname leu-icon | ||
* @prop {import("./paths").IconPathName} name - The name of the icon to display. | ||
* @prop {number} size - Width and height of the icon. A icon will always be displayed as a square. | ||
*/ | ||
export class LeuIcon extends LitElement { | ||
static styles = styles | ||
|
||
static properties = { | ||
name: { type: String, reflect: true }, | ||
size: { type: Number, reflect: true }, | ||
} | ||
|
||
constructor() { | ||
super() | ||
|
||
/** | ||
* @type {import("./paths").IconPathName} | ||
*/ | ||
this.name = "addNew" | ||
this.size = 24 | ||
} | ||
|
||
render() { | ||
const iconPath = paths[this.name] | ||
|
||
return html` | ||
<svg | ||
width="${this.size}" | ||
height="${this.size}" | ||
fill="currentColor" | ||
viewBox="0 0 24 24" | ||
fill-rule="evenodd" | ||
> | ||
${svg`<path d=${iconPath} />`} | ||
</svg> | ||
` | ||
} | ||
} |
This file contains 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,3 @@ | ||
svg { | ||
display: block; | ||
} |
This file contains 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,6 @@ | ||
import { defineElement } from "../../lib/defineElement.js" | ||
import { LeuIcon } from "./Icon.js" | ||
|
||
export { LeuIcon } | ||
|
||
defineElement("icon", LeuIcon) |
41 changes: 4 additions & 37 deletions
41
src/components/icon/icon.js → src/components/icon/paths.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,46 @@ | ||
import { html } from "lit" | ||
import "../leu-icon.js" | ||
import { ifDefined } from "lit/directives/if-defined.js" | ||
import { paths } from "../paths.js" | ||
|
||
export default { | ||
title: "Icon", | ||
component: "leu-icon", | ||
argTypes: { | ||
name: { | ||
control: "select", | ||
options: Object.keys(paths), | ||
}, | ||
color: { | ||
control: { | ||
type: "color", | ||
presetColors: ["#009ee0", "#d93c1a", "#1a7f1f"], | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
function Template({ name, size, color }) { | ||
return html` <leu-icon | ||
style="color: ${color}" | ||
name=${ifDefined(name)} | ||
size=${ifDefined(size)} | ||
></leu-icon>` | ||
} | ||
|
||
export const Regular = Template.bind({}) | ||
Regular.args = { | ||
size: 24, | ||
} | ||
|
||
export const Small = Template.bind({}) | ||
Small.args = { | ||
size: 16, | ||
} | ||
|
||
export const Colored = Template.bind({}) | ||
Colored.args = { | ||
name: "smileyDevastated", | ||
size: 24, | ||
color: "#d93c1a", | ||
} |
Oops, something went wrong.