Skip to content

Commit

Permalink
Temporary fix for EuiCard[selectable][layout=horizontal] instances on…
Browse files Browse the repository at this point in the history
… osquery live query and canvas's datasource selector
  • Loading branch information
Chandler Prall committed Nov 5, 2022
1 parent 7832378 commit 3045da6
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,49 @@
*/

import React from 'react';
import { css } from '@emotion/css';
import PropTypes from 'prop-types';
import { EuiCard, EuiIcon } from '@elastic/eui';

export const DatasourceSelector = ({ onSelect, datasources, current }) => (
<div className="canvasDataSource__list">
{datasources.map((d) => (
<EuiCard
key={d.name}
title={d.displayName}
titleElement="h5"
titleSize="xs"
icon={<EuiIcon type={d.image} size="l" />}
description={d.help}
layout="horizontal"
className="canvasDataSource__card"
selectable={{
isSelected: d.name === current ? true : false,
onClick: () => onSelect(d.name),
}}
/>
))}
</div>
);
export const DatasourceSelector = ({ onSelect, datasources, current }) => {
// TODO: custom css shouldn't be necessary after https://github.com/elastic/eui/issues/6345
// tested this placeholder fix on mac in Chrome, Firefox, Safari, and Edge
// with multiple zoom levels and with keyboard <tab> navigation
// and in a responsive design / mobile view
const cardStyles = css`
padding-bottom: 60px;
position: relative;
button {
position: absolute;
left: 0;
right: 0;
bottom: 0;
border-radius: 0;
}
`;

return (
<div className="canvasDataSource__list">
{datasources.map((d) => (
<EuiCard
key={d.name}
title={d.displayName}
titleElement="h5"
titleSize="xs"
icon={<EuiIcon type={d.image} size="l" />}
description={d.help}
layout="horizontal"
className={`canvasDataSource__card ${cardStyles}`}
selectable={{
isSelected: d.name === current ? true : false,
onClick: () => onSelect(d.name),
}}
/>
))}
</div>
);
}

DatasourceSelector.propTypes = {
onSelect: PropTypes.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ import { i18n } from '@kbn/i18n';
import styled from 'styled-components';

const StyledEuiCard = styled(EuiCard)`
/*
TODO: this css shouldn't be necessary after https://github.com/elastic/eui/issues/6345
tested this placeholder fix on mac in Chrome, Firefox, Safari, and Edge
with multiple zoom levels and with keyboard <tab> navigation
and in a responsive design / mobile view
*/
padding-bottom: 60px;
position: relative;
button {
position: absolute;
bottom: 0;
}
/* end todo css */
padding: 16px 92px 16px 16px !important;
.euiTitle {
Expand Down

0 comments on commit 3045da6

Please sign in to comment.