mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 10:38:13 -05:00
💄 Update icon prop name
This commit is contained in:
parent
d7ca4d49dc
commit
7e61acc4da
3 changed files with 21 additions and 17 deletions
|
@ -279,10 +279,10 @@
|
|||
|
||||
(mf/defc icon*
|
||||
{::mf/props :obj}
|
||||
[{:keys [icon size class] :rest props}]
|
||||
[{:keys [id size class] :rest props}]
|
||||
(let [class (dm/str (or class "") " " (stl/css :icon))
|
||||
props (mf/spread-props props {:class class :width icon-size-m :height icon-size-m})
|
||||
size-px (cond (= size "s") icon-size-s :else icon-size-m)
|
||||
offset (/ (- icon-size-m size-px) 2)]
|
||||
[:> "svg" props
|
||||
[:use {:href (dm/str "#icon-" icon) :width size-px :height size-px :x offset :y offset}]]))
|
||||
[:use {:href (dm/str "#icon-" id) :width size-px :height size-px :x offset :y offset}]]))
|
||||
|
|
|
@ -47,7 +47,7 @@ Assuming the namespace is required as `i`:
|
|||
You can now use the icon IDs defined in the namespace:
|
||||
|
||||
```clj
|
||||
[:> i/icon* {:icon i/pin}]
|
||||
[:> i/icon* {:id i/pin}]
|
||||
```
|
||||
|
||||
### Customizing colors
|
||||
|
@ -59,7 +59,7 @@ If you need to override this behavior, you can use a `class` in the `<Icon>`
|
|||
component and set `color` to whatever value you prefer:
|
||||
|
||||
```clj
|
||||
[:> i/icon* {:icon i/add :class (stl/css :toolbar-icon)}]
|
||||
[:> i/icon* {:id i/add :class (stl/css :toolbar-icon)}]
|
||||
```
|
||||
|
||||
```scss
|
||||
|
@ -74,7 +74,7 @@ By default, icons do not have any accessible text attached to them. You should
|
|||
add an `aria-label` attribute to set a proper text:
|
||||
|
||||
```clj
|
||||
[:> i/icon* {:icon i/add :aria-label (tr "foo.bar")}]
|
||||
[:> i/icon* {:id i/add :aria-label (tr "foo.bar")}]
|
||||
```
|
||||
|
||||
## Usage guidelines for design
|
||||
|
|
|
@ -14,7 +14,7 @@ export default {
|
|||
title: "Foundations/Assets/Icon",
|
||||
component: Components.Icon,
|
||||
argTypes: {
|
||||
icon: {
|
||||
id: {
|
||||
options: iconList,
|
||||
control: { type: "select" }
|
||||
},
|
||||
|
@ -25,12 +25,12 @@ export default {
|
|||
}
|
||||
};
|
||||
|
||||
export const AllIcons = {
|
||||
render: () => (
|
||||
export const All = {
|
||||
render: ({size}) => (
|
||||
<StoryWrapper theme="default">
|
||||
<StoryHeader>
|
||||
<h1>All Icons</h1>
|
||||
<p>Hover on an icon to see its ID</p>
|
||||
<p>Hover on an icon to see its ID.</p>
|
||||
</StoryHeader>
|
||||
<StoryGrid>
|
||||
{iconList.map((iconId) => (
|
||||
|
@ -39,39 +39,43 @@ export const AllIcons = {
|
|||
key={iconId}
|
||||
style={{ color: "var(--color-accent-primary)" }}
|
||||
>
|
||||
<Icon icon={iconId} />
|
||||
<Icon id={iconId} size={size} />
|
||||
</StoryGridCell>
|
||||
))}
|
||||
</StoryGrid>
|
||||
</StoryWrapper>
|
||||
),
|
||||
args: {
|
||||
size: "m",
|
||||
},
|
||||
parameters: {
|
||||
controls: { exclude: ["id", "size"] },
|
||||
backgrounds: { disable: true },
|
||||
},
|
||||
};
|
||||
|
||||
export const Default = {
|
||||
render: ({icon, ...args}) => (
|
||||
render: ({id, ...args}) => (
|
||||
<StoryWrapper theme="default">
|
||||
<Icon icon={icon} />
|
||||
<Icon id={id} {...args} />
|
||||
</StoryWrapper>
|
||||
),
|
||||
args: {
|
||||
icon: "pin",
|
||||
id: "pin",
|
||||
},
|
||||
parameters: {
|
||||
controls: { exclude: "size" }
|
||||
controls: { exclude: ["size"] }
|
||||
}
|
||||
};
|
||||
|
||||
export const CustomSize = {
|
||||
render: ({icon, size, ...args}) => (
|
||||
render: ({id, size, ...args}) => (
|
||||
<StoryWrapper theme="default">
|
||||
<Icon icon={icon} size={size} />
|
||||
<Icon id={id} size={size} {...args} />
|
||||
</StoryWrapper>
|
||||
),
|
||||
args: {
|
||||
icon: "pin",
|
||||
id: "pin",
|
||||
size: "m",
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue