Field.vue 2.1 KB

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