Skip to content

Commit

Permalink
Add custom Icon color example (#2762)
Browse files Browse the repository at this point in the history
Co-authored-by: mikearildbrown <[email protected]>
  • Loading branch information
joshwooding and mikearildbrown authored Nov 22, 2023
1 parent 2fd8c03 commit 96fa15a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions site/docs/components/icon/examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ data:

If you need a custom SVG icon, use the Icon component. Icon has the same API as the native `<svg>` element. Whenever you add a custom icon, pass an `aria-label` to Icon.

</LivePreview>
<LivePreview componentName="icon" exampleName="CustomColors">
### Custom colors
If you need to use a color other than "primary" or "secondary", use `color="inherit"` or use CSS to change the icon's `fill`.

</LivePreview>
<LivePreview componentName="icon" exampleName="AllIcons">
### All Icons
Expand Down
17 changes: 17 additions & 0 deletions site/src/examples/icon/CustomColors.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ReactElement } from "react";
import { ArrowDownIcon, ArrowUpIcon } from "@salt-ds/icons";
import { StackLayout } from "@salt-ds/core";

export const CustomColors = (): ReactElement => {
return (
<StackLayout direction="row">
<div style={{ color: "var(--salt-status-positive-foreground)" }}>
<ArrowUpIcon color="inherit" size={2} />
</div>
<ArrowDownIcon
style={{ fill: "var(--salt-status-negative-foreground)" }}
size={2}
/>
</StackLayout>
);
};
2 changes: 1 addition & 1 deletion site/src/examples/icon/CustomIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReactElement } from "react";
import { Icon, IconProps } from "@salt-ds/icons";
import { Icon } from "@salt-ds/icons";

export const CustomIcon = (): ReactElement => {
return (
Expand Down
1 change: 1 addition & 0 deletions site/src/examples/icon/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from "./BasicIcon";
export * from "./AllIcons";
export * from "./IconColor";
export * from "./CustomColors";
export * from "./CustomIcon";
export * from "./IconSize";
export * from "./IconTypes";

1 comment on commit 96fa15a

@vercel
Copy link

@vercel vercel bot commented on 96fa15a Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.