File size: 2,883 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import type { OriginalStackFrame } from '../../../shared/stack-frame'

import { CallStackFrame } from '../call-stack-frame/call-stack-frame'
import { ChevronUpDownIcon } from '../../icons/chevron-up-down'
import { css } from '../../utils/css'

export function CallStack({
  frames,
  isIgnoreListOpen,
  ignoredFramesTally,
  onToggleIgnoreList,
}: {
  frames: OriginalStackFrame[]
  isIgnoreListOpen: boolean
  ignoredFramesTally: number
  onToggleIgnoreList: () => void
}) {
  return (
    <div data-nextjs-call-stack-container>
      <div data-nextjs-call-stack-header>
        <p data-nextjs-call-stack-title>
          Call Stack <span data-nextjs-call-stack-count>{frames.length}</span>
        </p>
        {ignoredFramesTally > 0 && (
          <button
            // The isIgnoreListOpen value is used by tests to confirm whether it is open or not.
            data-nextjs-call-stack-ignored-list-toggle-button={isIgnoreListOpen}
            onClick={onToggleIgnoreList}
          >
            {`${isIgnoreListOpen ? 'Hide' : 'Show'} ${ignoredFramesTally} ignore-listed frame(s)`}
            <ChevronUpDownIcon />
          </button>
        )}
      </div>
      {frames.map((frame, frameIndex) => {
        return !frame.ignored || isIgnoreListOpen ? (
          <CallStackFrame key={frameIndex} frame={frame} />
        ) : null
      })}
    </div>
  )
}

export const CALL_STACK_STYLES = css`
  [data-nextjs-call-stack-container] {
    position: relative;
    margin-top: 8px;
  }

  [data-nextjs-call-stack-header] {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: var(--size-28);
    padding: 8px 8px 12px 4px;
    width: 100%;
  }

  [data-nextjs-call-stack-title] {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;

    margin: 0;

    color: var(--color-gray-1000);
    font-size: var(--size-16);
    font-weight: 500;
  }

  [data-nextjs-call-stack-count] {
    display: flex;
    justify-content: center;
    align-items: center;

    width: var(--size-20);
    height: var(--size-20);
    gap: 4px;

    color: var(--color-gray-1000);
    text-align: center;
    font-size: var(--size-11);
    font-weight: 500;
    line-height: var(--size-16);

    border-radius: var(--rounded-full);
    background: var(--color-gray-300);
  }

  [data-nextjs-call-stack-ignored-list-toggle-button] {
    all: unset;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--color-gray-900);
    font-size: var(--size-14);
    line-height: var(--size-20);
    border-radius: 6px;
    padding: 4px 6px;
    margin-right: -6px;
    transition: background 150ms ease;

    &:hover {
      background: var(--color-gray-100);
    }

    &:focus {
      outline: var(--focus-ring);
    }

    svg {
      width: var(--size-16);
      height: var(--size-16);
    }
  }
`