Field.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <div>
  3. <div class="field-title" :class="{ 'field-highlighted': isHighlighted }">
  4. {{ fieldName }}
  5. <span v-if="fieldArgs.length > 0">
  6. (
  7. <span v-for="(field, index) in fieldArgs" :key="`field-${index}`">
  8. {{ field.name }}:
  9. <GraphqlTypeLink
  10. :gql-type="field.type"
  11. :jump-type-callback="jumpTypeCallback"
  12. />
  13. <span v-if="index !== fieldArgs.length - 1">, </span>
  14. </span>
  15. ) </span
  16. >:
  17. <GraphqlTypeLink
  18. :gql-type="gqlField.type"
  19. :jump-type-callback="jumpTypeCallback"
  20. />
  21. </div>
  22. <div
  23. v-if="gqlField.description"
  24. class="text-secondaryLight py-2 field-desc"
  25. >
  26. {{ gqlField.description }}
  27. </div>
  28. <div
  29. v-if="gqlField.isDeprecated"
  30. class="
  31. rounded
  32. bg-yellow-200
  33. my-1
  34. text-black
  35. py-1
  36. px-2
  37. inline-block
  38. field-deprecated
  39. "
  40. >
  41. {{ $t("state.deprecated") }}
  42. </div>
  43. <div v-if="fieldArgs.length > 0">
  44. <h5 class="my-2">Arguments:</h5>
  45. <div class="border-divider border-l-2 pl-4">
  46. <div v-for="(field, index) in fieldArgs" :key="`field-${index}`">
  47. <span>
  48. {{ field.name }}:
  49. <GraphqlTypeLink
  50. :gql-type="field.type"
  51. :jump-type-callback="jumpTypeCallback"
  52. />
  53. </span>
  54. <div
  55. v-if="field.description"
  56. class="text-secondaryLight py-2 field-desc"
  57. >
  58. {{ field.description }}
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. import { defineComponent } from "@nuxtjs/composition-api"
  67. export default defineComponent({
  68. props: {
  69. gqlField: { type: Object, default: () => {} },
  70. jumpTypeCallback: { type: Function, default: () => {} },
  71. isHighlighted: { type: Boolean, default: false },
  72. },
  73. computed: {
  74. fieldName() {
  75. return this.gqlField.name
  76. },
  77. fieldArgs() {
  78. return this.gqlField.args || []
  79. },
  80. },
  81. })
  82. </script>
  83. <style scoped lang="scss">
  84. .field-highlighted {
  85. @apply border-b-2 border-accent;
  86. }
  87. .field-title {
  88. @apply select-text;
  89. }
  90. </style>