Files
fleet/frontend/components/TableContainer/DataTable/_styles.scss
T

447 lines
11 KiB
SCSS
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
$shadow-width: 40px;
$shadow-transition-width: 16px;
.data-table-block {
position: relative;
display: inline-block;
width: 100%;
.data-table {
&__wrapper {
position: relative;
border: 1px solid $ui-fleet-black-10;
border-radius: 6px;
flex-grow: 1;
width: 100%;
// Wide tables scroll horizontally within the table wrapper rather than
// pushing the document past the viewport. The shadow backgrounds below
// were already engineered for horizontal scrolling.
overflow-x: auto;
// Shadow
background-image:
/* Shadows */ linear-gradient(
to right,
$core-fleet-white,
$core-fleet-white-transparent
),
linear-gradient(
to left,
$core-fleet-white,
$core-fleet-white-transparent
),
/* Shadow covers */
linear-gradient(
to right,
$ui-shadow,
$core-fleet-white $shadow-transition-width
),
linear-gradient(
to left,
$ui-shadow,
$core-fleet-white $shadow-transition-width
);
background-position: left center, right center, left center, right center;
background-repeat: no-repeat;
background-color: $core-fleet-white;
background-size: $shadow-width 100%, $shadow-width 100%, 50% 100%,
50% 100%;
/* Opera doesn't support this in the shorthand */
background-attachment: local, local, scroll, scroll;
// End shadow
}
// applied to same element as data-table__table while loading
&__no-rows {
min-height: 272px;
}
&__table {
position: relative;
width: 100%;
border-collapse: collapse;
color: $ui-fleet-black-75;
font-size: $x-small;
}
tr {
border-bottom: 1px solid $ui-fleet-black-10;
&:last-child {
border-bottom: 0;
}
// override styles of checkbox data cells
.form-field--checkbox {
display: flex;
justify-content: center;
margin-bottom: 0;
.fleet-checkbox__label {
padding-left: 0;
}
}
// Cleaner when tabbing
a:focus-visible {
outline-offset: 0;
border-radius: $border-radius-medium;
}
}
thead {
background-color: $ui-off-white-opaque; // opaque needed for horizontal scroll shadow
color: $core-fleet-black;
text-align: left;
border-bottom: 1px solid $ui-fleet-black-10;
// resize header icons
img {
width: 16px;
height: 16px;
vertical-align: top;
}
// do not resize button icons inside headers
.button {
img {
width: initial;
height: initial;
vertical-align: initial;
}
}
th {
padding: 0 $table-cell-padding;
white-space: nowrap;
border-left: 1px solid $ui-fleet-black-10;
font-weight: $bold;
font-size: $xx-small;
height: 40px; // Match body row height
&:first-child {
border-top-left-radius: 6px;
border-left: none;
}
&.selection__header,
&.active-selection__checkbox {
width: 16px;
padding: 0 $pad-medium;
}
&:last-child {
border-top-right-radius: 6px;
}
&.actions__header {
border-left: none;
width: 99px;
}
&.linkToFilteredHosts__header,
&.view-all-hosts__header // Same as linkToFilteredHosts__header on some pages
{
border-left: none;
width: 120px;
}
.column-header {
display: flex;
flex-direction: column; // Filters under header name
min-width: max-content;
font-weight: $bold;
// Targets only HeaderCell's wrapper span (direct child of
// `.header-cell`), not arbitrary descendant spans. Previously
// `.column-header span` matched every descendant, leaking
// `display: flex` onto nested suffix/decoration spans like
// `.resolved-suffix` and turning them block-level.
.header-cell > span {
display: flex;
align-items: center;
gap: $gap-icon-text;
}
}
.header-cell {
font-weight: $bold;
}
// Sort arrows change color on hover
.sortable-header {
.column-header {
.header-cell {
min-height: 32px; // Leave room for outline on keyboard focus
}
}
&:hover {
.header-cell:not(.ascending) {
.ascending-arrow {
border-bottom-color: $ui-fleet-black-50;
}
}
.header-cell.ascending {
.descending-arrow {
border-top-color: $ui-fleet-black-50;
}
}
}
}
}
&.active-selection {
background: none;
z-index: 1;
th {
border: 0;
}
.fleet-checkbox {
opacity: 0;
}
.active-selection__container {
background-color: $ui-off-white;
width: 100% !important; // Too much specificity currently at page-level styling. Revisit after data table CSS update to remove !important.
.active-selection__inner {
justify-content: flex-start;
}
}
}
}
.active-selection {
position: absolute;
top: 0px;
width: 100%;
border: 0;
border-radius: 6px;
&__checkbox {
width: 16px;
}
&__container {
padding: 0 $table-cell-padding;
}
&__inner {
display: flex;
justify-content: space-between;
align-items: center;
gap: $gap-table-elements;
p {
margin: 0;
font-weight: $regular;
span {
font-weight: $bold;
}
}
}
&__inner-left,
&__inner-right {
display: flex;
align-items: center;
gap: $gap-table-elements;
}
}
tbody {
.component__tooltip-wrapper__element {
white-space: initial; // wraps long text with tooltip
}
tr,
.single-row {
transition: background-color 150ms ease-out;
&:hover {
background-color: $ui-off-white-opaque; // opaque needed for horizontal scroll shadow
}
&:focus-visible {
outline: 1px solid $core-focused-outline;
background: $ui-off-white;
border-radius: $border-radius;
}
}
// Round the last row's bottom corners so its background doesn't overflow
// the wrapper's rounded corners (visible in dark mode where row and
// wrapper backgrounds differ).
tr:last-child {
td:first-child {
border-bottom-left-radius: $border-radius-medium;
}
td:last-child {
border-bottom-right-radius: $border-radius-medium;
}
}
.single-row {
&:hover {
cursor: pointer;
}
}
.clickable-row {
&:hover {
cursor: pointer;
}
}
td {
height: 40px;
padding: 0 $table-cell-padding;
max-width: 500px;
word-wrap: break-word;
&.actions__cell {
// Keep the cell as table-cell (not display:flex) so the bottom-right
// border-radius of the last row renders cleanly. Right-align the
// dropdown by making its wrapper inline-flex.
text-align: right;
max-width: 99px;
.actions-dropdown__wrapper {
display: inline-flex;
// Reset cell's right-align so menu option text stays left-aligned.
text-align: left;
}
}
&.linkToFilteredHosts__cell,
&.view-all-hosts__cell // Same as linkToFilteredHosts__cell on some pages
{
text-align: right;
max-width: 140px;
// display: flex causes layout issues on /software/vulnerabilities table
align-items: center;
}
&.selection__cell {
width: 0px;
padding: 0 $pad-medium;
}
.link-cell,
.text-cell {
display: block; // inline-block is not vertically centered
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin: 0;
.__react_component_tooltip {
white-space: normal;
}
}
.link-cell {
display: inline-block;
overflow: visible;
@include link;
&:hover {
text-decoration: underline;
text-underline-offset: 3px;
}
> div {
display: flex;
align-items: center;
gap: $pad-small;
white-space: nowrap;
text-overflow: ellipsis;
}
.truncated-tooltip {
font-weight: $regular;
}
}
// css to properly style link-cell with tooltip
.link-cell-tooltip-wrapper {
overflow: visible; // fixes tooltip overflow cut off by cell
white-space: nowrap; // single line
margin: 0; // padding applied to .link-cell for larger clickable area
.component__tooltip-wrapper {
&__element {
display: block;
white-space: nowrap; // single line
text-overflow: ellipsis; // truncates text
overflow: hidden;
// TODO this naming is now confusing, as this .link-cell is not the outermost layer of
// the cell it's a NameCell
.link-cell {
padding: 0;
}
}
&__tip-text {
cursor: auto;
}
}
}
.w400 {
max-width: 352px; // 400px - 48px padding
min-width: 100%;
text-align: left;
}
.w250 {
max-width: 202px; // 250px - 48px padding
min-width: 100%;
text-align: left;
}
.w150 {
max-width: 102px; // 250px - 48px padding
min-width: 100%;
text-align: left;
}
.italic-cell {
font-style: italic;
// old react tooltip version
.__react_component_tooltip,
// new react tooltip version
.react-tooltip {
font-style: normal;
}
}
.grey-cell {
color: $ui-fleet-black-75;
}
}
.disable-highlight:hover {
background-color: initial;
}
}
}
.loading-overlay {
display: flex;
flex-grow: 1;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: $loading-overlay;
z-index: 1;
}
&__footer {
display: flex;
align-items: center;
height: 50px; // Match pagination height as pagination is optionally rendered
}
&__table-help-text {
font-size: $x-small;
display: flex;
align-items: center;
}
}