From 976740dc8b84c96c10a5232c250daf704c446324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Sun, 20 Oct 2024 22:21:07 +0200 Subject: [PATCH] make more concise --- .../brewRenderer/errorBar/errorBar.jsx | 81 ++++++------------- 1 file changed, 25 insertions(+), 56 deletions(-) diff --git a/client/homebrew/brewRenderer/errorBar/errorBar.jsx b/client/homebrew/brewRenderer/errorBar/errorBar.jsx index 0b030c668..e951e4aaa 100644 --- a/client/homebrew/brewRenderer/errorBar/errorBar.jsx +++ b/client/homebrew/brewRenderer/errorBar/errorBar.jsx @@ -7,67 +7,36 @@ import Dialog from '../../../components/dialog.jsx'; const DISMISS_BUTTON = ; -const ErrorBar = ( props ) => { - let hasOpenError = false; - let hasCloseError = false; - let hasMatchError = false; +const ErrorBar = (props) => { + let hasOpenError = false, hasCloseError = false, hasMatchError = false; - const renderErrors = () => { - hasOpenError = false; - hasCloseError = false; - hasMatchError = false; + const renderErrors = () => ( + + ); - const errors = _.map(props.errors, (err, idx) => { - if (err.id === 'OPEN') hasOpenError = true; - if (err.id === 'CLOSE') hasCloseError = true; - if (err.id === 'MISMATCH') hasMatchError = true; - - return ( -
  • - Line {err.line} : {err.text}, '{err.type}' tag -
  • - ); - }); - - return ; - }; - - const renderProtip = () => { - const msg = []; - if (hasOpenError) { - msg.push( -
    - An unmatched opening tag means there's an opened tag that isn't closed. You need to close your tags, like this {'
    '}. Make sure to match types! - - ); - } - - if (hasCloseError) { - msg.push( -
    - An unmatched closing tag means you closed a tag without opening it. Either remove it, or check to where you think you opened it. -
    - ); - } - - if (hasMatchError) { - msg.push( -
    - A type mismatch means you closed a tag, but the last open tag was a different type. -
    - ); - } - - return ( -
    -

    Protips!

    - {msg} -
    - ); - }; + const renderProtip = () => ( +
    +

    Protips!

    + {hasOpenError &&
    Unmatched opening tag. Close your tags, like this {'
    '}. Match types!
    } + {hasCloseError &&
    Unmatched closing tag. Either remove it or check where it was opened.
    } + {hasMatchError &&
    Type mismatch. Closed a tag with a different type.
    } + + ); if (!props.errors.length) return null; + return (