diff --git a/packages/buttons/src/elements/Button.spec.tsx b/packages/buttons/src/elements/Button.spec.tsx index 43d436a648a..8224ac8847a 100644 --- a/packages/buttons/src/elements/Button.spec.tsx +++ b/packages/buttons/src/elements/Button.spec.tsx @@ -9,6 +9,7 @@ import React from 'react'; import { render, renderRtl } from 'garden-test-utils'; import { Button } from './Button'; import TestIcon from '@zendeskgarden/svg-icons/src/16/gear-stroke.svg'; +import { COMPONENT_ID } from '../styled/StyledButton'; describe('Button', () => { it('is rendered as a button', () => { @@ -24,6 +25,20 @@ describe('Button', () => { expect(container.firstChild).toBe(ref.current); }); + describe('`data-garden-id` attribute', () => { + it('sets a default data-garden-id attribute', () => { + const { getByRole } = render( ); const contextValue = useMemo( diff --git a/packages/dropdowns/src/views/index.ts b/packages/dropdowns/src/views/index.ts index d1cef2e9c59..e459f2e27a3 100644 --- a/packages/dropdowns/src/views/index.ts +++ b/packages/dropdowns/src/views/index.ts @@ -36,5 +36,4 @@ export * from './menu/StyledItemGroup'; export * from './menu/StyledItemIcon'; export * from './menu/StyledItemMeta'; export * from './menu/StyledItemTypeIcon'; -export * from './menu/StyledButton'; export * from './menu/StyledSeparator'; diff --git a/packages/dropdowns/src/views/menu/StyledButton.ts b/packages/dropdowns/src/views/menu/StyledButton.ts deleted file mode 100644 index e6bab89a6df..00000000000 --- a/packages/dropdowns/src/views/menu/StyledButton.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright Zendesk, Inc. - * - * Use of this source code is governed under the Apache License, Version 2.0 - * found at http://www.apache.org/licenses/LICENSE-2.0. - */ - -import styled from 'styled-components'; -import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming'; -import { Button } from '@zendeskgarden/react-buttons'; - -const COMPONENT_ID = 'dropdowns.menu.button'; - -export const StyledButton = styled(Button).attrs({ - 'data-garden-id': COMPONENT_ID, - 'data-garden-version': PACKAGE_VERSION -})` - ${props => retrieveComponentStyles(COMPONENT_ID, props)}; -`; - -StyledButton.defaultProps = { - theme: DEFAULT_THEME -}; diff --git a/packages/grid/src/elements/pane/components/SplitterButton.spec.tsx b/packages/grid/src/elements/pane/components/SplitterButton.spec.tsx index cfcf83a9764..7e8efb6a40d 100644 --- a/packages/grid/src/elements/pane/components/SplitterButton.spec.tsx +++ b/packages/grid/src/elements/pane/components/SplitterButton.spec.tsx @@ -50,4 +50,12 @@ describe('SplitterButton', () => { expect(getByLabelText('toggle a').querySelector('svg')).toBeDefined(); }); + + describe('`data-garden-id` attribute', () => { + it('has the correct `data-garden-id`', () => { + const { getByLabelText } = render(); + + expect(getByLabelText('toggle a')).toHaveAttribute('data-garden-id', 'buttons.icon_button'); + }); + }); }); diff --git a/packages/grid/src/styled/pane/StyledPaneSplitterButton.ts b/packages/grid/src/styled/pane/StyledPaneSplitterButton.ts index bb26b7d0ff3..1a8edda090d 100644 --- a/packages/grid/src/styled/pane/StyledPaneSplitterButton.ts +++ b/packages/grid/src/styled/pane/StyledPaneSplitterButton.ts @@ -6,12 +6,10 @@ */ import styled, { css, ThemeProps, DefaultTheme } from 'styled-components'; -import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming'; +import { DEFAULT_THEME } from '@zendeskgarden/react-theming'; import { ChevronButton } from '@zendeskgarden/react-buttons'; import { Orientation } from '../../types'; -const COMPONENT_ID = 'pane.splitter_button'; - interface IStyledSplitterButtonProps { orientation: Orientation; isRotated: boolean; @@ -52,7 +50,6 @@ const transformStyles = (props: IStyledSplitterButtonProps & ThemeProps({ - 'data-garden-id': COMPONENT_ID, 'data-garden-version': PACKAGE_VERSION, isBasic: true, isPill: true, @@ -61,8 +58,6 @@ export const StyledPaneSplitterButton = styled(ChevronButton).attrs retrieveComponentStyles(COMPONENT_ID, props)}; `; StyledPaneSplitterButton.defaultProps = { diff --git a/packages/notifications/src/styled/global-alert/StyledGlobalAlertButton.spec.tsx b/packages/notifications/src/styled/global-alert/StyledGlobalAlertButton.spec.tsx index 64e96e447af..3020fe9fdd3 100644 --- a/packages/notifications/src/styled/global-alert/StyledGlobalAlertButton.spec.tsx +++ b/packages/notifications/src/styled/global-alert/StyledGlobalAlertButton.spec.tsx @@ -35,4 +35,12 @@ describe('StyledGlobalAlertButton', () => { }[type] ); }); + + describe('`data-garden-id` attribute', () => { + it('has the correct `data-garden-id`', () => { + const { container } = render(); + + expect(container.firstChild).toHaveAttribute('data-garden-id', 'buttons.button'); + }); + }); }); diff --git a/packages/notifications/src/styled/global-alert/StyledGlobalAlertButton.ts b/packages/notifications/src/styled/global-alert/StyledGlobalAlertButton.ts index 11786e27bca..55c05e64c36 100644 --- a/packages/notifications/src/styled/global-alert/StyledGlobalAlertButton.ts +++ b/packages/notifications/src/styled/global-alert/StyledGlobalAlertButton.ts @@ -6,19 +6,12 @@ */ import styled, { css, ThemeProps, DefaultTheme } from 'styled-components'; -import { - getColorV8, - DEFAULT_THEME, - retrieveComponentStyles, - focusStyles -} from '@zendeskgarden/react-theming'; +import { getColorV8, DEFAULT_THEME, focusStyles } from '@zendeskgarden/react-theming'; import { Button } from '@zendeskgarden/react-buttons'; import { IGlobalAlertProps } from '../../types'; import { colorStyles as basicColorStyles } from './StyledGlobalAlertClose'; -const COMPONENT_ID = 'notifications.global-alert.button'; - interface IStyledGlobalAlertButtonProps { alertType: IGlobalAlertProps['type']; isBasic?: boolean; @@ -91,7 +84,6 @@ function sizeStyles(props: ThemeProps) { } export const StyledGlobalAlertButton = styled(Button).attrs({ - 'data-garden-id': COMPONENT_ID, 'data-garden-version': PACKAGE_VERSION, focusInset: false, isDanger: false, @@ -105,8 +97,6 @@ export const StyledGlobalAlertButton = styled(Button).attrs({ ${sizeStyles}; ${colorStyles}; - - ${props => retrieveComponentStyles(COMPONENT_ID, props)}; `; StyledGlobalAlertButton.defaultProps = { diff --git a/packages/notifications/src/styled/global-alert/StyledGlobalAlertClose.spec.tsx b/packages/notifications/src/styled/global-alert/StyledGlobalAlertClose.spec.tsx index 4aaf3e6634c..53c76887724 100644 --- a/packages/notifications/src/styled/global-alert/StyledGlobalAlertClose.spec.tsx +++ b/packages/notifications/src/styled/global-alert/StyledGlobalAlertClose.spec.tsx @@ -32,4 +32,16 @@ describe('StyledGlobalAlertClose', () => { { modifier: '&:hover' } ); }); + + describe('`data-garden-id` attribute', () => { + it('has the correct `data-garden-id`', () => { + const { container } = render( + + + + ); + + expect(container.firstChild).toHaveAttribute('data-garden-id', 'buttons.icon_button'); + }); + }); }); diff --git a/packages/notifications/src/styled/global-alert/StyledGlobalAlertClose.ts b/packages/notifications/src/styled/global-alert/StyledGlobalAlertClose.ts index 556e4bae06b..81a02d474f5 100644 --- a/packages/notifications/src/styled/global-alert/StyledGlobalAlertClose.ts +++ b/packages/notifications/src/styled/global-alert/StyledGlobalAlertClose.ts @@ -6,18 +6,11 @@ */ import styled, { css, DefaultTheme, ThemeProps } from 'styled-components'; -import { - getColorV8, - DEFAULT_THEME, - retrieveComponentStyles, - focusStyles -} from '@zendeskgarden/react-theming'; +import { getColorV8, DEFAULT_THEME, focusStyles } from '@zendeskgarden/react-theming'; import { IconButton } from '@zendeskgarden/react-buttons'; import { IGlobalAlertProps } from '../../types'; -const COMPONENT_ID = 'notifications.global-alert.close'; - interface IStyledGlobalAlertCloseProps { alertType: IGlobalAlertProps['type']; } @@ -97,14 +90,11 @@ const sizeStyles = (props: ThemeProps) => { }; export const StyledGlobalAlertClose = styled(IconButton).attrs({ - 'data-garden-id': COMPONENT_ID, 'data-garden-version': PACKAGE_VERSION, size: 'small' })` ${sizeStyles}; ${colorStyles}; - - ${props => retrieveComponentStyles(COMPONENT_ID, props)}; `; StyledGlobalAlertClose.defaultProps = {