diff --git a/CHANGELOG.md b/CHANGELOG.md index 99ecdc245..32e3f7f32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ ### Removed +- [BREAKING] `Section`: removed the component and replaced the instances with either a `Box` or a full-width `Banner` ([@farazatarodi](https://github.com/farazatarodi) in [#2558](https://github.com/teamleadercrm/ui/pull/2558)) + ### Fixed ### Dependency updates diff --git a/src/components/banner/Banner.tsx b/src/components/banner/Banner.tsx index 541f85d27..f5485f659 100644 --- a/src/components/banner/Banner.tsx +++ b/src/components/banner/Banner.tsx @@ -1,13 +1,19 @@ import React from 'react'; +import cx from 'classnames'; -import Box from '../box'; -import Island, { IslandProps } from '../island'; -import Section, { SectionProps } from '../section'; +import Box, { BoxProps, Padding } from '../box'; import IconButton from '../iconButton'; import theme from './theme.css'; import { IconCloseMediumOutline } from '@teamleader/ui-icons'; +import { COLORS, SIZES } from '../../constants'; -export interface BannerProps extends SectionProps, IslandProps { +const PADDINGS: Record<'small' | 'medium' | 'large', Padding> = { + small: 3, + medium: 4, + large: 5, +}; + +export interface BannerProps extends Omit { /** The content to display inside the banner. */ children?: React.ReactNode; /** A class name for the wrapper to give custom styles. */ @@ -18,13 +24,33 @@ export interface BannerProps extends SectionProps, IslandProps { onClose?: React.MouseEventHandler; /** If true, component will take the full width of it's container. */ fullWidth?: boolean; + /** The color for the Banner background and border */ + color?: Exclude | 'white'; + /** The size of the Banner component */ + size?: Exclude; } -const Banner = ({ children, className, color = 'white', icon, onClose, fullWidth, ...others }: BannerProps) => { - const Element = fullWidth ? Section : Island; +const Banner = ({ + children, + className, + color = 'white', + size = 'medium', + icon, + onClose, + fullWidth, + ...others +}: BannerProps) => { + const classNames = cx(className, theme[color], theme['banner'], { [theme['banner_full-width']]: fullWidth }); return ( - +
{icon && {icon}} @@ -39,7 +65,7 @@ const Banner = ({ children, className, color = 'white', icon, onClose, fullWidth /> )}
-
+ ); }; diff --git a/src/components/banner/__tests__/__snapshots__/Banner.spec.tsx.snap b/src/components/banner/__tests__/__snapshots__/Banner.spec.tsx.snap index 3a13d866f..5c9afc9f9 100644 --- a/src/components/banner/__tests__/__snapshots__/Banner.spec.tsx.snap +++ b/src/components/banner/__tests__/__snapshots__/Banner.spec.tsx.snap @@ -3,9 +3,10 @@ exports[`Component - Banner renders 1`] = `
= ({ ...others }) => { return ( - + {backLinkProps && ( diff --git a/src/components/detailPage/__tests__/__snapshots__/DetailPage.spec.tsx.snap b/src/components/detailPage/__tests__/__snapshots__/DetailPage.spec.tsx.snap index f0ce8c826..9d2042c27 100644 --- a/src/components/detailPage/__tests__/__snapshots__/DetailPage.spec.tsx.snap +++ b/src/components/detailPage/__tests__/__snapshots__/DetailPage.spec.tsx.snap @@ -6,10 +6,10 @@ exports[`Component - DetailPage renders 1`] = ` class="box" data-teamleader-ui="detail-page" > -
- +
void; + /** A class name for the wrapper to give custom styles. */ + className?: string; } -const Header: GenericComponent = ({ icon, onCloseClick, children, ...rest }) => { +const Header: GenericComponent = ({ icon, onCloseClick, children, className, ...rest }) => { + const classNames = cx(className, theme['header']); + return ( -
+ {icon && ( {icon} @@ -34,7 +49,7 @@ const Header: GenericComponent = ({ icon, onCloseClick, children, . className={theme['close-icon']} /> )} -
+ ); }; diff --git a/src/components/dialog/__tests__/Dialog.spec.tsx b/src/components/dialog/__tests__/Dialog.spec.tsx index 9cce90745..ce63cccd6 100644 --- a/src/components/dialog/__tests__/Dialog.spec.tsx +++ b/src/components/dialog/__tests__/Dialog.spec.tsx @@ -61,7 +61,7 @@ describe('Component - Dialog', () => { ); expect(handleOnClose).not.toBeCalled(); - const closeButton = screen.baseElement.querySelector('section button[type="button"]'); + const closeButton = screen.baseElement.querySelector('div button[type="button"]'); await user.click(closeButton!); expect(handleOnClose).toBeCalledTimes(1); diff --git a/src/components/dialog/__tests__/__snapshots__/Dialog.spec.tsx.snap b/src/components/dialog/__tests__/__snapshots__/Dialog.spec.tsx.snap index dbc72bc16..fb03a33a0 100644 --- a/src/components/dialog/__tests__/__snapshots__/Dialog.spec.tsx.snap +++ b/src/components/dialog/__tests__/__snapshots__/Dialog.spec.tsx.snap @@ -29,9 +29,9 @@ exports[`Component - Dialog renders 1`] = `
-
-
+
-

-

+
= { - small: 3, - medium: 4, - large: 5, -}; - -export interface SectionProps extends Omit { - children?: ReactNode; - color?: Exclude | 'white'; - size?: Exclude; -} - -const Section: GenericComponent = ({ - children, - className, - color = 'white', - size = 'medium', - ...rest -}) => { - const classNames = cx(theme['section'], className as string, theme[color]); - - return ( - - {children} - - ); -}; - -export default Section; diff --git a/src/components/section/__tests__/Section.spec.tsx b/src/components/section/__tests__/Section.spec.tsx deleted file mode 100644 index 2248110e1..000000000 --- a/src/components/section/__tests__/Section.spec.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; -import { render } from '@testing-library/react'; -import Section from '../Section'; - -describe('Component - Section', () => { - it('renders', async () => { - const { asFragment } = render(
This is a Section
); - expect(asFragment()).toMatchSnapshot(); - }); -}); diff --git a/src/components/section/__tests__/__snapshots__/Section.spec.tsx.snap b/src/components/section/__tests__/__snapshots__/Section.spec.tsx.snap deleted file mode 100644 index f9d00cdcc..000000000 --- a/src/components/section/__tests__/__snapshots__/Section.spec.tsx.snap +++ /dev/null @@ -1,12 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Component - Section renders 1`] = ` - -
- This is a Section -
-
-`; diff --git a/src/components/section/index.ts b/src/components/section/index.ts deleted file mode 100644 index ecf986b32..000000000 --- a/src/components/section/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import Section, { SectionProps } from './Section'; - -export default Section; -export type { SectionProps }; diff --git a/src/components/section/section.stories.tsx b/src/components/section/section.stories.tsx deleted file mode 100644 index 9d76747f1..000000000 --- a/src/components/section/section.stories.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react'; -import { addStoryInGroup, LOW_LEVEL_BLOCKS } from '../../../.storybook/utils'; -import { Section, TextBody } from '../../index'; -import { ComponentStory, ComponentMeta } from '@storybook/react'; - -export default { - component: Section, - title: addStoryInGroup(LOW_LEVEL_BLOCKS, 'Section'), -} as ComponentMeta; - -export const Basic: ComponentStory = (args) => ( -
- I am a section -
-); diff --git a/src/components/section/theme.css b/src/components/section/theme.css deleted file mode 100644 index bac1b9df2..000000000 --- a/src/components/section/theme.css +++ /dev/null @@ -1,48 +0,0 @@ -@import '@teamleader/ui-colors'; -@import '@teamleader/ui-utilities'; - -.section { - border-bottom: 1px solid; -} - -.white { - background-color: var(--color-white); - border-color: var(--color-neutral); - color: var(--color-teal-darkest); -} - -.neutral { - background-color: var(--color-neutral-light); - border-color: var(--color-neutral); - color: var(--color-teal-darkest); -} - -.mint { - background-color: var(--color-mint-lightest); - border-color: var(--color-mint); - color: var(--color-mint-darkest); -} - -.violet { - background-color: var(--color-violet-lightest); - border-color: var(--color-violet); - color: var(--color-violet-darkest); -} - -.ruby { - background-color: var(--color-ruby-lightest); - border-color: var(--color-ruby); - color: var(--color-ruby-darkest); -} - -.gold { - background-color: var(--color-gold-lightest); - border-color: var(--color-gold); - color: var(--color-gold-darkest); -} - -.aqua { - background-color: var(--color-aqua-lightest); - border-color: var(--color-aqua); - color: var(--color-aqua-darkest); -} diff --git a/src/index.ts b/src/index.ts index 825ed8f81..e75710806 100644 --- a/src/index.ts +++ b/src/index.ts @@ -89,7 +89,6 @@ import Popover, { PopoverProps } from './components/popover'; import PoweredByButton, { PoweredByButtonProps } from './components/poweredByButton'; import ProgressTracker, { ProgressTrackerProps } from './components/progressTracker'; import { RadioButton, RadioButtonProps, RadioGroup, RadioGroupProps } from './components/radio'; -import Section, { SectionProps } from './components/section'; import Select, { AsyncSelect, AsyncSelectProps, @@ -238,7 +237,6 @@ export { ProgressTracker, RadioButton, RadioGroup, - Section, Select, SplitButton, StatusLabel, @@ -355,7 +353,6 @@ export type { ProgressTrackerProps, RadioButtonProps, RadioGroupProps, - SectionProps, SelectComponentsProps, SelectProps, SelectRef,