Replace Lookup tags with pf-react Chip component

This commit is contained in:
Marliana Lara
2019-02-22 14:35:58 -05:00
parent de3cc4637e
commit 92d3cb6dc4
3 changed files with 21 additions and 33 deletions

View File

@@ -228,26 +228,10 @@
}
}
.awx-c-icon--remove {
padding-left: 10px;
&:hover {
cursor: pointer;
}
}
.awx-c-list {
border-bottom: 1px solid #d7d7d7;
}
.awx-c-tag--pill {
color: var(--pf-global--BackgroundColor--light-100);
background-color: rgb(0, 123, 186);
border-radius: 3px;
margin: 1px 2px;
padding: 0 10px;
display: inline-block;
}
.at-c-listCardBody {
--pf-c-card__footer--PaddingX: 0;
--pf-c-card__footer--PaddingY: 0;

View File

@@ -2,6 +2,8 @@ import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { SearchIcon, CubesIcon } from '@patternfly/react-icons';
import {
Chip,
ChipGroup,
Modal,
Button,
EmptyState,
@@ -134,17 +136,6 @@ class Lookup extends React.Component {
this.handleModalToggle();
}
wrapTags (tags = []) {
return tags.map(tag => (
<span className="awx-c-tag--pill" key={tag.id}>
{tag.name}
<Button className="awx-c-icon--remove" id={tag.id} onClick={() => this.toggleSelected(tag)}>
x
</Button>
</span>
));
}
render () {
const {
isModalOpen,
@@ -159,6 +150,19 @@ class Lookup extends React.Component {
} = this.state;
const { lookupHeader = 'items', value, columns } = this.props;
let chips = null;
if (value) {
chips = (
<ChipGroup>
{value.map(chip => (
<Chip key={chip.id} onClick={() => this.toggleSelected(chip)}>
{chip.name}
</Chip>
))}
</ChipGroup>
);
}
return (
<I18n>
{({ i18n }) => (
@@ -166,7 +170,7 @@ class Lookup extends React.Component {
<Button className="pf-c-input-group__text" aria-label="search" id="search" onClick={this.handleModalToggle}>
<SearchIcon />
</Button>
<div className="pf-c-form-control">{this.wrapTags(value)}</div>
<div className="pf-c-form-control">{chips}</div>
<Modal
className="awx-c-modal"
title={`Select ${lookupHeader}`}