fix: add hover style for table rows

This commit is contained in:
chenos 2021-01-06 16:31:10 +08:00
parent eac7734f07
commit b6e41a6e45
5 changed files with 19 additions and 2 deletions

View File

@ -3,3 +3,7 @@
margin: 0 auto;
padding-top: 100px;
}
.ant-form-item-with-help {
margin-bottom: 24px;
}

View File

@ -144,6 +144,7 @@ export function SimpleTable(props: SimpleTableProps) {
data,
mutate,
rowKey,
isFieldComponent,
onMoved: async ({resourceKey, target}) => {
await api.resource(name).sort({
associatedKey,

View File

@ -21,9 +21,10 @@ interface Props {
mutate: any,
rowKey: any,
onMoved: any,
isFieldComponent?: boolean;
}
export const components = ({data = {}, rowKey, mutate, onMoved}: Props) => {
export const components = ({data = {}, rowKey, mutate, onMoved, isFieldComponent}: Props) => {
return {
body: {
wrapper: props => (
@ -51,7 +52,7 @@ export const components = ({data = {}, rowKey, mutate, onMoved}: Props) => {
row: ({ className, style, ...restProps }) => {
// function findIndex base on Table rowKey props and should always be a right array index
const index = findIndex(data.list, (x: any) => x[rowKey] === restProps['data-row-key']);
return <SortableItem index={index} {...restProps} />;
return <SortableItem index={index} className={`${className}${isFieldComponent ? '': ' row-clickable'}`} style={style} {...restProps} />;
},
},
};

View File

@ -138,6 +138,7 @@ export function Table(props: TableProps) {
data,
mutate,
rowKey,
isFieldComponent,
onMoved: async ({resourceKey, target}) => {
await api.resource(name).sort({
associatedKey,

View File

@ -22,3 +22,13 @@
.ant-form-item-label {
font-weight: 500;
}
.row-clickable {
cursor: pointer;
}
.ant-table-tbody > tr.row-clickable:hover > td {
background: #e6f7ff;
border-color: rgba(0, 0, 0, 0.03);
}