Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: material design icons' color to match theme #10

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ function App() {
};
}, [iconSetsSettings]);

function generateIconList(icons: (typeof iconSets)[number]["icons"]) {
function generateIconList(
icons: (typeof iconSets)[number]["icons"],
{
iconSettings: { svg: { attributes: customSvgAttributes = "" } = {} } = {},
}: Pick<(typeof iconSets)[number], "iconSettings">,
) {
return Object.entries(icons)
.filter(([name]) => {
return name.toLowerCase().includes(searchPhrase.toLowerCase());
Expand All @@ -101,7 +106,12 @@ function App() {
},
]) => {
const svg = `<svg ${attributes}>${elements}</svg>`;
const icon = <Icon attributes={attributes} elements={elements} />;
const icon = (
<Icon
attributes={`${attributes} ${customSvgAttributes}`}
elements={elements}
/>
);

return (
<IconButton
Expand All @@ -125,7 +135,7 @@ function App() {
}

const iconGrids = iconSets.map(
({ id, name, website, license, variantOptions, icons }) => {
({ id, name, website, license, variantOptions, icons, iconSettings }) => {
const hasMultipleVariants = variantOptions.length > 1;
const { showIcons: shouldShowIcons } = iconSetsSettings[id];

Expand Down Expand Up @@ -170,7 +180,9 @@ function App() {
</ControlsBar>
{shouldShowIcons && (
<GridList
items={generateIconList(icons)}
items={generateIconList(icons, {
iconSettings,
})}
emptyMessage={`No icons found for "${searchPhrase}" in ${name} library.`}
/>
)}
Expand Down
10 changes: 10 additions & 0 deletions src/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ type IconLibrary = {
url: string;
};
icons: IconSetVariant[];
iconSettings?: {
svg?: {
attributes?: string;
};
};
defaultSettings?: Partial<IconSetSettings>;
};

Expand Down Expand Up @@ -89,6 +94,11 @@ export const iconLibraries: IconLibrary[] = [
"sharp",
"two-tone",
]),
iconSettings: {
svg: {
attributes: 'fill="currentColor"',
},
},
defaultSettings: { selectedVariant: "outlined" },
},
];
Expand Down