Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: export members and add use client if needed for next support #26

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/components/Avatar/AvatarGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import cx from 'classnames';
import { useMemo } from 'react';
import { Avatar, type AvatarProps, type AvatarSize, type AvatarType } from '.';
Expand Down
1 change: 1 addition & 0 deletions lib/components/ContextMenu/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ContextMenu';
4 changes: 2 additions & 2 deletions lib/components/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DialogHeader } from './DialogHeader';
import { DialogSeenBy, type DialogSeenByProps } from './DialogSeenBy';

import type { ReactNode } from 'react';
import { DialogAction, type DialogActionButtonProps } from './DialogAction';
import { type DialogActionButtonProps, DialogActions } from './DialogActions.tsx';
import type { DialogRecipientProps, DialogSenderProps } from './DialogHeadings.tsx';
import { DialogHistory, type DialogHistoryProps } from './DialogHistory';
import { type DialogBackButtonProps, DialogNav } from './DialogNav';
Expand Down Expand Up @@ -87,7 +87,7 @@ export const Dialog = ({
<DialogBodyBase>
<DialogContent updatedAt={updatedAt} updatedByName={updatedByName} summary={summary} body={body} />
{attachments && <DialogAttachments {...attachments} />}
{actions?.length > 0 && <DialogAction items={actions} />}
{actions?.length > 0 && <DialogActions items={actions} />}
<MetaBase>
{seenBy && <DialogSeenBy {...seenBy} />}
{activityLog && <DialogActivityLog {...activityLog} />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import type { Meta, StoryObj } from '@storybook/react';
import { DialogAction } from './DialogAction';
import { DialogActions } from './DialogActions';

const meta = {
title: 'Dialog/Sections/DialogAction',
component: DialogAction,
title: 'Dialog/Sections/DialogActions',
component: DialogActions,
tags: ['autodocs'],
args: {
items: [
{
label: 'Primary',
priority: 'primary',
id: 'primary',
},
{
label: 'Secondary',
priority: 'secondary',
id: 'secondary',
},
],
},
} satisfies Meta<typeof DialogAction>;
} satisfies Meta<typeof DialogActions>;

export default meta;
type Story = StoryObj<typeof meta>;
Expand All @@ -34,18 +36,22 @@ export const MultipleButtons: Story = {
args: {
items: [
{
id: 'primary',
label: 'Primary',
priority: 'primary',
},
{
id: 'secondary-1',
label: 'Secondary',
priority: 'secondary',
},
{
id: 'tertiary-1',
label: 'Third action',
priority: 'tertiary',
},
{
id: 'tertiary-2',
label: 'Fourth action',
priority: 'tertiary',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import { type MouseEventHandler, useMemo, useState } from 'react';
import { Button, ComboButton } from '../Button';
import { Menu, type MenuItemProps } from '../Menu';
Expand All @@ -13,14 +14,14 @@ export interface DialogActionButtonProps {
loading?: boolean;
}

export interface DialogActionProps {
export interface DialogActionsProps {
/** List of actions */
items: DialogActionButtonProps[];
/** How many actions to display before turning into a ComboButton */
maxItems?: number;
}

export const DialogAction = ({ items, maxItems = 2 }: DialogActionProps) => {
export const DialogActions = ({ items, maxItems = 2 }: DialogActionsProps) => {
const [expanded, setExpanded] = useState<boolean>(false);
const sortedItems = useMemo(() => {
return (items || []).sort((a, b) => {
Expand Down
4 changes: 2 additions & 2 deletions lib/components/Dialog/DialogHeaderBase.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { ReactNode } from 'react';
import styles from './dialogHeaderBase.module.css';

export interface DialogHeaderProps {
export interface DialogHeaderBaseProps {
children?: ReactNode;
}

export const DialogHeaderBase = ({ children }: DialogHeaderProps) => {
export const DialogHeaderBase = ({ children }: DialogHeaderBaseProps) => {
return <header className={styles.header}>{children}</header>;
};
22 changes: 22 additions & 0 deletions lib/components/Dialog/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
export * from './Dialog';
export * from './DialogList';
export * from './DialogMetadata';
export * from './DialogListItem';
export * from './DialogListItemBase';
export * from './DialogActions.tsx';
export * from './DialogActivityLog';
export * from './DialogArticleBase';
export * from './DialogBase';
export * from './DialogBodyBase';
export * from './DialogBorder';
export * from './DialogContent';
export * from './DialogFooter';
export * from './DialogHeader';
export * from './DialogHeaderBase';
export * from './DialogHeadings';
export * from './DialogHistory';
export * from './DialogNav';
export * from './DialogSectionBase';
export * from './DialogSeenBy';
export * from './DialogSelect';
export * from './DialogStatus';
export * from './DialogTitle';
export * from './DialogTouchedBy';
2 changes: 2 additions & 0 deletions lib/components/List/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ export * from './ListItemBase';
export * from './ListItem';
export * from './ListBase';
export * from './List';
export * from './ListItemLabel';
export * from './ListItemMedia';
1 change: 1 addition & 0 deletions lib/components/Menu/useClickOutside.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import { type RefObject, useEffect } from 'react';

export const useClickOutside = (ref: RefObject<HTMLDivElement>, callback: () => void) => {
Expand Down
1 change: 1 addition & 0 deletions lib/components/Menu/useEscapeKey.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import { useEffect } from 'react';

export const useEscapeKey = (onEscape: () => void): void => {
Expand Down
2 changes: 2 additions & 0 deletions lib/components/Meta/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export * from './MetaBase';
export * from './MetaList';
export * from './MetaItemBase';
export * from './MetaItemMedia';
export * from './MetaItemLabel';
export * from './MetaItem';
export * from './MetaProgress';
export * from './MetaTimestamp';
7 changes: 6 additions & 1 deletion lib/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
export * from './Attachment';
export * from './Avatar';
export * from './Button';
export * from './Badge';
export * from './Button';
export * from './ContextMenu';
export * from './Dialog';
export * from './Header';
export * from './History';
export * from './Icon';
export * from './Layout';
export * from './List';
export * from './Menu';
export * from './Meta';
export * from './Toolbar';
export * from './Typography';
Loading