From 28b59aac6f5e86701d745d580ac054cdbb078852 Mon Sep 17 00:00:00 2001
From: Patrick Dillon
Date: Mon, 21 Sep 2020 16:36:28 -0400
Subject: [PATCH] [DXDP-1437] Update read-only checkbox and select styles
(#1727)
* [DXDP-1437] Update read-only checkbox and select styles
* Update snapshot
* Placeholder and checkbox updates
* Only apply placeholder styles if set
* No hover for disabled checkboxes
* Do not adjust readonly text for masked inputs
* Sync radio and checkbox styles
* Sync read only checkbox styles
* Remove box shadow for read-only
---
.../atoms/_simple-select/simple-select.tsx | 25 +-
.../atoms/_styled-input/styled-input.ts | 42 +-
core/components/atoms/checkbox/checkbox.tsx | 109 ++--
core/components/atoms/radio/radio.tsx | 88 ++--
core/components/atoms/select/select.story.tsx | 496 ++++++++----------
core/components/tokens/colors.ts | 302 +++++------
.../unit/__snapshots__/select.test.tsx.snap | 2 +-
7 files changed, 515 insertions(+), 549 deletions(-)
diff --git a/core/components/atoms/_simple-select/simple-select.tsx b/core/components/atoms/_simple-select/simple-select.tsx
index 4b3566986..597f75d5c 100644
--- a/core/components/atoms/_simple-select/simple-select.tsx
+++ b/core/components/atoms/_simple-select/simple-select.tsx
@@ -8,11 +8,6 @@ import { StyledInput } from "../_styled-input";
import Icon from "../icon";
import { ISelectOptions } from "../select/interfaces";
-const selectOpacity = {
- default: 1,
- disabled: 0.5
-};
-
const PLACEHOLDER_VALUE = "0";
const valueIsUndefined = (value) => value === undefined || value === null;
@@ -69,10 +64,15 @@ const SimpleSelect = ({ options, ...props }: ISimpleSelectProps) => {
return (
-
+
{(context) => (
-
+
{/* First option will be selected if there is no value passed as a prop */}
{props.placeholder && (
{option.description}
- )
+ );
}
public render() {
@@ -449,68 +419,68 @@ class CustomRendererExample extends React.Component<
defaultMenuOpen={this.props.defaultMenuOpen}
options={[
{
- label: 'One',
- description: 'This item holds the One number as 1.',
+ label: "One",
+ description: "This item holds the One number as 1.",
value: 1
},
{
- label: 'Two',
- description: 'This item holds the Two number as 2.',
+ label: "Two",
+ description: "This item holds the Two number as 2.",
value: 2
},
{
- label: 'Three',
- description: 'This item holds the Three number as 3.',
+ label: "Three",
+ description: "This item holds the Three number as 3.",
value: 3
},
{
- label: 'Four',
- description: 'This item holds the Four number as 4.',
+ label: "Four",
+ description: "This item holds the Four number as 4.",
value: 4
},
{
- label: 'Five',
- description: 'This item holds the Five number as 5.',
+ label: "Five",
+ description: "This item holds the Five number as 5.",
value: 5
},
{
- label: 'Six',
- description: 'This item holds the Six number as 6.',
+ label: "Six",
+ description: "This item holds the Six number as 6.",
value: 6
},
{
- label: 'Seven',
- description: 'This item holds the Seven number as 7.',
+ label: "Seven",
+ description: "This item holds the Seven number as 7.",
value: 7
},
{
- label: 'Eight',
- description: 'This item holds the Eight number as 8.',
+ label: "Eight",
+ description: "This item holds the Eight number as 8.",
value: 8
},
{
- label: 'Nine',
- description: 'This item holds the Nine number as 9.',
+ label: "Nine",
+ description: "This item holds the Nine number as 9.",
value: 9
},
{
- label: 'Ten',
- description: 'This item holds the Ten number as 10.',
+ label: "Ten",
+ description: "This item holds the Ten number as 10.",
value: 10
}
]}
/>
- )
+ );
}
}
-storiesOf('Select', module).add('custom renderer', () => (
+storiesOf("Select", module).add("custom renderer", () => (
-))
+));
-storiesOf('Select', module).add('custom value renderer', () => (
+storiesOf("Select", module).add("custom value renderer", () => (
-))
+));
-storiesOf('Select', module).add('interactive: custom value renderer', () => (
+storiesOf("Select", module).add("interactive: custom value renderer", () => (
{(value, onChange) => (
@@ -563,123 +533,123 @@ storiesOf('Select', module).add('interactive: custom value renderer', () => (
)}
options={[
{
- value: 'Harry Kane',
- text: 'Harry Kane',
- country: 'π¬π§'
+ value: "Harry Kane",
+ text: "Harry Kane",
+ country: "π¬π§"
},
{
- value: 'Lionel Messi',
- text: 'Lionel Messi',
- country: 'π¦π·'
+ value: "Lionel Messi",
+ text: "Lionel Messi",
+ country: "π¦π·"
},
{
- value: 'Antoine Griezmann',
- text: 'Antoine Griezmann',
- country: 'π«π·'
+ value: "Antoine Griezmann",
+ text: "Antoine Griezmann",
+ country: "π«π·"
},
{
- value: 'Luis Suarez',
- text: 'Luis Suarez',
- country: 'πΊπΎ'
+ value: "Luis Suarez",
+ text: "Luis Suarez",
+ country: "πΊπΎ"
}
]}
/>
)}
-))
+));
-storiesOf('Select', module).add('custom renderer in dialog', () => (
+storiesOf("Select", module).add("custom renderer in dialog", () => (
-))
+));
-type AsyncExampleItems = Array<{ label: string; description: string; value: number }>
+type AsyncExampleItems = Array<{ label: string; description: string; value: number }>;
class AsyncExample extends React.Component<{}, { selectedItems: AsyncExampleItems }> {
- public allOptions: AsyncExampleItems
+ public allOptions: AsyncExampleItems;
constructor(props) {
- super(props)
+ super(props);
- this.state = { selectedItems: [] }
+ this.state = { selectedItems: [] };
this.allOptions = [
{
- label: 'One',
- description: 'This item holds the One number as 1.',
+ label: "One",
+ description: "This item holds the One number as 1.",
value: 1
},
{
- label: 'Two',
- description: 'This item holds the Two number as 2.',
+ label: "Two",
+ description: "This item holds the Two number as 2.",
value: 2
},
{
- label: 'Three',
- description: 'This item holds the Three number as 3.',
+ label: "Three",
+ description: "This item holds the Three number as 3.",
value: 3
},
{
- label: 'Four',
- description: 'This item holds the Four number as 4.',
+ label: "Four",
+ description: "This item holds the Four number as 4.",
value: 4
},
{
- label: 'Five',
- description: 'This item holds the Five number as 5.',
+ label: "Five",
+ description: "This item holds the Five number as 5.",
value: 5
},
{
- label: 'Six',
- description: 'This item holds the Six number as 6.',
+ label: "Six",
+ description: "This item holds the Six number as 6.",
value: 6
},
{
- label: 'Seven',
- description: 'This item holds the Seven number as 7.',
+ label: "Seven",
+ description: "This item holds the Seven number as 7.",
value: 7
},
{
- label: 'Eight',
- description: 'This item holds the Eight number as 8.',
+ label: "Eight",
+ description: "This item holds the Eight number as 8.",
value: 8
},
{
- label: 'Nine',
- description: 'This item holds the Nine number as 9.',
+ label: "Nine",
+ description: "This item holds the Nine number as 9.",
value: 9
},
{
- label: 'Ten',
- description: 'This item holds the Ten number as 10.',
+ label: "Ten",
+ description: "This item holds the Ten number as 10.",
value: 10
}
- ]
+ ];
- this.loadOptions = this.loadOptions.bind(this)
- this.noOptionsMessage = this.noOptionsMessage.bind(this)
+ this.loadOptions = this.loadOptions.bind(this);
+ this.noOptionsMessage = this.noOptionsMessage.bind(this);
}
public handleChange(event) {
- const selectedItems = event.target.value
- console.log({ selectedItems })
- this.setState({ selectedItems })
+ const selectedItems = event.target.value;
+ console.log({ selectedItems });
+ this.setState({ selectedItems });
}
public filterOptions(value) {
- return this.allOptions.filter((item) => item.label.toLowerCase().includes(value.toLowerCase()))
+ return this.allOptions.filter((item) => item.label.toLowerCase().includes(value.toLowerCase()));
}
public loadOptions(inputValue, callback) {
setTimeout(() => {
- callback(this.filterOptions(inputValue))
- }, 500)
+ callback(this.filterOptions(inputValue));
+ }, 500);
}
public noOptionsMessage({ inputValue }) {
- return inputValue.length > 0 ? 'No options' : 'Type to search...'
+ return inputValue.length > 0 ? "No options" : "Type to search...";
}
public render() {
@@ -692,17 +662,17 @@ class AsyncExample extends React.Component<{}, { selectedItems: AsyncExampleItem
noOptionsMessage={this.noOptionsMessage}
loadOptions={this.loadOptions}
/>
- )
+ );
}
}
-storiesOf('Select', module).add('async select', () => (
+storiesOf("Select", module).add("async select", () => (
-))
+));
-storiesOf('Select', module).add('disabled options', () => (
+storiesOf("Select", module).add("disabled options", () => (
-))
+));
diff --git a/core/components/tokens/colors.ts b/core/components/tokens/colors.ts
index e67336180..3589b2a30 100644
--- a/core/components/tokens/colors.ts
+++ b/core/components/tokens/colors.ts
@@ -1,207 +1,207 @@
const colors = {
base: {
- white: '#FFF',
- black: '#000',
- default: '#333',
- gray: '#979797',
- grayDarkest: '#676767',
- grayDark: '#636363',
- grayMedium: '#A8A8A8',
- grayLight: '#D9D9D9',
- grayLightest: '#F1F1F1',
- blueDarker: '#097093',
- blue: '#0a84ae',
- blueLight: '#44c7f4',
- blueLightest: '#f5f7f9',
- orange: '#eb5424',
- orangeLighter: '#ff784d',
- orangeLightest: '#ffb299',
- orangeDark: '#FF3E00',
- greenDarker: '#3F6910',
- green: '#4CD964',
- red: '#FF0000',
- redDarker: '#801F00',
- yellow: '#786600',
+ white: "#FFF",
+ black: "#000",
+ default: "#333",
+ gray: "#979797",
+ grayDarkest: "#676767",
+ grayDark: "#636363",
+ grayMedium: "#A8A8A8",
+ grayLight: "#D9D9D9",
+ grayLightest: "#F1F1F1",
+ blueDarker: "#097093",
+ blue: "#0a84ae",
+ blueLight: "#44c7f4",
+ blueLightest: "#f5f7f9",
+ orange: "#eb5424",
+ orangeLighter: "#ff784d",
+ orangeLightest: "#ffb299",
+ orangeDark: "#FF3E00",
+ greenDarker: "#3F6910",
+ green: "#4CD964",
+ red: "#FF0000",
+ redDarker: "#801F00",
+ yellow: "#786600",
text: undefined // TODO: Review with Fer
},
text: {
- default: '#212121',
- inputs: '#555',
- secondary: '#757575',
- subtle: '#BDBDBD',
- error: '#FF0000'
+ default: "#212121",
+ inputs: "#555",
+ secondary: "#757575",
+ subtle: "#BDBDBD",
+ error: "#FF0000"
},
form: {
- title: '#000',
- divider: 'rgba(151,151,151,0.29)',
- background: '#f9f9f9'
+ title: "#000",
+ divider: "rgba(151,151,151,0.29)",
+ background: "#f9f9f9"
},
input: {
- background: '#FFF',
- backgroundReadOnly: '#F3F4F4',
- border: '#CCCCCC',
- borderHover: '#B7B7B7',
- borderFocus: '#0a84ae',
- borderError: '#FF0000',
- icon: '#A2A2A2',
- text: '#333',
- placeholder: '#B2B2B2',
- placeholderDisabled: '#C1C1C1',
- placeholderReadOnly: '#333',
- label: '#333',
- labelDisabled: '#C6C6C6'
+ background: "#FFF",
+ backgroundReadOnly: "#F3F4F4",
+ border: "#CCCCCC",
+ borderHover: "#B7B7B7",
+ borderFocus: "#0a84ae",
+ borderError: "#FF0000",
+ icon: "#A2A2A2",
+ text: "#333",
+ placeholder: "#B2B2B2",
+ placeholderDisabled: "#C1C1C1",
+ placeholderReadOnly: "#A8A8A8",
+ label: "#333",
+ labelDisabled: "#C6C6C6"
},
link: {
- default: '#0a84ae',
- defaultHover: '#053b4e',
- defaultFocus: '#053b4e',
- sidebar: '#333',
- sidebarHover: '#FF3E00',
- sidebarFocus: '#FF3E00'
+ default: "#0a84ae",
+ defaultHover: "#053b4e",
+ defaultFocus: "#053b4e",
+ sidebar: "#333",
+ sidebarHover: "#FF3E00",
+ sidebarFocus: "#FF3E00"
},
tooltip: {
- background: '#1A1A1A',
- text: '#FFF'
+ background: "#1A1A1A",
+ text: "#FFF"
},
tabs: {
- default: '#212121',
- defaultHover: '#0a84ae'
+ default: "#212121",
+ defaultHover: "#0a84ae"
},
button: {
default: {
- background: '#F1F1F1',
- backgroundHover: '#E9E8E8',
- backgroundFocus: '#E9E8E8',
- backgroundActive: '#DADADA',
- text: '#333',
- icon: 'default',
- border: '#F1F1F1',
- borderHover: '#E9E8E8',
- borderFocus: '#E9E8E8',
- borderActive: '#DADADA'
+ background: "#F1F1F1",
+ backgroundHover: "#E9E8E8",
+ backgroundFocus: "#E9E8E8",
+ backgroundActive: "#DADADA",
+ text: "#333",
+ icon: "default",
+ border: "#F1F1F1",
+ borderHover: "#E9E8E8",
+ borderFocus: "#E9E8E8",
+ borderActive: "#DADADA"
},
primary: {
- background: '#44C7F4',
- backgroundHover: '#13B7ED',
- backgroundFocus: '#13B7ED',
- backgroundActive: '#11A7D9',
- text: '#FAFAFA',
- icon: 'white',
- border: '#44C7F4',
- borderHover: '#13B7ED',
- borderFocus: '#13B7ED',
- borderActive: '#11A7D9'
+ background: "#44C7F4",
+ backgroundHover: "#13B7ED",
+ backgroundFocus: "#13B7ED",
+ backgroundActive: "#11A7D9",
+ text: "#FAFAFA",
+ icon: "white",
+ border: "#44C7F4",
+ borderHover: "#13B7ED",
+ borderFocus: "#13B7ED",
+ borderActive: "#11A7D9"
},
secondary: {
- background: 'transparent',
- backgroundHover: 'rgba(0,0,0,0.05)',
- backgroundFocus: 'rgba(0,0,0,0.05)',
- backgroundActive: '#DADADA',
- text: '#333',
- icon: 'default',
- border: '#D0D2D3',
- borderHover: '#B5B7B8',
- borderFocus: '#B5B7B8',
- borderActive: '#DADADA'
+ background: "transparent",
+ backgroundHover: "rgba(0,0,0,0.05)",
+ backgroundFocus: "rgba(0,0,0,0.05)",
+ backgroundActive: "#DADADA",
+ text: "#333",
+ icon: "default",
+ border: "#D0D2D3",
+ borderHover: "#B5B7B8",
+ borderFocus: "#B5B7B8",
+ borderActive: "#DADADA"
},
cta: {
- background: '#EB5424',
- backgroundHover: '#D94514',
- backgroundFocus: '#D94514',
- backgroundActive: '#BF3A11',
- text: '#FAFAFA',
- icon: 'white',
- border: '#EB5424',
- borderHover: '#D94514',
- borderFocus: '#D94514',
- borderActive: '#BF3A11'
+ background: "#EB5424",
+ backgroundHover: "#D94514",
+ backgroundFocus: "#D94514",
+ backgroundActive: "#BF3A11",
+ text: "#FAFAFA",
+ icon: "white",
+ border: "#EB5424",
+ borderHover: "#D94514",
+ borderFocus: "#D94514",
+ borderActive: "#BF3A11"
},
destructive: {
- background: '#FF0000',
- backgroundHover: '#E40002',
- backgroundFocus: '#E40002',
- backgroundActive: '#BE0001',
- text: '#FAFAFA',
- icon: 'white',
- border: '#FF0000',
- borderHover: '#E40002',
- borderFocus: '#E40002',
- borderActive: '#BE0001'
+ background: "#FF0000",
+ backgroundHover: "#E40002",
+ backgroundFocus: "#E40002",
+ backgroundActive: "#BE0001",
+ text: "#FAFAFA",
+ icon: "white",
+ border: "#FF0000",
+ borderHover: "#E40002",
+ borderFocus: "#E40002",
+ borderActive: "#BE0001"
},
success: {
- background: '#4CD964',
- backgroundHover: '#4CD964',
- backgroundFocus: '#4CD964',
- text: '#FAFAFA',
- icon: 'white',
- border: '#4CD964',
- borderHover: '#4CD964',
- borderFocus: '#4CD964',
- borderActive: '#4CD964',
+ background: "#4CD964",
+ backgroundHover: "#4CD964",
+ backgroundFocus: "#4CD964",
+ text: "#FAFAFA",
+ icon: "white",
+ border: "#4CD964",
+ borderHover: "#4CD964",
+ borderFocus: "#4CD964",
+ borderActive: "#4CD964",
backgroundActive: undefined // TODO: Review with Fer
},
link: {
- text: '#0a84ae',
- icon: 'blue',
- hover: '#0a84ae',
- focus: '#0a84ae'
+ text: "#0a84ae",
+ icon: "blue",
+ hover: "#0a84ae",
+ focus: "#0a84ae"
}
},
icon: {
- default: '#333',
- light: '#A8A8A8',
- sidebar: 'default',
- sidebarHover: 'orangeDark',
- sidebarFocus: 'orangeDark'
+ default: "#333",
+ light: "#A8A8A8",
+ sidebar: "default",
+ sidebarHover: "orangeDark",
+ sidebarFocus: "orangeDark"
},
list: {
- backgroundHover: '#FAFAFA',
- borderColor: '#DDD'
+ backgroundHover: "#FAFAFA",
+ borderColor: "#DDD"
},
alert: {
default: {
- background: '#F0F0F0',
- text: '#333'
+ background: "#F0F0F0",
+ text: "#333"
},
information: {
- background: '#DBF4FC',
- text: '#097093'
+ background: "#DBF4FC",
+ text: "#097093"
},
success: {
- background: '#E5F8D1',
- text: '#3F6910'
+ background: "#E5F8D1",
+ text: "#3F6910"
},
warning: {
- background: '#FFF6CB',
- text: '#786600'
+ background: "#FFF6CB",
+ text: "#786600"
},
danger: {
- background: '#FFD8CC',
- text: '#801F00'
+ background: "#FFD8CC",
+ text: "#801F00"
}
},
radio: {
- background: '#FFF',
- border: '#BEBEBE',
- backgroundSelected: '#3B99FC',
- borderSelected: '#2C90FC',
- backgroundDisabled: '#F6F6F6',
- borderDisabled: '#CCC',
- shadow: 'rgba(0,0,0,0.20)',
- shadowDisabled: 'rgba(0,0,0,0.10)'
+ background: "#FFF",
+ border: "#BEBEBE",
+ backgroundSelected: "#3B99FC",
+ borderSelected: "#2C90FC",
+ backgroundDisabled: "#F6F6F6",
+ borderDisabled: "#CCC",
+ shadow: "rgba(0,0,0,0.20)",
+ shadowDisabled: "rgba(0,0,0,0.10)"
},
status: {
- default: '#7D7D7D',
- information: '#3BC0F2',
- success: '#73CD1F',
- warning: '#F49C20',
- danger: '#D14B49'
+ default: "#7D7D7D",
+ information: "#3BC0F2",
+ success: "#73CD1F",
+ warning: "#F49C20",
+ danger: "#D14B49"
},
tag: {
- background: '#DBF4FD',
- border: '#3BC0F2',
- text: '#3BC0F2'
+ background: "#DBF4FD",
+ border: "#3BC0F2",
+ text: "#3BC0F2"
}
-}
+};
-export default colors
+export default colors;
diff --git a/internal/test/unit/__snapshots__/select.test.tsx.snap b/internal/test/unit/__snapshots__/select.test.tsx.snap
index 6e3c7ee9e..5e7fc1791 100644
--- a/internal/test/unit/__snapshots__/select.test.tsx.snap
+++ b/internal/test/unit/__snapshots__/select.test.tsx.snap
@@ -282,7 +282,7 @@ exports[`Select simple variant renders SimpleSelect 1`] = `