From 1a73735e7f37f48910e2f6e43225b07f55922133 Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Tue, 20 Sep 2022 13:52:52 -0700 Subject: [PATCH 1/4] Update EuiCheckbox ahead of time to accept custom `css` This adds an unused Emotion className, but I wanted to ensure 1. The css merging approach is in place and not forgotten when converted to EUI (since ...rest) is not passed to the className wrapper 2. the test is in place and not forgetten when it's converted to Emotion --- .../checkbox/__snapshots__/checkbox.test.tsx.snap | 12 ++++++------ src/components/form/checkbox/checkbox.test.tsx | 10 ++++++++++ src/components/form/checkbox/checkbox.tsx | 7 ++++++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/components/form/checkbox/__snapshots__/checkbox.test.tsx.snap b/src/components/form/checkbox/__snapshots__/checkbox.test.tsx.snap index 23677fab670..7fdb5b8be70 100644 --- a/src/components/form/checkbox/__snapshots__/checkbox.test.tsx.snap +++ b/src/components/form/checkbox/__snapshots__/checkbox.test.tsx.snap @@ -2,7 +2,7 @@ exports[`EuiCheckbox is rendered 1`] = `
{ + shouldRenderCustomStyles( + , + { skipStyles: true } // styles get applied to the nested input, not to the className wrapper + ); + shouldRenderCustomStyles( + , + { childProps: ['labelProps'], skipParentTest: true } + ); + test('is rendered', () => { const component = render( {}} {...requiredProps} /> diff --git a/src/components/form/checkbox/checkbox.tsx b/src/components/form/checkbox/checkbox.tsx index 8ef768b4895..b678e749a0d 100644 --- a/src/components/form/checkbox/checkbox.tsx +++ b/src/components/form/checkbox/checkbox.tsx @@ -13,6 +13,7 @@ import React, { InputHTMLAttributes, LabelHTMLAttributes, } from 'react'; +import { css } from '@emotion/react'; import classNames from 'classnames'; import { keysOf, CommonProps } from '../../common'; @@ -67,6 +68,7 @@ export class EuiCheckbox extends Component { render() { const { className, + css: customCss, id, checked, label, @@ -103,8 +105,11 @@ export class EuiCheckbox extends Component { ); } + const styles = { euiCheckbox: css`` }; // TODO: Emotion conversion + const cssStyles = [styles.euiCheckbox, customCss]; + return ( -
+
Date: Tue, 20 Sep 2022 13:53:28 -0700 Subject: [PATCH 2/4] Update downstream checkbox snapshots --- .../__snapshots__/basic_table.test.tsx.snap | 10 +++++----- .../__snapshots__/checkable_card.test.tsx.snap | 2 +- .../__snapshots__/key_pad_menu_item.test.tsx.snap | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/basic_table/__snapshots__/basic_table.test.tsx.snap b/src/components/basic_table/__snapshots__/basic_table.test.tsx.snap index 60967358d11..8256fdeda7a 100644 --- a/src/components/basic_table/__snapshots__/basic_table.test.tsx.snap +++ b/src/components/basic_table/__snapshots__/basic_table.test.tsx.snap @@ -1418,7 +1418,7 @@ exports[`EuiBasicTable with initial selection 1`] = ` class="euiFlexItem euiFlexItem--flexGrowZero" >
Date: Tue, 20 Sep 2022 13:55:32 -0700 Subject: [PATCH 3/4] Update EuiSwitch ahead of time to accept custom `css` See previous commit message for EuiCheckbox --- .../controls/__snapshots__/column_selector.test.tsx.snap | 4 ++-- .../form/switch/__snapshots__/switch.test.tsx.snap | 6 +++--- src/components/form/switch/switch.test.tsx | 9 +++++++++ src/components/form/switch/switch.tsx | 7 ++++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/components/datagrid/controls/__snapshots__/column_selector.test.tsx.snap b/src/components/datagrid/controls/__snapshots__/column_selector.test.tsx.snap index f37f6eddd43..118b0dab81f 100644 --- a/src/components/datagrid/controls/__snapshots__/column_selector.test.tsx.snap +++ b/src/components/datagrid/controls/__snapshots__/column_selector.test.tsx.snap @@ -109,7 +109,7 @@ exports[`useDataGridColumnSelector columnSelector renders a toolbar button/popov class="euiFlexItem" >