mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-22 22:30:52 +01:00
Merge branch '@feature/sticky-notes' into '@fix/zalgo-text'
Fix sticky notes (issue #137) - (feature #238) See merge request nitro/nitro-react!69
This commit is contained in:
commit
8512588905
BIN
src/assets/images/room-widgets/stickie-widget/stickie-dreams.png
Normal file
BIN
src/assets/images/room-widgets/stickie-widget/stickie-dreams.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
BIN
src/assets/images/room-widgets/stickie-widget/stickie-heart.png
Normal file
BIN
src/assets/images/room-widgets/stickie-widget/stickie-heart.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 945 B |
Binary file not shown.
After Width: | Height: | Size: 405 B |
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
@ -5,6 +5,8 @@ import { useFurnitureStickieWidget } from '../../../../hooks';
|
||||
|
||||
const STICKIE_COLORS = [ '9CCEFF','FF9CFF', '9CFF9C','FFFF33' ];
|
||||
const STICKIE_COLOR_NAMES = [ 'blue', 'pink', 'green', 'yellow' ];
|
||||
const STICKIE_TYPES = [ 'post_it','post_it_shakesp', 'post_it_dreams','post_it_xmas', 'post_it_vd', 'post_it_juninas' ];
|
||||
const STICKIE_TYPE_NAMES = [ 'post_it', 'shakesp', 'dreams', 'christmas', 'heart', 'juninas' ];
|
||||
|
||||
const getStickieColorName = (color: string) =>
|
||||
{
|
||||
@ -15,31 +17,43 @@ const getStickieColorName = (color: string) =>
|
||||
return STICKIE_COLOR_NAMES[index];
|
||||
}
|
||||
|
||||
const getStickieTypeName = (type: string) =>
|
||||
{
|
||||
let index = STICKIE_TYPES.indexOf(type);
|
||||
|
||||
if(index === -1) index = 0;
|
||||
|
||||
return STICKIE_TYPE_NAMES[index];
|
||||
}
|
||||
|
||||
export const FurnitureStickieView: FC<{}> = props =>
|
||||
{
|
||||
const { objectId = -1, color = '0', text = '', canModify = false, updateColor = null, updateText = null, trash = null, onClose = null } = useFurnitureStickieWidget();
|
||||
const { objectId = -1, color = '0', text = '', type = '', canModify = false, updateColor = null, updateText = null, trash = null, onClose = null } = useFurnitureStickieWidget();
|
||||
const [ isEditing, setIsEditing ] = useState(false);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setIsEditing(false);
|
||||
}, [ objectId, color, text ]);
|
||||
}, [ objectId, color, text, type ]);
|
||||
|
||||
if(objectId === -1) return null;
|
||||
|
||||
return (
|
||||
<DraggableWindow handleSelector=".drag-handler" windowPosition={ DraggableWindowPosition.TOP_LEFT }>
|
||||
<div className={ 'nitro-stickie nitro-stickie-image stickie-' + getStickieColorName(color) }>
|
||||
<div className={ 'nitro-stickie nitro-stickie-image stickie-' + (type == 'post_it' ? getStickieColorName(color) : getStickieTypeName(type)) }>
|
||||
<div className="d-flex align-items-center stickie-header drag-handler">
|
||||
<div className="d-flex align-items-center flex-grow-1 h-100">
|
||||
{ canModify &&
|
||||
<>
|
||||
<div className="nitro-stickie-image stickie-trash header-trash" onClick={ trash }></div>
|
||||
{ type == 'post_it' &&
|
||||
<>
|
||||
{ STICKIE_COLORS.map(color =>
|
||||
{
|
||||
return <div key={ color } className="stickie-color ms-1" onClick={ event => updateColor(color) } style={ { backgroundColor: ColorUtils.makeColorHex(color) } } />
|
||||
}) }
|
||||
</> }
|
||||
</> }
|
||||
</div>
|
||||
<div className="d-flex align-items-center nitro-stickie-image stickie-close header-close" onClick={ onClose }></div>
|
||||
</div>
|
||||
|
@ -161,6 +161,26 @@
|
||||
background-position: -2px -184px;
|
||||
}
|
||||
|
||||
&.stickie-christmas {
|
||||
background-image: url("../../../../assets/images/room-widgets/stickie-widget/stickie-christmas.png");
|
||||
}
|
||||
|
||||
&.stickie-shakesp {
|
||||
background-image: url("../../../../assets/images/room-widgets/stickie-widget/stickie-shakesp.png");
|
||||
}
|
||||
|
||||
&.stickie-dreams {
|
||||
background-image: url("../../../../assets/images/room-widgets/stickie-widget/stickie-dreams.png");
|
||||
}
|
||||
|
||||
&.stickie-heart {
|
||||
background-image: url("../../../../assets/images/room-widgets/stickie-widget/stickie-heart.png");
|
||||
}
|
||||
|
||||
&.stickie-juninas {
|
||||
background-image: url("../../../../assets/images/room-widgets/stickie-widget/stickie-juninas.png");
|
||||
}
|
||||
|
||||
&.stickie-close {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
|
@ -10,6 +10,7 @@ const useFurnitureStickieWidgetState = () =>
|
||||
const [ category, setCategory ] = useState(-1);
|
||||
const [ color, setColor ] = useState('0');
|
||||
const [ text, setText ] = useState('');
|
||||
const [ type, setType ] = useState('');
|
||||
const [ canModify, setCanModify ] = useState(false);
|
||||
|
||||
const onClose = () =>
|
||||
@ -18,6 +19,7 @@ const useFurnitureStickieWidgetState = () =>
|
||||
setCategory(-1);
|
||||
setColor('0');
|
||||
setText('');
|
||||
setType('');
|
||||
setCanModify(false);
|
||||
}
|
||||
|
||||
@ -66,6 +68,7 @@ const useFurnitureStickieWidgetState = () =>
|
||||
setCategory(event.category);
|
||||
setColor(color || '0');
|
||||
setText(text || '');
|
||||
setType(roomObject.type || 'post_it');
|
||||
setCanModify(GetRoomSession().isRoomOwner || GetSessionDataManager().isModerator || IsOwnerOfFurniture(roomObject));
|
||||
});
|
||||
|
||||
@ -76,7 +79,7 @@ const useFurnitureStickieWidgetState = () =>
|
||||
onClose();
|
||||
});
|
||||
|
||||
return { objectId, color, text, canModify, updateColor, updateText, trash, onClose };
|
||||
return { objectId, color, text, type, canModify, updateColor, updateText, trash, onClose };
|
||||
}
|
||||
|
||||
export const useFurnitureStickieWidget = useFurnitureStickieWidgetState;
|
||||
|
Loading…
Reference in New Issue
Block a user