aboutsummaryrefslogtreecommitdiff
path: root/source/library/components/DocExplorer/FieldView.svelte
blob: 71d215c30641829d0ff6d3b69b5e8745ffe456ca (plain) (blame)
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
<script lang="ts">
  import TypeLink from "./TypeLink.svelte";
  import type { GraphQLField, GraphQLInputField } from "graphql";

  type Props = {
    field: GraphQLField<unknown, unknown> | GraphQLInputField;
    onNavigate: (typeName: string) => void;
  };

  let { field, onNavigate }: Props = $props();

  const args = $derived("args" in field ? field.args : []);
</script>

<style lang="scss">
  .field {
    display: grid;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }

  .heading {
    font-size: 0.95rem;
    font-weight: 600;
  }

  .section-label {
    color: var(--graphiql-muted, #858585);
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
  }

  .description {
    color: var(--graphiql-muted, #858585);
    font-size: 0.8125rem;
    line-height: 1.4;
  }

  .args {
    display: grid;
    gap: 0.375rem;
  }

  .arg {
    font-size: 0.8125rem;
  }

  .arg-name {
    color: var(--graphiql-fg, #d4d4d4);
  }

  .arg-description {
    color: var(--graphiql-muted, #858585);
    font-size: 0.75rem;
    margin-left: 1rem;
    margin-top: 0.125rem;
  }
</style>

<div class="field">
  <div class="heading">{field.name}</div>
  {#if field.description}
    <div class="description">{field.description}</div>
  {/if}
  <div>
    <div class="section-label">Type</div>
    <TypeLink {onNavigate} type={field.type}/>
  </div>
  {#if args.length > 0}
    <div>
      <div class="section-label">Arguments</div>
      <div class="args">
        {#each args as arg}
          <div class="arg">
            <span class="arg-name">{arg.name}</span>:
            <TypeLink {onNavigate} type={arg.type}/>
            {#if arg.description}
              <div class="arg-description">{arg.description}</div>
            {/if}
          </div>
        {/each}
      </div>
    </div>
  {/if}
</div>