Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2475 from teamleadercrm/empty-state-badged-link-a…
Browse files Browse the repository at this point in the history
…ction

Add a `BadgedLink` action to `EmptyState`
  • Loading branch information
BeirlaenAaron authored Dec 6, 2022
2 parents ae792e6 + f561192 commit 3a937c4
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@

### Dependency updates

## [18.1.0] - 2022-12-05

### Added

- `EmptyState`: Add an action prop that renders a `BadgedLink` ([@BeirlaenAaron](https://github.com/BeirlaenAaron)) in ([#2475](https://github.com/teamleadercrm/ui/pull/2475))

## [18.0.0] - 2022-11-29

### Changed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@teamleader/ui",
"description": "Teamleader UI library",
"version": "18.0.0",
"version": "18.1.0",
"author": "Teamleader <[email protected]>",
"bugs": {
"url": "https://github.com/teamleadercrm/ui/issues"
Expand Down
2 changes: 1 addition & 1 deletion src/components/detailPage/DetailPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import theme from './theme.css';

export interface DetailPageHeaderProps extends Omit<ContainerProps, 'title'> {
children?: ReactNode;
backLinkProps?: Omit<BadgedLinkProps, 'icon' | 'inheric'> & { children: ReactNode };
backLinkProps?: Omit<BadgedLinkProps, 'icon' | 'inherit'> & { children: ReactNode };
title: React.ReactNode;
/** The color which the title should have */
titleColor?: 'neutral' | 'teal';
Expand Down
9 changes: 9 additions & 0 deletions src/components/emptyState/EmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import theme from './theme.css';
import { BoxProps } from '../box/Box';
import { GenericComponent } from '../../@types/types';
import { SIZES } from '../../constants';
import BadgedLink, { BadgedLinkProps } from '../badgedLink';
import { IconAddSmallOutline } from '@teamleader/ui-icons';

export interface EmptyStateProps extends Omit<BoxProps, 'size'> {
hidePointer?: boolean;
metaText?: ReactNode | string;
size?: Exclude<typeof SIZES[number], 'tiny' | 'fullscreen' | 'smallest' | 'hero'>;
title?: ReactNode | string;
action?: Omit<BadgedLinkProps, 'icon' | 'inherit'> & { children: ReactNode };
}

const illustrationMap = {
Expand All @@ -31,6 +34,7 @@ const EmptyState: GenericComponent<EmptyStateProps> = ({
hidePointer = false,
size = 'medium',
title,
action,
...others
}) => {
const classNames = cx(
Expand Down Expand Up @@ -60,6 +64,11 @@ const EmptyState: GenericComponent<EmptyStateProps> = ({
{metaText}
</TextBody>
)}
{action && (
<Box marginTop={3}>
<BadgedLink {...action} icon={<IconAddSmallOutline />} inherit={false} />
</Box>
)}
</div>
</Box>
);
Expand Down
14 changes: 13 additions & 1 deletion src/components/emptyState/emptyState.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { addStoryInGroup, MID_LEVEL_BLOCKS } from '../../../.storybook/utils';
import EmptyState from './EmptyState';
import { Marker } from '../typography';
import { Marker, TextBodyCompact } from '../typography';
import { ComponentStory, ComponentMeta } from '@storybook/react';

const title = (
Expand Down Expand Up @@ -35,3 +35,15 @@ WithTitle.args = {
'I am the meta information and I basically explain that you can start adding content via the add button above.',
title,
};

export const WithAction: ComponentStory<typeof EmptyState> = (args) => <EmptyState {...args} />;

WithAction.args = {
metaText:
'I am the meta information and I basically explain that you can start adding content via the add button above.',
title,
action: {
children: <TextBodyCompact>Start adding content</TextBodyCompact>,
onClick: () => console.log('action.onClick'),
},
};

0 comments on commit 3a937c4

Please sign in to comment.