Skip to content

Commit

Permalink
Merge pull request #277 from Enterwell/feature/item-accordion
Browse files Browse the repository at this point in the history
feat: Added ItemAccordion component to ui
  • Loading branch information
AleksandarDev authored Jan 8, 2024
2 parents f356bec + 6abf7e2 commit c10a36f
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 1 deletion.
26 changes: 26 additions & 0 deletions apps/docs/components/ExampleItemAccordion.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ItemAccordion, ItemAccordionDetails, ItemAccordionSummary, ItemAccordionActions } from '@enterwell/react-ui';
import { Button, Stack, Typography } from '@mui/material';

export function ExampleItemAccordion() {
return (
<ItemAccordion>
<ItemAccordionSummary>
<Stack width="160px">
<Typography fontSize={14} fontWeight="bold">
Test title
</Typography>
</Stack>
<Stack>
<Typography>Test summary text</Typography>
</Stack>
</ItemAccordionSummary>
<ItemAccordionDetails></ItemAccordionDetails>
<ItemAccordionActions>
<Stack direction={'row'}>
<Button color='warning'>Delete</Button>
<Button color='success'>Update</Button>
</Stack>
</ItemAccordionActions>
</ItemAccordion>
)
}
33 changes: 33 additions & 0 deletions apps/docs/pages/react-ui/components/item-accordion.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: ItemAccordion
---

import { ItemAccordion } from '@enterwell/react-ui';
import { ComponentWithSource } from '../../../components/docs/ComponentWithSource.tsx';
import { ExampleItemAccordion } from '../../../components/ExampleItemAccordion.tsx';
import { ComponentDescription, ComponentParameters, ComponentSource } from '../../../components/docs/ComponentDocs';

# ItemAccordion

## Description

<ComponentDescription name="ItemAccordion" />

### Parameters

<ComponentParameters name="ItemAccordion" />

## Example

<ComponentWithSource component={ ExampleItemAccordion } centered />

## Inspect

<details>
<summary>Source code</summary>
<ComponentSource
package="@enterwell/react-ui"
directory="ItemAccordion"
name="ItemAccordion"
/>
</details>
3 changes: 2 additions & 1 deletion packages/react-ui/.changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"SearchHeader",
"Select",
"SplitButton",
"TimeInput"
"TimeInput",
"ItemAccordion"
]
}
12 changes: 12 additions & 0 deletions packages/react-ui/ItemAccordion/ItemAccordion.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import MuiAccordion, { type AccordionProps } from '@mui/material/Accordion';

/**
* Item accordion component.
*
* @param props - The props of the component
* @returns The ItemAccordion component.
* @public
*/
export function ItemAccordion(props: AccordionProps) {
return <MuiAccordion disableGutters {...props} />
}
18 changes: 18 additions & 0 deletions packages/react-ui/ItemAccordion/ItemAccordionActions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useTheme } from '@mui/material';
import MuiAccordionActions, { type AccordionActionsProps } from '@mui/material/AccordionActions';

/**
* Item accordion actions component.
*
* @param props - The props of the component
* @returns The ItemAccordionActions component.
* @public
*/
export function ItemAccordionActions(props: AccordionActionsProps) {
const theme = useTheme();
return (
<MuiAccordionActions {...props} sx={{ borderTop: '1px solid', borderTopColor: theme.palette.divider, ...props.sx }} />
);
}

export default ItemAccordionActions;
18 changes: 18 additions & 0 deletions packages/react-ui/ItemAccordion/ItemAccordionDetails.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useTheme } from '@mui/material';
import MuiAccordionDetails, { type AccordionDetailsProps } from '@mui/material/AccordionDetails';

/**
* Item accordion details component.
*
* @param props - The props of the component
* @returns The ItemAccordionDetails component.
* @public
*/
export function ItemAccordionDetails(props: AccordionDetailsProps) {
const theme = useTheme();
return (
<MuiAccordionDetails {...props} sx={{ padding: 16, borderTop: '1px solid', borderTopColor: theme.palette.divider, ...props.sx }} />
);
}

export default ItemAccordionDetails;
28 changes: 28 additions & 0 deletions packages/react-ui/ItemAccordion/ItemAccordionSummary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import MuiAccordionSummary, { type AccordionSummaryProps } from '@mui/material/AccordionSummary';
import { ExpandMore } from '@mui/icons-material';

/**
* Item accordion summary component.
*
* @param props - The props of the component
* @returns The ItemAccordionSummary component.
* @public
*/
export function ItemAccordionSummary(props: AccordionSummaryProps) {
const {
children,
...rest
} = props;

return (
<MuiAccordionSummary
expandIcon={<ExpandMore color="primary" />}
{...rest}
sx={{ height: 56, ...rest.sx }}
>
{children}
</MuiAccordionSummary >
);
}

export default ItemAccordionSummary;
4 changes: 4 additions & 0 deletions packages/react-ui/ItemAccordion/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./ItemAccordion";
export * from "./ItemAccordionSummary";
export * from "./ItemAccordionDetails";
export * from "./ItemAccordionActions";
Empty file.
1 change: 1 addition & 0 deletions packages/react-ui/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

// component exports
export * from "./ItemAccordion";
export * from "./Select";
export * from "./SplitButton";
export * from "./DatePicker";
Expand Down
16 changes: 16 additions & 0 deletions packages/react-ui/temp/react-ui.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
```ts

import { AccordionActionsProps } from '@mui/material/AccordionActions';
import { AccordionDetailsProps } from '@mui/material/AccordionDetails';
import { AccordionProps } from '@mui/material/Accordion';
import { AccordionSummaryProps } from '@mui/material/AccordionSummary';
import { AutocompleteProps } from '@mui/material/Autocomplete';
import { ButtonGroupProps } from '@mui/material';
import { ButtonProps } from '@mui/material';
Expand Down Expand Up @@ -102,6 +106,18 @@ export type DropdownButtonProps = ButtonProps & {
onClick?: (event: any, value: any) => void;
};

// @public
export function ItemAccordion(props: AccordionProps): react_jsx_runtime.JSX.Element;

// @public
export function ItemAccordionActions(props: AccordionActionsProps): react_jsx_runtime.JSX.Element;

// @public
export function ItemAccordionDetails(props: AccordionDetailsProps): react_jsx_runtime.JSX.Element;

// @public
export function ItemAccordionSummary(props: AccordionSummaryProps): react_jsx_runtime.JSX.Element;

// @public
export function PageDrawer({ expanded, onChange, children, height, minHeight, onResize, color, ...rest }: PageDrawerProps): react_jsx_runtime.JSX.Element;

Expand Down

0 comments on commit c10a36f

Please sign in to comment.