mirror of
https://github.com/ansible/awx.git
synced 2026-01-21 22:48:02 -03:30
* Switched Selectable Card to styled components * styles.scss in AddRole/ removed * styles.scss import in index.jsx removed Signed-off-by: catjones9 <catjones@redhat.com> * Addressed PR linter issues Signed-off-by: catjones9 <catjones@redhat.com> * Switched Indicator and Label to styled components Signed-off-by: catjones9 <catjones@redhat.com>
68 lines
1.4 KiB
JavaScript
68 lines
1.4 KiB
JavaScript
import React, { Component } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import styled from 'styled-components';
|
|
|
|
const SelectableItem = styled.div`
|
|
min-width: 200px;
|
|
border: 1px solid var(--pf-global--BorderColor--200);
|
|
border-radius: var(--pf-global--BorderRadius--sm);
|
|
border: 1px solid;
|
|
border-color: ${props => (props.isSelected ? 'var(--pf-global--active-color--100)' : 'var(--pf-global--BorderColor--200)')};
|
|
margin-right: 20px;
|
|
font-weight: bold;
|
|
display: flex;
|
|
cursor: pointer;
|
|
`;
|
|
|
|
const Indicator = styled.div`
|
|
display: flex;
|
|
flex: 0 0 5px;
|
|
background-color: ${props => (props.isSelected ? 'var(--pf-global--active-color--100)' : null)};
|
|
`;
|
|
|
|
const Label = styled.div`
|
|
display: flex;
|
|
flex: 1;
|
|
align-items: center;
|
|
padding: 20px;
|
|
`;
|
|
|
|
class SelectableCard extends Component {
|
|
render () {
|
|
const {
|
|
label,
|
|
onClick,
|
|
isSelected
|
|
} = this.props;
|
|
|
|
return (
|
|
<SelectableItem
|
|
onClick={onClick}
|
|
onKeyPress={onClick}
|
|
role="button"
|
|
tabIndex="0"
|
|
isSelected={isSelected}
|
|
>
|
|
|
|
<Indicator
|
|
isSelected={isSelected}
|
|
/>
|
|
<Label>{label}</Label>
|
|
</SelectableItem>
|
|
);
|
|
}
|
|
}
|
|
|
|
SelectableCard.propTypes = {
|
|
label: PropTypes.string,
|
|
onClick: PropTypes.func.isRequired,
|
|
isSelected: PropTypes.bool
|
|
};
|
|
|
|
SelectableCard.defaultProps = {
|
|
label: '',
|
|
isSelected: false
|
|
};
|
|
|
|
export default SelectableCard;
|