Skip to content

Commit

Permalink
feat: add disabled state
Browse files Browse the repository at this point in the history
  • Loading branch information
remvze committed Jan 4, 2024
1 parent c8e5122 commit ff26597
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/components/menu/item/item.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
outline: none;
transition: 0.2s;

&:hover {
&:disabled {
cursor: not-allowed;
opacity: 0.4;
}

&:not(:disabled):hover {
color: var(--color-foreground);
background-color: var(--color-neutral-200);
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/menu/item/item.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import styles from './item.module.css';

interface ItemProps {
disabled: boolean;
icon: React.ReactElement;
label: string;
onClick: () => void;
}

export function Item({ icon, label, onClick }: ItemProps) {
export function Item({ disabled = false, icon, label, onClick }: ItemProps) {
return (
<button className={styles.item} onClick={onClick}>
<button className={styles.item} disabled={disabled} onClick={onClick}>
<span className={styles.icon}>{icon}</span> {label}
</button>
);
Expand Down
11 changes: 10 additions & 1 deletion src/components/menu/items/share.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@ import { IoShareSocialSharp } from 'react-icons/io5/index';

import { Item } from '../item';

import { useSoundStore } from '@/store';

interface ShareProps {
open: () => void;
}

export function Share({ open }: ShareProps) {
const noSelected = useSoundStore(state => state.noSelected());

return (
<Item icon={<IoShareSocialSharp />} label="Share Sounds" onClick={open} />
<Item
disabled={noSelected}
icon={<IoShareSocialSharp />}
label="Share Sounds"
onClick={open}
/>
);
}

0 comments on commit ff26597

Please sign in to comment.