From c40ab4f7036079d598451214da66b0e92b74a620 Mon Sep 17 00:00:00 2001 From: Bash Elliott Date: Fri, 20 Jan 2023 11:21:15 +1100 Subject: [PATCH] Added stroke colours. --- src/App.jsx | 24 ++++++++++++++++++------ src/bubble-input.jsx | 4 ++-- src/bubble.jsx | 4 ++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 3ca0f4e..c286d8c 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -11,7 +11,8 @@ import React from 'react' function App() { const [messages, addMessage] = useMessages([]) const [newMessage, setNewMessage] = useState('') - const [colour, setColour] = useState('#f00') + const [fillColour, setFillColour] = useState('#eee') + const [strokeColour, setStrokeColour] = useState('#000') const handleSubmit = useCallback( bubbleHeight => { @@ -27,8 +28,13 @@ function App() { [newMessage, messages] ) - const handleColourChange = (color) => { - setColour(color.hex); + const handleFillColourChange = (color) => { + setFillColour(color.hex); + console.log(color); + }; + + const handleStrokeColourChange = (color) => { + setStrokeColour(color.hex); console.log(color); }; @@ -40,7 +46,7 @@ function App() { {messages.map(m => ( - + {m.text} ))} @@ -49,11 +55,17 @@ function App() { value={newMessage} onChange={setNewMessage} onSubmit={handleSubmit} - colourClass={colour} + fillColour={fillColour} + strokeColour={strokeColour} /> - +
+

Fill

+ +

Stroke

+ +
) } diff --git a/src/bubble-input.jsx b/src/bubble-input.jsx index baa1d83..ee8fd21 100644 --- a/src/bubble-input.jsx +++ b/src/bubble-input.jsx @@ -1,7 +1,7 @@ import React, { useCallback, useState, useRef, useEffect } from 'react' import './bubble-input.css' -const BubbleInput = ({ onChange, onSubmit, value, colourClass }) => { +const BubbleInput = ({ onChange, onSubmit, value, fillColour, strokeColour }) => { const refEditable = useRef() const refContainer = useRef() const [submitted, setSubmitted] = useState(false) @@ -42,7 +42,7 @@ const BubbleInput = ({ onChange, onSubmit, value, colourClass }) => { ref={refEditable} className="bubble-content" contentEditable - style={{backgroundColor: colourClass}} + style={{backgroundColor: fillColour, color: strokeColour}} spellCheck="false" onBlur={handleBlur} onKeyDown={handleKeyDown} diff --git a/src/bubble.jsx b/src/bubble.jsx index df357d3..efdfa5c 100644 --- a/src/bubble.jsx +++ b/src/bubble.jsx @@ -11,7 +11,7 @@ const transition = { } } -const Bubble = ({ id, children, sender, dy, colourClass }) => { +const Bubble = ({ id, children, sender, dy, fillColour, strokeColour }) => { const [isPresent, safeToRemove] = usePresence() const animations = { @@ -32,7 +32,7 @@ const Bubble = ({ id, children, sender, dy, colourClass }) => { return ( -
{children}
+
{children}
) }