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

teableio / teable / 8538004962

03 Apr 2024 11:36AM CUT coverage: 18.233% (-3.3%) from 21.535%
8538004962

Pull #528

github

web-flow
Merge c1a248a6f into 45ee7ebb3
Pull Request #528: feat: Kanban view

575 of 1136 branches covered (50.62%)

29 of 2908 new or added lines in 83 files covered. (1.0%)

5 existing lines in 5 files now uncovered.

6439 of 35315 relevant lines covered (18.23%)

3.94 hits per line

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

0.0
/packages/sdk/src/components/cell-value/cell-rating/CellRating.tsx
NEW
1
import type { IRatingFieldOptions } from '@teable/core';
×
NEW
2
import { ColorUtils, RatingIcon } from '@teable/core';
×
NEW
3
import { Star, Moon, Sun, Zap, Flame, Heart, Apple, ThumbsUp } from '@teable/icons';
×
NEW
4
import { cn } from '@teable/ui-lib';
×
NEW
5
import type { ICellValue } from '../type';
×
NEW
6

×
NEW
7
export const RATING_ICON_MAP = {
×
NEW
8
  [RatingIcon.Star]: Star,
×
NEW
9
  [RatingIcon.Moon]: Moon,
×
NEW
10
  [RatingIcon.Sun]: Sun,
×
NEW
11
  [RatingIcon.Zap]: Zap,
×
NEW
12
  [RatingIcon.Flame]: Flame,
×
NEW
13
  [RatingIcon.Heart]: Heart,
×
NEW
14
  [RatingIcon.Apple]: Apple,
×
NEW
15
  [RatingIcon.ThumbUp]: ThumbsUp,
×
NEW
16
};
×
NEW
17

×
NEW
18
interface ICellRating extends ICellValue<number> {
×
NEW
19
  options: IRatingFieldOptions;
×
NEW
20
  itemClassName?: string;
×
NEW
21
}
×
NEW
22

×
NEW
23
export const CellRating = (props: ICellRating) => {
×
NEW
24
  const { value, options, className, style, itemClassName } = props;
×
NEW
25
  const { icon, color: colorKey, max } = options;
×
NEW
26
  const Icon = RATING_ICON_MAP[icon];
×
NEW
27
  const color = ColorUtils.getHexForColor(colorKey);
×
NEW
28

×
NEW
29
  return (
×
NEW
30
    <div className={cn('flex', className)} style={style}>
×
NEW
31
      {Array.from({ length: max }).map((_, index) => {
×
NEW
32
        let iconStyle = {};
×
NEW
33

×
NEW
34
        if (value != null && index < value) {
×
NEW
35
          iconStyle = { fill: color, color };
×
NEW
36
        }
×
NEW
37

×
NEW
38
        return (
×
NEW
39
          <Icon
×
NEW
40
            key={index}
×
NEW
41
            className={cn(
×
NEW
42
              'size-4 mr-1 rounded cursor-pointer text-slate-200 fill-slate-200 dark:text-gray-700 dark:fill-gray-700',
×
NEW
43
              value != null && index < value && 'fill',
×
NEW
44
              itemClassName
×
NEW
45
            )}
×
NEW
46
            style={iconStyle}
×
NEW
47
          />
×
NEW
48
        );
×
NEW
49
      })}
×
NEW
50
    </div>
×
NEW
51
  );
×
NEW
52
};
×
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