• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zendeskgarden / react-components / 180f4396-9708-4f9d-9976-168ae8d5da2c

25 Jun 2024 09:12PM UTC coverage: 96.019% (-0.02%) from 96.043%
180f4396-9708-4f9d-9976-168ae8d5da2c

Pull #1842

circleci

geotrev
chore: force light mode, remove dark offsets, simplify tests
Pull Request #1842: feat(notifications): new light/dark mode colors

3336 of 3691 branches covered (90.38%)

Branch coverage included in aggregate %.

239 of 243 new or added lines in 24 files covered. (98.35%)

1 existing line in 1 file now uncovered.

10145 of 10349 relevant lines covered (98.03%)

213.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/packages/notifications/src/styled/StyledIcon.ts
1
/**
2
 * Copyright Zendesk, Inc.
3
 *
4
 * Use of this source code is governed under the Apache License, Version 2.0
5
 * found at http://www.apache.org/licenses/LICENSE-2.0.
6
 */
7

8
import styled, { DefaultTheme, ThemeProps, css } from 'styled-components';
17✔
9
import {
10
  getColor,
11
  DEFAULT_THEME,
12
  StyledBaseIcon,
13
  retrieveComponentStyles
14
} from '@zendeskgarden/react-theming';
17✔
15
import { Type } from '../types';
16
import { validationTypes } from '../utils/icons';
17✔
17

18
const COMPONENT_ID = 'notifications.icon';
17✔
19

20
interface IStyledIconProps extends ThemeProps<DefaultTheme> {
21
  $type?: Type;
22
}
23

24
const sizeStyles = ({ theme: { rtl, space } }: IStyledIconProps) => {
17✔
25
  return css`
22✔
26
    right: ${rtl && `${space.base * 4}px`};
22!
27
    left: ${!rtl && `${space.base * 4}px`};
44✔
28
    margin-top: ${space.base / 2}px;
29
  `;
30
};
31

32
const colorStyles = ({ theme, $type }: IStyledIconProps) => {
17✔
33
  let variable;
34

35
  switch ($type) {
22!
36
    case validationTypes.success:
37
      variable = 'foreground.success';
6✔
38
      break;
6✔
39
    case validationTypes.error:
40
      variable = 'foreground.danger';
6✔
41
      break;
6✔
42
    case validationTypes.warning:
43
      variable = 'foreground.warning';
4✔
44
      break;
4✔
45
    case validationTypes.info:
46
      variable = 'foreground.subtle';
6✔
47
      break;
6✔
48
    default:
NEW
49
      variable = 'foreground.default';
×
NEW
50
      break;
×
51
  }
52

53
  const color = getColor({ variable, theme });
22✔
54

55
  return css`
22✔
56
    color: ${color};
57
  `;
58
};
59

60
export const StyledIcon = styled(StyledBaseIcon).attrs({
22✔
61
  'data-garden-id': COMPONENT_ID,
62
  'data-garden-version': PACKAGE_VERSION
63
})<IStyledIconProps>`
64
  position: absolute;
65

66
  ${sizeStyles}
67
  ${colorStyles}
68

69
  ${props => retrieveComponentStyles(COMPONENT_ID, props)}
22✔
70
`;
71

72
StyledIcon.defaultProps = {
17✔
73
  theme: DEFAULT_THEME
74
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc