Skip to content

Commit

Permalink
feat(ui): NoDataPlaceholder signature changed content > children
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandarDev committed Oct 27, 2023
1 parent e1266d2 commit 95f4542
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 23 deletions.
8 changes: 6 additions & 2 deletions web/apps/app/app/channels/[channelName]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ function ChannelConnectPartial(props: { channelName: string }) {
return <ChannelPartialSlack />;

return (
<NoDataPlaceholder content="Connect action not availble" />
<NoDataPlaceholder>
Connect action not availble
</NoDataPlaceholder>
);
}

Expand Down Expand Up @@ -71,7 +73,9 @@ export default function AppChannelPage({ params }: { params: { channelName: stri
))}
</List>
) : (
<NoDataPlaceholder content="No items" />
<NoDataPlaceholder>
No items
</NoDataPlaceholder>
)}
</Loadable>
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion web/apps/app/components/graphs/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ function Graph({ isLoading, error, data, label, discrete, ...rest }: GraphProps)
{!!label && <Typography>{label}</Typography>}
<Loadable isLoading={isLoading} loadingLabel="Loading data" error={error} width={100}>
{!data || data.length <= 0
? <NoDataPlaceholder content={t('NoData')} />
? <NoDataPlaceholder>{t('NoData')}</NoDataPlaceholder>
: <GraphComponent data={data} {...rest} />}
</Loadable>
</Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export default function EntityContactSelection(props: EntityContactSelectionProp
};

if (!isLoading && !error && !contacts.length) {
return <div className="p-2"><NoDataPlaceholder content={'No applicable contacts available'} /></div>;
return (
<div className="p-2">
<NoDataPlaceholder>No applicable contacts available</NoDataPlaceholder>
</div>
);
}

return (
Expand Down
4 changes: 3 additions & 1 deletion web/apps/app/components/views/Entity/EntityDetailsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export default function EntityDetailsView({ id }: EntityDetailsViewProps) {

if (!isLoading && !error && entity == null) {
return (
<NoDataPlaceholder content={'Not Found'} />
<NoDataPlaceholder>
Not Found
</NoDataPlaceholder>
);
}
return (
Expand Down
4 changes: 3 additions & 1 deletion web/apps/app/components/widgets/parts/WidgetChecklist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ function WidgetChecklist(props: WidgetSharedProps<ConfigProps>) {
? items.map(item => <ChecklistItem key={item.id} item={item} onChange={handleItemChanged} onRemove={handleItemRemoved} />)
: (
<div className="flex h-full items-center justify-center">
<NoDataPlaceholder content={placeholders.t('NoItems')} />
<NoDataPlaceholder>
{placeholders.t('NoItems')}
</NoDataPlaceholder>
</div>
)}
</Stack>
Expand Down
4 changes: 3 additions & 1 deletion web/apps/app/components/widgets/parts/WidgetFinanceStock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export default function WidgetFinanceStock(props: WidgetSharedProps<ConfigProps>
</Stack>
<Stack>
{!price?.item ? (
<NoDataPlaceholder content={'No data'} />
<NoDataPlaceholder>
No data
</NoDataPlaceholder>
) : (
<>
<Typography level="h4" bold lineHeight={0.9}>${closePrice}</Typography>
Expand Down
15 changes: 12 additions & 3 deletions web/apps/ui-docs/stories/Components/NavigatingButton.stories.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { NavigatingButton } from "@signalco/ui/dist/NavigatingButton";
import { StoryObj } from "@storybook/react";
import { Meta, StoryObj } from "@storybook/react";

export default { component: NavigatingButton, tags: ['autodocs'] };
type Story = StoryObj<typeof NavigatingButton>;
const Component = NavigatingButton;

export default {
component: Component,
tags: ['autodocs'],
args: {
children: 'Navigate',
href: '#'
}
} satisfies Meta<typeof Component>;
type Story = StoryObj<typeof Component>;

export const Default: Story = {};
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { NoDataPlaceholder } from "@signalco/ui/dist/NoDataPlaceholder";
import { StoryObj } from "@storybook/react";
import { Meta, StoryObj } from "@storybook/react";

export default { component: NoDataPlaceholder, tags: ['autodocs'] };
type Story = StoryObj<typeof NoDataPlaceholder>;
const Component = NoDataPlaceholder;

export default { component: Component, tags: ['autodocs'], args: { children: 'No data' } } satisfies Meta<typeof Component>;
type Story = StoryObj<typeof Component>;

export const Default: Story = {};
3 changes: 2 additions & 1 deletion web/apps/ui-docs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"noEmit": true
},
"include": [
"stories"
"stories/**/*.ts",
"stories/**/*.tsx"
]
}
4 changes: 2 additions & 2 deletions web/packages/ui/src/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState } from 'react';
import type { ComponentProps, MouseEvent } from 'react';
import { cx } from 'classix';
import { ExpandDown } from '@signalco/ui-icons';
import { Row } from '../Row';
import { Icon } from '../Icon';
import { Collapse } from '../Collapse';
import { Card, CardContent, CardHeader } from '../Card';

Expand Down Expand Up @@ -34,7 +34,7 @@ export function Accordion({ children, open, disabled, onOpenChanged, unmountOnEx
<Row spacing={1} justifyContent="space-between">
{multipleChildren ? children[0] : children}
{!disabled && (
<Icon>{actualOpen ? 'expand_less' : 'expand_more'}</Icon>
<ExpandDown className={cx('uitw-transition-transform', actualOpen && 'uitw-scale-y-[-1]')} />
)}
</Row>
</CardHeader>
Expand Down
2 changes: 1 addition & 1 deletion web/packages/ui/src/FilterList/FilterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function ItemsWrapper({ children, noItemsPlaceholder, itemsWrapper, ...re
return (
<Loadable {...rest}>
{!children || !Array.isArray(children) || children.length === 0 ? (
<NoDataPlaceholder content={noItemsPlaceholder} />
<NoDataPlaceholder>{noItemsPlaceholder}</NoDataPlaceholder>
) : (
<ItemsWrapper>{children}</ItemsWrapper>
)}
Expand Down
10 changes: 4 additions & 6 deletions web/packages/ui/src/NoDataPlaceholder/NoDataPlaceholder.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Typography } from '../Typography';
import { Typography, type TypographyProps } from '../Typography';

export type NoDataPlaceholderProps = {
content: React.ReactNode | string;
};
export type NoDataPlaceholderProps = TypographyProps;

export function NoDataPlaceholder({ content }: NoDataPlaceholderProps) {
return <Typography level="body2">{content}</Typography>
export function NoDataPlaceholder(props: NoDataPlaceholderProps) {
return <Typography level="body2" {...props} />
}

0 comments on commit 95f4542

Please sign in to comment.