Skip to content

Commit

Permalink
Merge pull request #85 from nebula-aac/custom-meshery-components
Browse files Browse the repository at this point in the history
[components] created `searchbar` and `tooltip`
  • Loading branch information
aabidsofi19 authored Sep 9, 2023
2 parents 3188e5f + 0214ed1 commit 4c5acd3
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 13 deletions.
4 changes: 3 additions & 1 deletion packages/components/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ module.exports = {
sourceType: 'module'
},
plugins: ['react'],
rules: {}
rules: {
'@typescript-eslint/explicit-function-return-type': ['warn']
}
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AccordionProps, Accordion as MuiAccordion } from '@mui/material';
import { Accordion as MuiAccordion, type AccordionProps } from '@mui/material';
import React from 'react';

export function Accordion(props: AccordionProps) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AccordionActionsProps, AccordionActions as MuiAccordionActions } from '@mui/material';
import { AccordionActions as MuiAccordionActions, type AccordionActionsProps } from '@mui/material';
import React from 'react';

export function AccordionActions(props: AccordionActionsProps) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AccordionDetailsProps, AccordionDetails as MuiAccordionDetails } from '@mui/material';
import { AccordionDetails as MuiAccordionDetails, type AccordionDetailsProps } from '@mui/material';
import React from 'react';

export function AccordionDetails(props: AccordionDetailsProps) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AccordionSummaryProps, AccordionSummary as MuiAccordionSummary } from '@mui/material';
import { AccordionSummary as MuiAccordionSummary, type AccordionSummaryProps } from '@mui/material';
import React from 'react';

export function AccordionSummary(props: AccordionSummaryProps) {
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/base/Accordion/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { Accordion } from './accordion';
export { AccordionActions } from './accordionactions';
export { AccordionDetails } from './accordiondetails';
export { AccordionSummary } from './accordionsummary';
52 changes: 52 additions & 0 deletions packages/components/src/custom/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React, { Fragment, type ChangeEvent, type FC, type ReactNode } from 'react';
import { Box } from '../box';
import { InputAdornment } from '../inputadornment';
import { TextField } from '../textfield';

interface SearchBarProps {
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
value: string;
width?: string;
label: string;
endAdornment?: ReactNode;
}

const SearchBar: FC<SearchBarProps> = ({
onChange,
value,
width,
label,
endAdornment,
...props
}) => {
return (
<Fragment>
<Box
component="form"
sx={{
'& > :not(style)': { width }
}}
{...props}
>
<TextField
variant="outlined"
label={label}
fullWidth
type="search"
value={value}
onChange={onChange}
sx={{
margin: 'auto',
height: '5ch'
}}
placeholder="Search"
InputProps={{
endAdornment: <InputAdornment position="end">{endAdornment}</InputAdornment>
}}
/>
</Box>
</Fragment>
);
};

export default SearchBar;
25 changes: 25 additions & 0 deletions packages/components/src/custom/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { type TooltipProps as MuiTooltipProps } from '@mui/material';
import React, { type FC, type MouseEvent, type ReactElement } from 'react';
import { Tooltip } from '../tooltip';

type TooltipProps = {
title: string;
onClick?: (event: MouseEvent<HTMLElement>) => void;
children: ReactElement<any, any>;
} & Omit<MuiTooltipProps, 'title' | 'children' | 'onClick'>;

export const MesheryTooltip: FC<TooltipProps> = ({
title,
onClick,
placement,
children,
...props
}) => {
return (
<Tooltip title={title} placement={placement} onClick={onClick} arrow {...props}>
{children}
</Tooltip>
);
};

export default Tooltip;
2 changes: 2 additions & 0 deletions packages/components/src/custom/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as SearchBar } from './SearchBar';
export { default as Tooltip } from './Tooltip';
7 changes: 3 additions & 4 deletions packages/components/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
export { Accordion } from './accordion';
export { AccordionActions } from './accordionactions';
export { AccordionDetails } from './accordiondetails';
export { AccordionSummary } from './accordionsummary';
export { AppBar } from './appbar';
export { Avatar } from './avatar';
export { AvatarGroup } from './avatargroup';
export * from './base/Accordion';
export { Box } from './box';
export { BaseButton } from './button';
export { ButtonGroup } from './buttongroup';
export { Card } from './card';
export { Checkbox } from './checkbox';
export { Chip } from './chip';
export * from './custom';
export { Dialog } from './dialog';
export { DialogActions } from './dialogactions';
export { DialogContent } from './dialogcontent';
Expand All @@ -19,6 +17,7 @@ export { DialogTitle } from './dialogtitle';
export { Divider } from './divider';
export { Drawer } from './drawer';
export { IconButton } from './iconbutton';
export { InputAdornment } from './inputadornment';
export { List } from './list';
export { Menu } from './menu';
export { Paper } from './paper';
Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/inputadornment.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { InputAdornment as MuiInputAdornment, type InputAdornmentProps } from '@mui/material';
import React from 'react';

export function InputAdornment(props: InputAdornmentProps): JSX.Element {
return <MuiInputAdornment {...props} />;
}
6 changes: 3 additions & 3 deletions packages/components/src/textfield.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TextField as MuiTextField, TextFieldProps } from '@mui/material';
import { TextField as MuiTextField, type TextFieldProps } from '@mui/material';
import React from 'react';

export const TextField = (props: TextFieldProps) => {
export function TextField(props: TextFieldProps): JSX.Element {
return <MuiTextField {...props} />;
};
}
2 changes: 1 addition & 1 deletion packages/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@layer5/sistent-components": "0.1.0",
"@layer5/sistent-components": "*",
"@mui/material": "^5.14.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
11 changes: 11 additions & 0 deletions packages/design-system/src/stories/SearchBar.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { MesherySearchBar } from '@layer5/sistent-components';

export default {
title: 'Example/SearchBar',
component: MesherySearchBar,
tags: ['autodocs']
};

export function SearchBar() {
return <MesherySearchBar />;
}
15 changes: 15 additions & 0 deletions packages/design-system/src/stories/Tooltip.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { BaseButton, MesheryTooltip } from '@layer5/sistent-components';

export default {
title: 'Example/Tooltip',
component: MesheryTooltip,
tags: ['autodocs']
};

export function NonInteractiveTooltip() {
return (
<MesheryTooltip title="Add" disableInteractive>
<BaseButton>Not Interactive</BaseButton>
</MesheryTooltip>
);
}

0 comments on commit 4c5acd3

Please sign in to comment.