Skip to content

Commit e2c6e1d

Browse files
committed
Better props.
1 parent 3415ef5 commit e2c6e1d

File tree

15 files changed

+116
-49
lines changed

15 files changed

+116
-49
lines changed

src/components/drops/drop/container.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ const styledAnimation = css`
1818
animation-delay: 0.01s;
1919
`
2020

21-
const Container = styled(Flex).attrs(({ zIndex = 60 }) => ({ zIndex }))`
22-
position: fixed;
21+
const Container = styled(Flex).attrs(({ zIndex = 60, ...rest }) => ({
22+
zIndex,
23+
position: "fixed",
24+
...rest,
25+
}))`
2326
left: -99999px;
24-
z-index: 36;
2527
2628
${({ animation }) => animation && styledAnimation}
2729
${({ hideShadow }) => !hideShadow && "box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);"}

src/components/input/input.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const TextInput = ({
5858
inputRef,
5959
size = "large",
6060
handleMetaDisplay = defaultHandleMetaDisplay,
61+
inputContainerStyles,
6162
...props
6263
}) => {
6364
const [focused, handleFocus, handleBlur] = useFocusedState({ onBlur, onFocus })
@@ -115,6 +116,7 @@ export const TextInput = ({
115116
success={isSuccess}
116117
error={isError}
117118
disabled={disabled}
119+
{...inputContainerStyles}
118120
>
119121
{iconLeft && <LeftIcon icon={iconLeft} />}
120122
<StyledInput

src/components/pill/alertMastercard.js

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ const AlertMasterCard = forwardRef(
1111
height,
1212
normal,
1313
onClick,
14+
labelProps = {},
1415
pillLeft = {},
1516
pillRight = {},
17+
pillEnd,
1618
round,
1719
size,
1820
...rest
@@ -24,7 +26,8 @@ const AlertMasterCard = forwardRef(
2426
background: masterCardColorMap.alert,
2527
color: "text",
2628
icon: "alarm_bell",
27-
zIndex: 1,
29+
zIndex: 4,
30+
...labelProps,
2831
...commonProps,
2932
}
3033
const pillProps = {
@@ -40,30 +43,44 @@ const AlertMasterCard = forwardRef(
4043
pillRight.background,
4144
pillRight.flavour || "disabledWarning"
4245
)
46+
const pillEndBackground =
47+
pillEnd && getMasterCardBackground(pillEnd.background, pillEnd.flavour || "disabledClear")
48+
4349
const pillLeftProps = {
4450
background: pillLeftBackground,
4551
position: "relative",
4652
margin: [0, 0, 0, -3],
4753
padding: [1, 2, 1, 4],
54+
zIndex: 3,
4855
...pillProps,
4956
...pillLeft,
50-
round: "0 12px 12px 0",
57+
round: labelProps.hidden ? round : "0 12px 12px 0",
5158
}
5259
const pillRightProps = {
5360
background: pillRightBackground,
5461
margin: [0, 0, 0, -3],
5562
padding: [1, 2, 1, 4],
63+
zIndex: 2,
5664
...pillProps,
5765
...pillRight,
5866
}
67+
const pillEndProps = pillEnd && {
68+
background: pillEndBackground,
69+
margin: [0, 0, 0, -3],
70+
padding: [1, 2, 1, 4],
71+
zIndex: 1,
72+
...pillProps,
73+
...pillEnd,
74+
}
5975

6076
return (
6177
<MasterCardContainer data-testid={testId} onClick={onClick} ref={ref} {...commonProps}>
62-
<MasterCardPill data-testid={`${testId}-icon-pill`} {...iconProps} />
63-
<>
64-
<MasterCardPill data-testid={`${testId}-left-pill`} {...pillLeftProps} />
65-
<MasterCardPill data-testid={`${testId}-right-pill`} {...pillRightProps} />
66-
</>
78+
{!labelProps.hidden && (
79+
<MasterCardPill data-testid={`${testId}-icon-pill`} {...iconProps} />
80+
)}
81+
<MasterCardPill data-testid={`${testId}-left-pill`} {...pillLeftProps} />
82+
<MasterCardPill data-testid={`${testId}-right-pill`} {...pillRightProps} />
83+
{pillEndProps && <MasterCardPill data-testid={`${testId}-end-pill`} {...pillEndProps} />}
6784
</MasterCardContainer>
6885
)
6986
}

src/components/pill/mastercard.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const MasterCard = forwardRef(
1818
onClick,
1919
pillLeft = {},
2020
pillRight = {},
21+
pillEnd,
2122
round,
2223
size,
2324
...rest
@@ -26,10 +27,14 @@ const MasterCard = forwardRef(
2627
) => {
2728
const commonProps = { height, round, size }
2829
const pillProps = { normal, ...commonProps, ...rest }
30+
2931
const pillRightBackground = getMasterCardBackground(
3032
pillRight.background,
3133
pillRight.flavour || "disabledWarning"
3234
)
35+
const pillEndBackground =
36+
pillEnd && getMasterCardBackground(pillEnd.background, pillEnd.flavour || "disabledClear")
37+
3338
const pillLeftProps = {
3439
background: getMasterCardBackground(pillLeft.background, pillLeft.flavour || "disabledError"),
3540
padding: [1, 3],
@@ -45,10 +50,17 @@ const MasterCard = forwardRef(
4550
...pillProps,
4651
...pillRight,
4752
}
53+
const pillEndProps = pillEnd && {
54+
background: pillEndBackground,
55+
margin: [0, 0, 0, -1],
56+
padding: [1, 2],
57+
...pillProps,
58+
...pillEnd,
59+
}
4860

4961
return (
5062
<MasterCardContainer
51-
background={pillRightBackground}
63+
background={pillEndBackground || pillRightBackground}
5264
data-testid={testId}
5365
onClick={onClick}
5466
ref={ref}
@@ -58,6 +70,9 @@ const MasterCard = forwardRef(
5870
<>
5971
<MasterCardPill data-testid={`${testId}-left-pill`} {...pillLeftProps} />
6072
<MasterCardPill data-testid={`${testId}-right-pill`} {...pillRightProps} />
73+
{pillEndProps && (
74+
<MasterCardPill data-testid={`${testId}-end-pill`} {...pillEndProps} />
75+
)}
6176
</>
6277
)}
6378
</MasterCardContainer>

src/components/pill/mixins/colors.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const colorMap = {
22
background: {
33
neutral: "nodeBadgeBackground",
44
success: ["green", "netdata"],
5+
clear: ["green", "netdata"],
56
warning: ["yellow", "seaBuckthorn"],
67
error: ["red", "pomegranate"],
78
},
@@ -14,21 +15,25 @@ const colorMap = {
1415
border: {
1516
neutral: "neutralPillBorder",
1617
success: ["green", "deyork"],
18+
clear: ["green", "deyork"],
1719
warning: ["yellow", "seaBuckthorn"],
1820
error: ["red", "apricot"],
1921
},
2022
color: {
2123
neutral: "neutralPillColor",
2224
success: ["green", "netdata"],
25+
clear: ["green", "netdata"],
2326
warning: ["yellow", "seaBuckthorn"],
2427
error: ["red", "apricot"],
2528
},
2629
}
2730

2831
export const masterCardColorMap = {
2932
alert: "alertIcon",
33+
disabledClear: "idleClear",
3034
disabledError: "idleError",
3135
disabledWarning: "idleWarning",
36+
clear: "successLite",
3237
error: "errorLite",
3338
warning: "warningLite",
3439
}

src/components/search/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const Search = forwardRef(({ value, onChange, placeholder, ...rest }, ref) => (
77
value={value}
88
onChange={onChange}
99
placeholder={placeholder}
10-
metaShrinked
1110
size="small"
1211
{...rest}
1312
/>

src/components/tableV2/core/base-table.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ const HeaderCell = styled(Box)`
2525
}
2626
`
2727

28-
const Table = forwardRef(({ children, width, ...props }, ref) => {
29-
return (
30-
<Flex height="100%" width="100%" column>
31-
<Box sx={{ borderCollapse: "separate" }} ref={ref} as="table" width={width} {...props}>
32-
{children}
33-
</Box>
34-
</Flex>
35-
)
36-
})
28+
const Table = forwardRef(({ children, width, ...props }, ref) => (
29+
<Box
30+
sx={{ borderCollapse: "separate", "table-layout": "fixed" }}
31+
ref={ref}
32+
as="table"
33+
width={width}
34+
{...props}
35+
>
36+
{children}
37+
</Box>
38+
))
3739

3840
Table.Head = forwardRef(({ children, ...props }, ref) => (
3941
<Box
@@ -96,7 +98,6 @@ Table.HeadCell = forwardRef(
9698
children,
9799
align = "left",
98100
width,
99-
minWidth,
100101
tooltipText,
101102
filter,
102103
onMouseDown,
@@ -120,8 +121,9 @@ Table.HeadCell = forwardRef(
120121
fontSize: "14px",
121122
}}
122123
position="relative"
124+
overflow="hidden"
123125
padding={[1, 2]}
124-
width={{ min: `${minWidth}px`, max: `${width}px`, base: `${width}px` }}
126+
width={`${width}px`}
125127
onMouseEnter={() => onHover({ row: null, column: id })}
126128
onMouseLeave={() => onHover()}
127129
height="60px"
@@ -280,16 +282,12 @@ Table.Cell = forwardRef(
280282
textAlign: align,
281283
whiteSpace: "nowrap",
282284
}}
283-
width={{
284-
base: `${width || maxWidth}px`,
285-
max: `${width || maxWidth}px`,
286-
min: `${minWidth}px`,
287-
}}
285+
width={`${width}px`}
288286
overflow="hidden"
289287
{...rest}
290288
background={
291289
!rest.background && isRowHovering
292-
? "borderSecondary"
290+
? "elementBackground"
293291
: rest.background || (index % 2 == 0 ? "mainBackground" : "tableRowBg")
294292
}
295293
backgroundOpacity={

src/components/tableV2/core/rows.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from "react"
1+
import React, { useEffect, useMemo } from "react"
22
import { useVirtualizer } from "@tanstack/react-virtual"
33
import { flexRender } from "@tanstack/react-table"
44
import { useTableContext } from "../features/provider"
@@ -49,8 +49,11 @@ const Rows = ({
4949
const paddingTop = virtualRows.length > 0 ? virtualRows?.[0]?.start || 0 : 0
5050

5151
const totalHeight = virtualizer.getTotalSize()
52-
const paddingBottom =
53-
virtualRows.length > 0 ? totalHeight - (virtualRows?.[virtualRows.length - 1]?.end || 0) : 0
52+
const paddingBottom = useMemo(
53+
() =>
54+
virtualRows.length > 0 ? totalHeight - (virtualRows?.[virtualRows.length - 1]?.end || 0) : 0,
55+
[virtualRows.length]
56+
)
5457

5558
return (
5659
<>
@@ -59,7 +62,7 @@ const Rows = ({
5962
<td style={{ height: `${paddingTop}px` }} />
6063
</tr>
6164
)}
62-
{virtualizer.getVirtualItems().map(virtualRow => {
65+
{virtualRows.map(virtualRow => {
6366
const row = rows[virtualRow.index]
6467
const cells = row[getRowHandler]()
6568

src/components/tableV2/features/globalControls.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react"
1+
import React, { memo } from "react"
22
import Flex from "src/components/templates/flex"
33
import SearchInput from "src/components/search"
44
import { Icon } from "src/components/icon"
@@ -13,6 +13,9 @@ const GlobalControls = ({
1313
tableMeta,
1414
}) => {
1515
const wordsCount = searchValue?.split(" ").filter(x => !!x).length
16+
17+
tableMeta = typeof tableMeta === "function" ? tableMeta({}, {}, null) : tableMeta
18+
1619
return (
1720
<Flex
1821
width="100%"
@@ -46,4 +49,4 @@ const GlobalControls = ({
4649
)
4750
}
4851

49-
export default GlobalControls
52+
export default memo(GlobalControls)

src/components/tableV2/features/useRowSelection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default (enabled, { testPrefix, tableMeta }) =>
3030
/>
3131
),
3232
enableColumnFilter: false,
33-
enableSorting: tableMeta?.enableSelectionSorting || false,
33+
enableSorting: false,
3434
size: width,
3535
maxSize: width,
3636
minSize: width,

0 commit comments

Comments
 (0)