From 0cac2fec2a25ef44a83898cabcf78da536bef24c Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Thu, 4 Feb 2021 10:36:46 -0800 Subject: [PATCH] feat(web): add button types --- web/src/StyleGuide.jsx | 24 ++++++++++++++++++++++++ web/src/components/Button.jsx | 23 +++++++++++++++-------- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/web/src/StyleGuide.jsx b/web/src/StyleGuide.jsx index 0e93eef70..8f2235ef4 100644 --- a/web/src/StyleGuide.jsx +++ b/web/src/StyleGuide.jsx @@ -28,6 +28,30 @@ export default function StyleGuide() { +
+ + + + +
+
+ + + + +
Switch
diff --git a/web/src/components/Button.jsx b/web/src/components/Button.jsx index f72941e91..f1b42fd06 100644 --- a/web/src/components/Button.jsx +++ b/web/src/components/Button.jsx @@ -5,24 +5,31 @@ const noop = () => {}; const ButtonColors = { blue: { contained: 'bg-blue-500 focus:bg-blue-400 active:bg-blue-600 ring-blue-300', - outlined: '', + outlined: + 'text-blue-500 border-2 border-blue-500 hover:bg-blue-500 hover:bg-opacity-20 focus:bg-blue-500 focus:bg-opacity-40 active:bg-blue-500 active:bg-opacity-40', text: 'text-blue-500 hover:bg-blue-500 hover:bg-opacity-20 focus:bg-blue-500 focus:bg-opacity-40 active:bg-blue-500 active:bg-opacity-40', }, red: { contained: 'bg-red-500 focus:bg-red-400 active:bg-red-600 ring-red-300', - outlined: '', - text: '', + outlined: + 'text-red-500 border-2 border-red-500 hover:bg-red-500 hover:bg-opacity-20 focus:bg-red-500 focus:bg-opacity-40 active:bg-red-500 active:bg-opacity-40', + text: + 'text-red-500 hover:bg-red-500 hover:bg-opacity-20 focus:bg-red-500 focus:bg-opacity-40 active:bg-red-500 active:bg-opacity-40', }, green: { contained: 'bg-green-500 focus:bg-green-400 active:bg-green-600 ring-green-300', - outlined: '', - text: '', + outlined: + 'text-green-500 border-2 border-green-500 hover:bg-green-500 hover:bg-opacity-20 focus:bg-green-500 focus:bg-opacity-40 active:bg-green-500 active:bg-opacity-40', + text: + 'text-green-500 hover:bg-green-500 hover:bg-opacity-20 focus:bg-green-500 focus:bg-opacity-40 active:bg-green-500 active:bg-opacity-40', }, disabled: { contained: 'bg-gray-400', - outlined: '', - text: '', + outlined: + 'text-gray-500 border-2 border-gray-500 hover:bg-gray-500 hover:bg-opacity-20 focus:bg-gray-500 focus:bg-opacity-40 active:bg-gray-500 active:bg-opacity-40', + text: + 'text-gray-500 hover:bg-gray-500 hover:bg-opacity-20 focus:bg-gray-500 focus:bg-opacity-40 active:bg-gray-500 active:bg-opacity-40', }, black: { contained: '', @@ -48,7 +55,7 @@ export default function Button({ type = 'contained', ...attrs }) { - let classes = `${className} ${ + let classes = `${className} ${ButtonTypes[type]} ${ ButtonColors[disabled ? 'disabled' : color][type] } font-sans inline-flex font-bold uppercase text-xs px-2 py-2 rounded outline-none focus:outline-none ring-opacity-50 transition-shadow transition-colors ${ disabled ? 'cursor-not-allowed' : 'focus:ring-2 cursor-pointer'