formview better style

This commit is contained in:
Jan Prochazka
2021-01-23 20:36:58 +01:00
parent 532c64840b
commit e253cfb1b0
2 changed files with 14 additions and 1 deletions

View File

@@ -3,11 +3,17 @@
import React from 'react'; import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { FontIcon } from '../icons'; import { FontIcon } from '../icons';
import useTheme from '../theme/useTheme';
const Label = styled.span` const Label = styled.span`
font-weight: ${props => (props.notNull ? 'bold' : 'normal')}; font-weight: ${props => (props.notNull ? 'bold' : 'normal')};
white-space: nowrap; white-space: nowrap;
`; `;
const ExtInfoWrap = styled.span`
font-weight: normal;
margin-left: 5px;
color: ${props => props.theme.left_font3};
`;
export function getColumnIcon(column, forceIcon = false) { export function getColumnIcon(column, forceIcon = false) {
if (column.autoIncrement) return 'img autoincrement'; if (column.autoIncrement) return 'img autoincrement';
@@ -19,9 +25,11 @@ export function getColumnIcon(column, forceIcon = false) {
/** @param column {import('dbgate-datalib').DisplayColumn|import('dbgate-types').ColumnInfo} */ /** @param column {import('dbgate-datalib').DisplayColumn|import('dbgate-types').ColumnInfo} */
export default function ColumnLabel(column) { export default function ColumnLabel(column) {
const icon = getColumnIcon(column, column.forceIcon); const icon = getColumnIcon(column, column.forceIcon);
const theme = useTheme();
return ( return (
<Label {...column}> <Label {...column}>
{icon ? <FontIcon icon={icon} /> : null} {column.headerText || column.columnName} {icon ? <FontIcon icon={icon} /> : null} {column.headerText || column.columnName}
{column.extInfo ? <ExtInfoWrap theme={theme}>{column.extInfo}</ExtInfoWrap> : null}
</Label> </Label>
); );
} }

View File

@@ -490,7 +490,12 @@ export default function FormView(props) {
isSelected={currentCell[0] == rowIndex && currentCell[1] == chunkIndex * 2} isSelected={currentCell[0] == rowIndex && currentCell[1] == chunkIndex * 2}
ref={element => setCellRef(rowIndex, chunkIndex * 2, element)} ref={element => setCellRef(rowIndex, chunkIndex * 2, element)}
> >
<ColumnLabelMargin {...col} /> <ColumnLabelMargin
{...col}
headerText={col.columnName}
style={{ marginLeft: (col.uniquePath.length - 1) * 20 }}
extInfo={col.foreignKey ? ` -> ${col.foreignKey.refTableName}` : null}
/>
{col.foreignKey && ( {col.foreignKey && (
<ShowFormButton <ShowFormButton