Add components for simple view users and companies.

Add Grid.jsx for css grid.
This commit is contained in:
Фролов 2021-08-31 18:03:08 +05:00
parent 22c242cd5e
commit 33146c59d8
3 changed files with 81 additions and 20 deletions

View File

@ -0,0 +1,25 @@
import {Tooltip} from 'antd'
import {BankOutlined} from '@ant-design/icons'
import {Grid, GridItem} from './Grid'
export const CompanyView = ({company}) => {
if(!company)
return <Tooltip title='нет данных'>-</Tooltip>
const displayName = company?.caption
const tooltipInfo = <Grid columnGap='8px'>
<GridItem row={1} col={1}>
тип:
</GridItem>
<GridItem row={1} col={2}>
{company?.companyTypeCaption}
</GridItem>
</Grid>
return <Tooltip title={tooltipInfo}>
<BankOutlined style={{marginRight:8}}/>
{displayName}
</Tooltip>
}

30
src/components/Grid.jsx Normal file
View File

@ -0,0 +1,30 @@
export const Grid = ({children, ...other}) => {
const gridContainerStyle = {
display: 'grid',
columnGap: '4px',
rowGap: '4px',
...other,
}
return <div style={gridContainerStyle}>
{children}
</div>
}
export const GridItem = ({children, row, col, rowSpan, colSpan, ...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,
...other,
}
return <div style={gridItemStyle}>
{children}
</div>
}

View File

@ -1,6 +1,6 @@
import {Tooltip} from 'antd'
import { UserOutlined } from '@ant-design/icons'
import '../styles/grid.css'
import {UserOutlined} from '@ant-design/icons'
import {Grid, GridItem} from './Grid'
export const UserView = ({user}) => {
if(!user)
@ -8,29 +8,35 @@ export const UserView = ({user}) => {
const displayName = user?.login
const tooltipInfo = <div className='grid_container'>
<div className='c1 r1'>
Имя
</div>
<div className='c2 r1'>
const tooltipInfo = <Grid columnGap='8px'>
<GridItem row={1} col={1}>
Имя:
</GridItem>
<GridItem row={1} col={2}>
{user?.name}
</div>
<div className='c1 r2'>
Фамилия
</div>
<div className='c2 r2'>
</GridItem>
<GridItem row={2} col={1}>
Фамилия:
</GridItem>
<GridItem row={3} col={2}>
{user?.surname}
</div>
<div className='c1 r3'>
Отчество
</div>
<div className='c2 r3'>
</GridItem>
<GridItem row={3} col={1}>
Отчество:
</GridItem>
<GridItem row={3} col={2}>
{user?.patronymic}
</div>
</div>
</GridItem>
<GridItem row={4} col={1}>
Компания:
</GridItem>
<GridItem row={4} col={2}>
{user?.company?.caption}
</GridItem>
</Grid>
return <Tooltip title={tooltipInfo}>
<UserOutlined/>
<UserOutlined style={{marginRight:8}}/>
{displayName}
</Tooltip>