From b4db34051195bd8ea40ea3e4f0e8fb5b37d07f16 Mon Sep 17 00:00:00 2001 From: Michael Fix Date: Tue, 19 May 2020 21:07:02 -0700 Subject: [PATCH] implement underline text as error (#1015) --- components/Carbon.js | 12 ++++++++++-- components/SelectionEditor.js | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/components/Carbon.js b/components/Carbon.js index 5b82e4c..d9b1ac1 100644 --- a/components/Carbon.js +++ b/components/Carbon.js @@ -34,6 +34,15 @@ function searchLanguage(l) { } function noop() {} +function getUnderline(underline) { + switch (underline) { + case 1: + return 'underline' + case 2: + return `${COLORS.RED} wavy underline; text-decoration-skip-ink: none` + } + return 'initial' +} class Carbon extends React.PureComponent { static defaultProps = { @@ -115,8 +124,7 @@ class Carbon extends React.PureComponent { const css = [ changes.bold != null && `font-weight: ${changes.bold ? 'bold' : 'initial'}`, changes.italics != null && `font-style: ${changes.italics ? 'italic' : 'initial'}`, - changes.underline != null && - `text-decoration: ${changes.underline ? 'underline' : 'initial'}`, + changes.underline != null && `text-decoration: ${getUnderline(changes.underline)}`, changes.color != null && `color: ${changes.color} !important`, ] .filter(Boolean) diff --git a/components/SelectionEditor.js b/components/SelectionEditor.js index 0781f0d..ca16f72 100644 --- a/components/SelectionEditor.js +++ b/components/SelectionEditor.js @@ -37,7 +37,7 @@ function reducer(state, action) { case 'UNDERLINE': { return { ...state, - underline: !state.underline, + underline: Number(state.underline + 1) % 3, } } case 'COLOR': {