Skip to content

Commit 1be280c

Browse files
committed
chore: code review
1 parent 6650cf4 commit 1be280c

File tree

6 files changed

+38
-34
lines changed

6 files changed

+38
-34
lines changed

packages/notifications/src/elements/content/Close.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import React, { ButtonHTMLAttributes } from 'react';
99
import { StyledClose } from '../../styled';
1010
import { useNotificationsContext } from '../../utils/useNotificationsContext';
1111
import { useText } from '@zendeskgarden/react-theming';
12-
import XStrokeIcon from '@zendeskgarden/svg-icons/src/12/x-stroke.svg';
12+
import XStrokeIcon from '@zendeskgarden/svg-icons/src/16/x-stroke.svg';
1313

1414
/**
1515
* @deprecated use `Alert.Close` or `Notification.Close` instead

packages/notifications/src/elements/global-alert/GlobalAlertButton.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ export const GlobalAlertButton = forwardRef<HTMLButtonElement, IGlobalAlertButto
2323
ref={ref}
2424
$alertType={type}
2525
{...props}
26-
focusInset={false}
27-
isDanger={false}
28-
isLink={false}
29-
isNeutral={false}
30-
isPill={false}
31-
isStretched={false}
3226
size="small"
3327
isPrimary={!isBasic}
3428
isBasic={isBasic}

packages/notifications/src/styled/StyledBase.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,8 @@ export interface IStyledBaseProps extends ThemeProps<DefaultTheme> {
2222
$type?: Type;
2323
}
2424

25-
const boxShadow = (props: IStyledBaseProps) => {
26-
const { theme } = props;
27-
const { space, shadows, opacity } = theme;
28-
const offsetY = `${space.base * 5}px`;
29-
const blurRadius = `${space.base * 7}px`;
30-
const color = getColor({
31-
hue: 'neutralHue',
32-
shade: 1200,
33-
light: { transparency: opacity[200] },
34-
dark: { transparency: opacity[1000] },
35-
theme
36-
});
37-
38-
return shadows.lg(offsetY, blurRadius, color as string);
39-
};
40-
4125
const colorStyles = ({ theme, $type, $isFloating }: IStyledBaseProps) => {
26+
const { space, shadows, opacity } = theme;
4227
let bgVariable;
4328
let borderVariable;
4429
let fgVariable;
@@ -76,8 +61,21 @@ const colorStyles = ({ theme, $type, $isFloating }: IStyledBaseProps) => {
7661
const borderColor = getColor({ variable: borderVariable, theme });
7762
const foregroundColor = getColor({ variable: fgVariable, theme });
7863

64+
const offsetY = `${space.base * 5}px`;
65+
const blurRadius = `${space.base * 7}px`;
66+
const color = getColor({
67+
hue: 'neutralHue',
68+
shade: 1200,
69+
light: { transparency: opacity[200] },
70+
dark: { transparency: opacity[1000] },
71+
theme
72+
});
73+
74+
const boxShadow = shadows.lg(offsetY, blurRadius, color);
75+
7976
return css`
8077
border-color: ${borderColor};
78+
box-shadow: ${$isFloating && boxShadow};
8179
background-color: ${backgroundColor};
8280
color: ${foregroundColor};
8381
`;
@@ -98,7 +96,6 @@ export const StyledBase = styled.div.attrs({
9896
position: relative;
9997
border: ${props => props.theme.borders.sm};
10098
border-radius: ${props => props.theme.borderRadii.md};
101-
box-shadow: ${props => props.$isFloating && boxShadow};
10299
padding: ${padding};
103100
line-height: ${props => getLineHeight(props.theme.space.base * 5, props.theme.fontSizes.md)};
104101
font-size: ${props => props.theme.fontSizes.md};

packages/notifications/src/styled/StyledIcon.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,28 @@ const sizeStyles = ({ theme: { rtl, space } }: IStyledIconProps) => {
3030
};
3131

3232
const colorStyles = ({ theme, $type }: IStyledIconProps) => {
33-
let color;
33+
let variable;
3434

3535
switch ($type) {
3636
case validationTypes.success:
37-
color = getColor({ variable: 'foreground.success', theme });
37+
variable = 'foreground.success';
3838
break;
3939
case validationTypes.error:
40-
color = getColor({ variable: 'foreground.danger', theme });
40+
variable = 'foreground.danger';
4141
break;
4242
case validationTypes.warning:
43-
color = getColor({ variable: 'foreground.warning', theme });
43+
variable = 'foreground.warning';
4444
break;
4545
case validationTypes.info:
46-
color = getColor({ variable: 'foreground.subtle', theme });
46+
variable = 'foreground.subtle';
47+
break;
48+
default:
49+
variable = 'foreground.default';
4750
break;
4851
}
4952

53+
const color = getColor({ variable, theme });
54+
5055
return css`
5156
color: ${color};
5257
`;

packages/notifications/src/styled/StyledWell.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* found at http://www.apache.org/licenses/LICENSE-2.0.
66
*/
77

8-
import styled from 'styled-components';
8+
import styled, { ThemeProps, css, DefaultTheme } from 'styled-components';
99
import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
1010
import { StyledBase } from './StyledBase';
1111

@@ -15,16 +15,24 @@ export interface IStyledWellProps {
1515
$isRecessed?: boolean;
1616
}
1717

18+
const colorStyles = ({ theme, $isRecessed }: IStyledWellProps & ThemeProps<DefaultTheme>) => {
19+
const foreground = getColor({ variable: 'foreground.subtle', theme });
20+
const background = $isRecessed && getColor({ variable: 'background.recessed', theme });
21+
22+
return css`
23+
background-color: ${background};
24+
color: ${foreground};
25+
`;
26+
};
27+
1828
/**
1929
* Supports all `<div>` props
2030
*/
2131
export const StyledWell = styled(StyledBase).attrs({
2232
'data-garden-id': COMPONENT_ID,
2333
'data-garden-version': PACKAGE_VERSION
2434
})<IStyledWellProps>`
25-
background-color: ${p =>
26-
p.$isRecessed && getColor({ variable: 'background.recessed', theme: p.theme })};
27-
color: ${p => getColor({ variable: 'foreground.subtle', theme: p.theme })};
35+
${colorStyles}
2836
2937
${p => retrieveComponentStyles(COMPONENT_ID, p)};
3038
`;

packages/notifications/src/utils/icons.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const validationIcons: Record<Type, Record<string, unknown>> = {
1818
info: InfoStrokeIcon
1919
};
2020

21-
export const validationTypes: Record<Type, string> = {
21+
export const validationTypes: Record<Type, Type> = {
2222
success: 'success',
2323
error: 'error',
2424
warning: 'warning',

0 commit comments

Comments
 (0)