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

[FEAT] Icon Component #30

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
9 changes: 2 additions & 7 deletions src/modules/account/components/signin-button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { signInWithGoogle } from '@/lib/auth/actions'
import { Generic } from '@/types/global'
import { tw } from '@/lib/utils/tw'
import React from 'react'
import Icon from '@/modules/common/templates/icon'
Comment on lines 5 to +8
Copy link
Member

Choose a reason for hiding this comment

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

You must maintain an order in the imports based on their size.


const AccountSignInButton: React.FC<Generic> = ({ className }) =>
{
Expand All @@ -17,13 +18,7 @@ const AccountSignInButton: React.FC<Generic> = ({ className }) =>
className
)}
>
<UserCircleIcon
aria-hidden="true"
className={tw(
"size-6 flex-shrink-0",
"text-light-secondary dark:text-dark-secondary group-hover:text-light-text/60 dark:group-hover:text-dark-text/60"
)}
/>
<Icon icon={<UserCircleIcon />} />
Copy link
Member

Choose a reason for hiding this comment

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

You forgot to put back the classes that already had the icon before.

Suggested change
<Icon icon={<UserCircleIcon />} />
<Icon
icon={<UserCircleIcon />}
className={tw(
"size-6 flex-shrink-0",
"group-hover:text-light-text/60 dark:group-hover:text-dark-text/60"
)}
/>

</button>
</form>
)
Expand Down
9 changes: 2 additions & 7 deletions src/modules/common/components/select-button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@

import { ChevronDownIcon } from '@heroicons/react/24/outline'
import { ComboboxButton } from '@headlessui/react'
import { tw } from '@/lib/utils/tw'
import Icon from '@/modules/common/templates/icon'

const SelectButton = () =>
{
return (
<ComboboxButton className="group absolute inset-y-0 right-0 px-2.5">
<ChevronDownIcon
className={tw(
"size-4",
"text-light-text dark:text-dark-text"
)}
/>
<Icon icon={<ChevronDownIcon/>} />
</ComboboxButton>
)
}
Expand Down
8 changes: 2 additions & 6 deletions src/modules/common/templates/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import DropdownItem from '../components/dropdown-item'
import { DropdownProps } from '@/types/templates'
import React, { useState } from 'react'
import { tw } from '@/lib/utils/tw'
import Icon from './icon'

const Dropdown: React.FC<DropdownProps> = ({ options, label, className, children, onSelect }) =>
{
Expand All @@ -31,12 +32,7 @@ const Dropdown: React.FC<DropdownProps> = ({ options, label, className, children
>
{label}
{children}
<ChevronRightIcon
className={tw(
"text-light-text dark:text-dark-text size-4 transition-transform duration-200",
{ "rotate-90": isOpen }
)}
/>
<Icon icon={ChevronRightIcon} className="w-4 h-4" />
Copy link
Member

Choose a reason for hiding this comment

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

You forgot to put back the classes that already had the icon before.

Remember that you have to pass a created object, however, you are passing an unbuilt object, use < />.

Suggested change
<Icon icon={ChevronRightIcon} className="w-4 h-4" />
<Icon
icon={<ChevronRightIcon />}
className={tw(
"transition-transform duration-200",
{ "rotate-90": isOpen }
)}
/>

</MenuButton>

<MenuItems
Expand Down
21 changes: 21 additions & 0 deletions src/modules/common/templates/icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use client'

import { tw } from "@/lib/utils/tw";
import { IconProps } from "@/types/templates";
import React from "react";

const Icon: React.FC<IconProps> = ({ className, icon }) =>
{
return (
<span
className={tw(
"font-bold size-4",
"text-light-text dark:text-dark-text",
className
)}>
{icon}
</span>
);
}

export default Icon;
Comment on lines +1 to +21
Copy link
Member

@jdic jdic Nov 14, 2024

Choose a reason for hiding this comment

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

You must maintain a similar structure to the rest of the project, making use of ' when you are not in an HTML based structure and keep an order in the imports based on their size, also you must use a 2 spaces ident, not 4 spaces.

Suggested change
'use client'
import { tw } from "@/lib/utils/tw";
import { IconProps } from "@/types/templates";
import React from "react";
const Icon: React.FC<IconProps> = ({ className, icon }) =>
{
return (
<span
className={tw(
"font-bold size-4",
"text-light-text dark:text-dark-text",
className
)}>
{icon}
</span>
);
}
export default Icon;
'use client'
import { IconProps } from '@/types/templates'
import { tw } from '@/lib/utils/tw'
import React from 'react'
const Icon: React.FC<IconProps> = ({ className, icon }) =>
{
return (
<span
className={tw(
"size-4",
"text-light-text dark:text-dark-text",
className
)}>
{icon}
</span>
)
}
export default Icon

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { HeaderSideMenuCloseButtonProps } from '@/types/components'
import { XMarkIcon } from '@heroicons/react/24/outline'
import { tw } from '@/lib/utils/tw'
import React from 'react'
import Icon from '@/modules/common/templates/icon'

const HeaderSideMenuCloseButton: React.FC<HeaderSideMenuCloseButtonProps> = ({ onClose, className }) =>
{
Expand All @@ -20,9 +21,7 @@ const HeaderSideMenuCloseButton: React.FC<HeaderSideMenuCloseButtonProps> = ({ o
aria-label="Cerrar menú"
>
<span className="absolute -inset-0.5" />
<XMarkIcon
className="size-6"
aria-hidden="true"
<Icon icon={<XMarkIcon />}
/>
</button>
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/types/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@ export interface SelectProps extends Generic
onSelect?: (selected: SelectItem) => void
label?: string
}

export interface IconProps extends Generic
{
icon: JSX.Element
}