diff --git a/src/components/Grid.jsx b/src/components/Grid.jsx deleted file mode 100644 index 177fc31..0000000 --- a/src/components/Grid.jsx +++ /dev/null @@ -1,39 +0,0 @@ -export const Grid = ({children, style, ...other}) => { - const gridContainerStyle = { - display: 'grid', - margin: '8px', - justifyItems: 'stretch', - alignItems: 'stretch', - ...style, - } - - return
- {children} -
-} - -export const GridItem = ({children, row, col, rowSpan, colSpan, style, ...other}) => { - const localRow = +row - const localCol = +col - const localColSpan = colSpan ? colSpan - 1 : 0 - const localRowSpan = rowSpan ? rowSpan - 1 : 0 - const gridItemStyle = { - gridColumnStart: localCol, - gridColumnEnd: localCol + localColSpan, - gridRowStart: localRow, - gridRowEnd: localRow + localRowSpan, - padding: '4px', - ...style, - } - - return
- {children} -
-} - -export const Flex = ({children, style, ...other}) => -
- {children} -
\ No newline at end of file diff --git a/src/components/Grid.tsx b/src/components/Grid.tsx new file mode 100644 index 0000000..3b653c4 --- /dev/null +++ b/src/components/Grid.tsx @@ -0,0 +1,54 @@ +import React from 'react' + +interface ComponentProps { + children?: React.ReactNode + style?: React.CSSProperties + [other: string]: any +} + +interface GridItemProps extends ComponentProps { + children?: React.ReactNode + style?: React.CSSProperties + row: number + col: number + rowSpan?: number + colSpan?: number +} + +const gridDefaultStyle = { + display: 'grid', + margin: '8px', + justifyItems: 'stretch', + alignItems: 'stretch', +} + +export const Grid = ({ children, style, ...other }: ComponentProps) => ( +
+ {children} +
+) + +export const GridItem = ({ children, row, col, rowSpan, colSpan, style, ...other }: GridItemProps) => { + const localRow = +row + const localCol = +col + const localColSpan = colSpan ? colSpan - 1 : 0 + const localRowSpan = rowSpan ? rowSpan - 1 : 0 + const gridItemStyle = { + gridColumnStart: localCol, + gridColumnEnd: localCol + localColSpan, + gridRowStart: localRow, + gridRowEnd: localRow + localRowSpan, + padding: '4px', + ...style, + } + + return
+ {children} +
+} + +export const Flex = ({ children, style, ...other } : ComponentProps) => ( +
+ {children} +
+) diff --git a/src/components/UserView.jsx b/src/components/UserView.jsx deleted file mode 100644 index 08e7ab3..0000000 --- a/src/components/UserView.jsx +++ /dev/null @@ -1,43 +0,0 @@ -import {Tooltip} from 'antd' -import {UserOutlined} from '@ant-design/icons' -import {Grid, GridItem} from './Grid' - -export const UserView = ({user}) => { - if(!user) - return - - - const displayName = user?.login - - const tooltipInfo = - - Имя: - - - {user?.name} - - - Фамилия: - - - {user?.surname} - - - Отчество: - - - {user?.patronymic} - - - Компания: - - - {user?.company?.caption} - - - - return - - {displayName} - - -} \ No newline at end of file diff --git a/src/components/UserView.tsx b/src/components/UserView.tsx new file mode 100644 index 0000000..c2fc142 --- /dev/null +++ b/src/components/UserView.tsx @@ -0,0 +1,29 @@ +import {Tooltip} from 'antd' +import { UserOutlined } from '@ant-design/icons' +import { Grid, GridItem } from './Grid' +import { UserDto } from '../services/api' + +interface UserViewProps { + user: UserDto +} + +export const UserView = ({ user } : UserViewProps) => (user ? ( + + Фамилия: + {user?.surname} + Имя: + {user?.name} + Отчество: + {user?.patronymic} + Компания: + {user?.company?.caption} + + )}> + + {user?.login} + + ) : ( + - + ) +)