-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Popup improvements and acknowledgement of existing vite bug: vitejs/v…
- Loading branch information
Showing
10 changed files
with
151 additions
and
78 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { PopupItemT } from './PopupTypes'; | ||
|
||
import _classes from './popup.module.css'; | ||
import { classNames } from '../../utils'; | ||
|
||
export interface ItemClassesT { | ||
item?: string, | ||
itemHover?: string, | ||
itemActive?: string, | ||
}; | ||
|
||
export interface ItemStylesT { | ||
item?: React.CSSProperties, | ||
itemHover?: React.CSSProperties, | ||
itemActive?: React.CSSProperties, | ||
}; | ||
|
||
interface Props { | ||
classes?: ItemClassesT, | ||
styles?: ItemStylesT, | ||
item: PopupItemT, | ||
}; | ||
|
||
const Item = ({ | ||
classes, | ||
styles, | ||
item, | ||
}: Props) => { | ||
//------------------------------------------------------------------------------------------------------------------ | ||
// State | ||
//------------------------------------------------------------------------------------------------------------------ | ||
const [hovered, setHovered] = useState<boolean>(false); | ||
const [active, setActive] = useState<boolean>(false); | ||
|
||
//------------------------------------------------------------------------------------------------------------------ | ||
// Styling | ||
//------------------------------------------------------------------------------------------------------------------ | ||
const itemClassName = classNames( | ||
classNames(_classes?.item, classes?.item ), | ||
hovered && classNames(_classes?.itemHover, classes?.itemHover), | ||
active && classNames(_classes?.itemActive, classes?.itemActive), | ||
); | ||
|
||
console.log(itemClassName) | ||
|
||
const itemStyle = { | ||
...styles?.item, | ||
...( hovered ? styles?.itemHover : {} ), | ||
...( active ? styles?.itemActive : {} ), | ||
}; | ||
|
||
//------------------------------------------------------------------------------------------------------------------ | ||
// Event Handlers | ||
//------------------------------------------------------------------------------------------------------------------ | ||
const handleMouseEnter = () => setHovered(true); | ||
const handleMouseLeave = () => setHovered(false); | ||
const handleMouseDown = () => setActive(true); | ||
const handleMouseUp = () => setActive(false); | ||
|
||
return ( | ||
<div key={ item.id } | ||
className ={ itemClassName } | ||
style ={ itemStyle } | ||
onClick ={ item.onClick } | ||
onMouseEnter ={ handleMouseEnter } | ||
onMouseLeave ={ handleMouseLeave } | ||
onMouseDown ={ handleMouseDown } | ||
onMouseUp ={ handleMouseUp } | ||
> | ||
{ item.label } | ||
</div> | ||
); | ||
}; | ||
|
||
export default Item; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,5 +240,5 @@ | |
|
||
.popupItem_hover { | ||
background: var(--COLOR-SECONDARY-3); | ||
color: red; | ||
color: var(--COLOR-PRIMARY-1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters