Skip to content

Commit

Permalink
feat: add iconClasses prop to Icon components
Browse files Browse the repository at this point in the history
This commit adds the `iconClasses` prop to the Icon components, which allows for more flexible styling of the icons. The commonIconClasses variable is used to apply shared classes to all icons. The AllIcon, EnabledIcon, DisabledIcon and DeletedIcon components are updated to use this new prop instead of className.
  • Loading branch information
ajyey committed Jun 21, 2023
1 parent c9224e3 commit 5a1a272
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,26 @@ function FilterEmailsDropdown({
}: {
onFilterChange: (option: string) => void;
}) {
const commonSvgClasses = 'w-5 h-5 mr-2';
const dropdownItems = [
{
label: 'All',
value: 'All',
icon: <AllIcon className={`${commonSvgClasses} stroke-mikado-yellow`} />
icon: <AllIcon iconClasses={'stroke-mikado-yellow'} />
},
{
label: 'Enabled',
value: 'Enabled',
icon: <EnabledIcon className={`${commonSvgClasses} stroke-eucalyptus`} />
icon: <EnabledIcon iconClasses={'stroke-eucalyptus'} />
},
{
label: 'Disabled',
value: 'Disabled',
icon: <DisabledIcon className={`${commonSvgClasses} stroke-magnesium`} />
icon: <DisabledIcon iconClasses={'stroke-magnesium'} />
},
{
label: 'Deleted',
value: 'Deleted',
icon: <DeletedIcon className={`${commonSvgClasses} stroke-red-500`} />
icon: <DeletedIcon iconClasses={'stroke-red-500'} />
}
];
// State for the dropdown menu open/close status
Expand Down
44 changes: 34 additions & 10 deletions src/pages/popup/components/home/icons/icons.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import React from 'react';

/**
* Props for the Icon components
*/
interface IconProps {
className?: string;
iconClasses?: string;
}
// classes shared by all icons
const commonIconClasses = 'w-5 h-5 mr-2';

export const AllIcon: React.FC<IconProps> = ({ className }) => (
/**
* SVG icon for the "All" dropdown filter option
* @param iconClasses classes to apply to the icon
* https://heroicons.com/
*/
export const AllIcon: React.FC<IconProps> = ({ iconClasses }) => (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className={className}
className={`${commonIconClasses} ${iconClasses}`}
>
<path
strokeLinecap="round"
Expand All @@ -21,14 +31,19 @@ export const AllIcon: React.FC<IconProps> = ({ className }) => (
</svg>
);

export const EnabledIcon: React.FC<IconProps> = ({ className }) => (
/**
* SVG icon for the "Enabled" dropdown filter option
* @param iconClasses classes to apply to the icon
* https://heroicons.com/
*/
export const EnabledIcon: React.FC<IconProps> = ({ iconClasses }) => (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className={className}
className={`${commonIconClasses} ${iconClasses}`}
>
<path
strokeLinecap="round"
Expand All @@ -37,15 +52,19 @@ export const EnabledIcon: React.FC<IconProps> = ({ className }) => (
/>
</svg>
);

export const DisabledIcon: React.FC<IconProps> = ({ className }) => (
/**
* SVG icon for the "Disabled" dropdown filter option
* @param iconClasses classes to apply to the icon
* https://heroicons.com/
*/
export const DisabledIcon: React.FC<IconProps> = ({ iconClasses }) => (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className={className}
className={`${commonIconClasses} ${iconClasses}`}
>
<path
strokeLinecap="round"
Expand All @@ -55,14 +74,19 @@ export const DisabledIcon: React.FC<IconProps> = ({ className }) => (
</svg>
);

export const DeletedIcon: React.FC<IconProps> = ({ className }) => (
/**
* SVG icon for the "Deleted" dropdown filter option
* @param iconClasses classes to apply to the icon
* https://heroicons.com/
*/
export const DeletedIcon: React.FC<IconProps> = ({ iconClasses }) => (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className={className}
className={`${commonIconClasses} ${iconClasses}`}
>
<path
strokeLinecap="round"
Expand Down

0 comments on commit 5a1a272

Please sign in to comment.