Skip to content

Commit d60035b

Browse files
authored
feat(settings): updates for space notifications table (#432)
* chore(select): update select component styles * Update select component with latest UI styles * Add support for tiny on netdata table select * chore(netdata table): add support for button on bulk actions * Add support for regular button on table's bulk actions * Update button styles to support strong font weight
1 parent e81c32b commit d60035b

File tree

7 files changed

+87
-34
lines changed

7 files changed

+87
-34
lines changed

src/components/button/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface ButtonWrapperProps extends ButtonProps, MarginProps, PaddingPro
3636
loadingLabel?: string | JSX.Element
3737
loadingIcon?: any
3838
iconColor?: string
39+
strong?: boolean
3940
}
4041

4142
type IconButtonProps = Pick<

src/components/button/styled.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export const StyledButton = styled.button.attrs(props => ({
116116
? getSizeBy(props.small ? 4 : 5)
117117
: getSizeBy(props.tiny ? 2 : props.small ? 3 : 4)};
118118
119-
font-weight: 500;
119+
font-weight: ${({ strong }) => strong ? 700 : 500};
120120
font-size: ${({ small, tiny }) => (tiny ? "10px" : small ? "12px" : "14px")};
121121
line-height: ${getSizeBy(2)};
122122
white-space: nowrap;

src/components/select/index.js

+68-25
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import ReactSelect from "react-select"
22
import styled from "styled-components"
33

4-
export const selectMenusZIndex = 100
5-
64
const makeCustomTheme = theme => selectTheme => {
75
return {
86
...selectTheme,
@@ -27,47 +25,92 @@ const makeCustomTheme = theme => selectTheme => {
2725
}
2826

2927
const getOptionColor = (theme, state) => {
30-
if (state.isDisabled) return theme.colors.border
28+
if (state.isDisabled) return theme.colors.placeholder
3129
if (state.isSelected) return theme.colors.bright
32-
return theme.colors.text
30+
return theme.colors.textDescription
3331
}
3432

35-
const makeCustomStyles = (theme, providedStyles) => ({
36-
option: (styles, state) => ({
33+
const makeCustomStyles = (theme, { size, ...providedStyles } = {}) => ({
34+
control: (styles, state) => ({
3735
...styles,
38-
color: getOptionColor(theme, state),
39-
fontWeight: "normal",
36+
borderColor: state.isFocused ? theme.colors.inputBorderFocus : theme.colors.inputBorder,
37+
boxShadow: "none",
38+
minWidth: 160,
39+
...(size === "tiny" ? { minHeight: 28 } : {}),
40+
":hover": {
41+
borderColor: theme.colors.inputBorderHover,
42+
},
4043
}),
41-
control: styles => ({
44+
input: (styles, state) =>({
4245
...styles,
43-
minWidth: 160,
44-
fontWeight: "normal",
46+
color: state.isDisabled ? theme.colors.placeholder : theme.colors.textDescription,
47+
...(size === "tiny" ? {
48+
lineHeight: "18px",
49+
paddingBottom: 0,
50+
paddingTop: 0
51+
} : {}),
4552
}),
46-
menu: styles => ({
53+
menu: styles => ({ ...styles, zIndex: 100 }),
54+
menuPortal: styles => ({ ...styles, zIndex: 9999 }),
55+
multiValue: (styles) => ({
4756
...styles,
48-
zIndex: selectMenusZIndex,
57+
fontSize: size === "tiny" ? "12px" : "14px",
58+
...(size === "tiny" ? { minHeight: 18 } : {}),
4959
}),
50-
multiValueLabel: (styles, control) => ({
60+
multiValueLabel: (styles, state) => ({
5161
...styles,
52-
paddingRight: control.data.isDisabled ? "8px" : "",
53-
borderRadius: "2px 0 0 2px",
5462
backgroundColor: theme.colors.disabled,
63+
borderRadius: "2px 0 0 2px",
64+
color: state.isDisabled ? theme.colors.placeholder : theme.colors.textDescription,
65+
...(size === "tiny" ? { padding: "1px" } : {}),
66+
paddingRight: state.data.isDisabled ? "8px" : "",
5567
}),
56-
multiValueRemove: (styles, control) =>
57-
control.data.isDisabled
68+
multiValueRemove: (styles, state) => ({
69+
color: state.isDisabled ? theme.colors.placeholder : theme.colors.textDescription,
70+
...(state.data.isDisabled
5871
? { ...styles, display: "none" }
5972
: {
60-
...styles,
61-
color: theme.colors.text,
62-
borderRadius: "0 2px 2px 0",
63-
background: theme.colors.disabled,
64-
":hover": {
65-
background: theme.colors.borderSecondary,
66-
},
73+
...styles,
74+
borderRadius: "0 2px 2px 0",
75+
background: theme.colors.disabled,
76+
":hover": {
77+
background: theme.colors.borderSecondary,
6778
},
79+
}),
80+
}),
81+
option: (styles, state) => ({
82+
...styles,
83+
color: getOptionColor(theme, state),
84+
...(size === "tiny" ? { fontSize: "12px", minHeight: 28, padding: "4px 8px" } : {}),
85+
}),
86+
placeholder: styles => ({
87+
...styles,
88+
color: theme.colors.placeholder,
89+
...(size === "tiny"
90+
? { fontSize: "12px", lineHeight: "18px" }
91+
: {})
92+
}),
93+
singleValue: (styles, state) => ({
94+
...styles,
95+
color: state.isDisabled ? theme.colors.placeholder : theme.colors.textDescription,
96+
fontSize: size === "tiny" ? "12px" : "14px"
97+
}),
98+
...(size === "tiny"
99+
? {
100+
dropdownIndicator: styles => ({ ...styles, padding: "3px" }),
101+
clearIndicator: styles => ({ ...styles, padding: "3px" }),
102+
indicatorsContainer: styles => ({ ...styles, minHeight: 28 }),
103+
valueContainer: styles => ({
104+
...styles,
105+
minHeight: 28,
106+
padding: "1px 6px",
107+
}),
108+
}
109+
: {}),
68110
...providedStyles,
69111
})
70112

113+
// @TODO check react-select for rendering data attributes
71114
export const Select = styled(ReactSelect).attrs(props => ({
72115
...props,
73116
theme: makeCustomTheme(props.theme),

src/components/tableV2/components/action.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Tooltip from "src/components/drops/tooltip"
44
import Flex from "src/components/templates/flex"
55

66
import { ConfirmationDialog } from "src/components/confirmation-dialog"
7-
import { IconButton } from "src/components/button"
7+
import { Button, IconButton } from "src/components/button"
88

99
const Action = forwardRef(
1010
(
@@ -31,6 +31,8 @@ const Action = forwardRef(
3131
iconColor,
3232
flavour = "borderless",
3333
CustomUIAction,
34+
label,
35+
...rest
3436
},
3537
ref
3638
) => {
@@ -55,6 +57,8 @@ const Action = forwardRef(
5557
handleAction?.()
5658
}
5759

60+
const Component = label ? Button : IconButton
61+
5862
return (
5963
<>
6064
{isConfirmationOpen && CustomUIAction && (
@@ -88,13 +92,13 @@ const Action = forwardRef(
8892
ref={ref}
8993
alignItems="center"
9094
justifyContent="center"
91-
_hover={{ background: disabled ? null : "borderSecondary" }}
95+
_hover={{ background: (disabled || label) ? null : "borderSecondary" }}
9296
cursor={disabled ? "auto" : "pointer"}
9397
key={id}
9498
round
95-
background={background}
99+
background={label ? null : background}
96100
>
97-
<IconButton
101+
<Component
98102
iconSize="small"
99103
data-testid={`netdata-table-action-${id}${testPrefix}`}
100104
data-ga={dataGa}
@@ -103,6 +107,8 @@ const Action = forwardRef(
103107
icon={icon}
104108
flavour={flavour}
105109
iconColor={iconColor}
110+
label={label}
111+
{...rest}
106112
/>
107113
</Flex>
108114
</Tooltip>

src/components/tableV2/components/dropdownFilter.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react"
22

33
import { Select } from "src/components/select"
44

5-
const DropdownFilter = ({ onChange, value, options, isMulti }) => {
5+
const DropdownFilter = ({ onChange, value, options, isMulti, styles }) => {
66
const selectedValue = value
77

88
return (
@@ -13,6 +13,7 @@ const DropdownFilter = ({ onChange, value, options, isMulti }) => {
1313
onChange={option => {
1414
onChange(option)
1515
}}
16+
styles={styles}
1617
/>
1718
)
1819
}

src/components/tableV2/components/selectFilter.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import DropdownFilter from "./dropdownFilter"
33

44
const all = { value: "all", label: "All" }
55

6-
const SelectFilter = ({ isMulti = false, column, options = [] }) => {
6+
const SelectFilter = ({ column, isMulti = false, options = [], tiny = false }) => {
77
const { setFilterValue, getFilterValue } = column
88
const filterValue = getFilterValue()
99

@@ -16,6 +16,7 @@ const SelectFilter = ({ isMulti = false, column, options = [] }) => {
1616
isMulti={isMulti}
1717
options={optionsWithExtraChoice}
1818
onChange={value => setFilterValue(value)}
19+
styles={tiny && { size: "tiny" }}
1920
/>
2021
)
2122
}

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ Table.HeadCell = forwardRef(
147147
)}
148148
</Box>
149149
</Flex>
150-
151-
{filter}
150+
<Box sx={{ fontWeight: "normal" }}>
151+
{filter}
152+
</Box>
152153
<Table.Resizer
153154
onMouseDown={onMouseDown}
154155
onTouchStart={onTouchStart}

0 commit comments

Comments
 (0)