-
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.
client: add tag button and action button
- Loading branch information
1 parent
934b68e
commit ac8c9a6
Showing
7 changed files
with
179 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,30 @@ | ||
@import '@/variables'; | ||
|
||
.action-button { | ||
cursor: pointer; | ||
|
||
&--green { | ||
border-color: $navbar-selected-color; | ||
color: $navbar-selected-color; | ||
background-color: transparent; | ||
border-radius: 5px; | ||
|
||
&:hover { | ||
color: $secondary; | ||
background-color: $navbar-selected-color; | ||
} | ||
} | ||
|
||
&--red { | ||
border-color: $cancel-color; | ||
color: $cancel-color; | ||
background-color: transparent; | ||
border-radius: 5px; | ||
|
||
&:hover { | ||
color: $secondary; | ||
background-color: $cancel-color; | ||
} | ||
} | ||
|
||
} |
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,27 @@ | ||
import './ActionButton.scss'; | ||
|
||
export enum ActionButtonColor { | ||
GREEN, | ||
RED, | ||
} | ||
|
||
export interface ActionButtonProps { | ||
onClick: () => void; | ||
description: string; | ||
color: ActionButtonColor; | ||
} | ||
|
||
const actionButtonColorToClass = { | ||
[ActionButtonColor.GREEN]: 'action-button--green', | ||
[ActionButtonColor.RED]: 'action-button--red', | ||
}; | ||
|
||
const ActionButton = ({ onClick, description, color }: ActionButtonProps) => { | ||
return ( | ||
<button onClick={onClick} className={actionButtonColorToClass[color]}> | ||
{description} | ||
</button> | ||
); | ||
}; | ||
|
||
export default ActionButton; |
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,65 @@ | ||
@import '@/variables'; | ||
|
||
.tag-button { | ||
position: relative; | ||
width: 8rem; | ||
margin: 0; | ||
padding: 0; | ||
|
||
&__toggle { | ||
cursor: pointer; | ||
border: 2px solid $navbar-selected-color; | ||
background-color: transparent; | ||
color: $navbar-selected-color; | ||
border-radius: 5px; | ||
width: 8rem; | ||
align-items: center; | ||
justify-content: space-between; | ||
display: flex; | ||
flex-direction: row; | ||
|
||
.svg-icon { | ||
background-color: $navbar-selected-color; | ||
justify-content: flex-end; | ||
} | ||
|
||
&__description { | ||
text-align: center; | ||
width: 6rem; | ||
} | ||
|
||
&:hover { | ||
color: $secondary; | ||
background-color: $navbar-selected-color; | ||
|
||
.svg-icon { | ||
background-color: $secondary; | ||
} | ||
} | ||
} | ||
|
||
&__menu { | ||
position: absolute; | ||
top: 100%; | ||
left: 0; | ||
list-style-type: none; | ||
padding: 0; | ||
margin: 0; | ||
border: 2px solid $navbar-selected-color; | ||
background-color: transparent; | ||
color: $navbar-selected-color; | ||
width: 100%; | ||
border-radius: 5px; | ||
|
||
&__element { | ||
padding: 0.7rem 1.5rem; | ||
cursor: pointer; | ||
border-radius: 5px; | ||
|
||
&:hover { | ||
color: $secondary; | ||
background-color: $navbar-selected-color; | ||
} | ||
} | ||
} | ||
} |
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,42 @@ | ||
import { useReducer, useState } from 'react'; | ||
import './TagButton.scss'; | ||
import SVGIcon from 'components/SVGIcon/SVGIcon'; | ||
|
||
export interface TagButtonProps { | ||
listItems: Array<string>; | ||
chosenItem: string; | ||
} | ||
|
||
const TagButton = ({ listItems, chosenItem = listItems[0] }: TagButtonProps) => { | ||
const [isOpen, toggle] = useReducer((isOpenToChange) => !isOpenToChange, false); | ||
const [selectedOption, setSelectedOption] = useState(chosenItem); | ||
|
||
const handleOptionClick = (item: string) => { | ||
setSelectedOption(item); | ||
toggle(); | ||
}; | ||
|
||
return ( | ||
<div className="tag-button"> | ||
<div className="tag-button__toggle" onClick={toggle}> | ||
<div className='tag-button__toggle__description'>{selectedOption}</div> | ||
<SVGIcon iconName={isOpen ? 'reverse-drop-down-icon' : 'drop-down-icon'}/> | ||
</div> | ||
{isOpen && ( | ||
<ul className="tag-button__menu"> | ||
{listItems.map((item, index) => ( | ||
<li | ||
key={index} | ||
className="tag-button__menu__element" | ||
onClick={() => handleOptionClick(item)} | ||
> | ||
{item} | ||
</li> | ||
))} | ||
</ul> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default TagButton; |
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