Convert toolbar button components to styled-components.

This commit is contained in:
Kia Lam 2019-05-10 12:27:19 -04:00
parent cc192246d9
commit 0ea4a4dedd
No known key found for this signature in database
GPG Key ID: 294F9BE53C241D03
4 changed files with 85 additions and 43 deletions

View File

@ -96,7 +96,7 @@ class DataListToolbar extends React.Component {
)}
</Toolbar>
</LevelItem>
<LevelItem>
<LevelItem css="display: flex;">
{additionalControls}
</LevelItem>
</Level>

View File

@ -66,49 +66,49 @@
margin-left: 20px;
}
.awx-toolbar .pf-c-button.pf-m-primary {
background-color: #5cb85c;
min-width: 0px;
width: 30px;
height: 30px;
text-align: center;
padding: 0px;
margin: 0px;
margin-right: 20px;
}
// .awx-toolbar .pf-c-button.pf-m-primary {
// background-color: #5cb85c;
// min-width: 0px;
// width: 30px;
// height: 30px;
// text-align: center;
// padding: 0px;
// margin: 0px;
// margin-right: 20px;
// }
.awx-toolbar .pf-l-toolbar__item .pf-c-button.pf-m-plain {
font-size: 18px;
}
.awx-ToolBarBtn {
width: 30px;
display: flex;
justify-content: center;
margin-right: 20px;
border-radius: 3px;
// .awx-ToolBarBtn {
// width: 30px;
// display: flex;
// justify-content: center;
// margin-right: 20px;
// border-radius: 3px;
&[disabled] {
cursor: not-allowed;
}
}
// &[disabled] {
// cursor: not-allowed;
// }
// }
.awx-ToolBarBtn:hover {
.awx-ToolBarTrashCanIcon {
color: white;
}
background-color:#d9534f;
}
// .awx-ToolBarBtn:hover {
// .awx-ToolBarTrashCanIcon {
// color: white;
// }
// background-color:#d9534f;
// }
.awx-ToolBarBtn[disabled]:hover {
.awx-ToolBarTrashCanIcon {
color: #d2d2d2;
}
background-color: white;
}
// .awx-ToolBarBtn[disabled]:hover {
// .awx-ToolBarTrashCanIcon {
// color: #d2d2d2;
// }
// background-color: white;
// }
.pf-l-toolbar > div {
&:last-child{
display:none;
}
}
// .pf-l-toolbar > div {
// &:last-child{
// display:none;
// }
// }

View File

@ -1,10 +1,24 @@
import React from 'react';
import { string, func } from 'prop-types';
import { Link } from 'react-router-dom';
import { Button } from '@patternfly/react-core';
import { Button as PFButton } from '@patternfly/react-core';
import { PlusIcon } from '@patternfly/react-icons';
import { I18n } from '@lingui/react';
import { t } from '@lingui/macro';
import styled from 'styled-components';
const Button = styled(PFButton)`
&&& { /* higher specificity order */
background-color: #5cb85c;
min-width: 0;
width: 30px;
height: 30px;
text-align: center;
padding: 0;
margin: 0;
margin-right: 20px;
}
`;
function ToolbarAddButton ({ linkTo, onClick }) {
if (!linkTo && !onClick) {
@ -15,7 +29,7 @@ function ToolbarAddButton ({ linkTo, onClick }) {
return (
<I18n>
{({ i18n }) => (
<Link to={linkTo} className="pf-c-button pf-m-primary">
<Link to={linkTo}>
<Button
variant="primary"
aria-label={i18n._(t`Add`)}

View File

@ -1,12 +1,41 @@
import React, { Fragment } from 'react';
import { func, bool, number, string, arrayOf, shape } from 'prop-types';
import { Button, Tooltip } from '@patternfly/react-core';
import { Button as PFButton, Tooltip } from '@patternfly/react-core';
import { TrashAltIcon } from '@patternfly/react-icons';
import { I18n, i18nMark } from '@lingui/react';
import { Trans, t } from '@lingui/macro';
import styled from 'styled-components';
import AlertModal from '../AlertModal';
import { pluralize } from '../../util/strings';
const Button = styled(PFButton)`
width: 30px;
height: 30px;
display: flex;
justify-content: center;
margin-right: 20px;
border-radius: 3px;
&:disabled {
cursor: not-allowed;
&:hover {
background-color: white;
> svg {
color: #d2d2d2;
}
}
}
&:hover {
background-color:#d9534f;
> svg {
color: white;
}
}
`;
const ItemToDelete = shape({
id: number.isRequired,
name: string.isRequired,
@ -102,13 +131,12 @@ class ToolbarDeleteButton extends React.Component {
position="left"
>
<Button
className="awx-ToolBarBtn"
variant="plain"
aria-label={i18n._(t`Delete`)}
onClick={this.handleConfirmDelete}
isDisabled={isDisabled}
>
<TrashAltIcon className="awx-ToolBarTrashCanIcon" />
<TrashAltIcon />
</Button>
</Tooltip>
{ isModalOpen && (