Kongponents Component Library

repository·main·Indexed 41 days ago

https://github.com/kong/kongponents

A generic Vue component library of UI elements designed for use in any web application, originally built for Kong's internal needs. Version 9.64.18.

Tokens
106.1K
Snippets
360
Records
476
Agent score
50%

What's inside Kongponents

  1. Overview of Kongponents

    main

    Kongponents is a Vue-powered component library designed to provide powerful, lightweight, and reusable UI components. While developed for Kong, the library is designed to be usable by all developers.

    Key features include:

    • Vue 3 and TypeScript: Built with Vue 3 and TypeScript for improved autocompletion and Devtools support.
    • Themeable: Many components support customization via CSS variables, enabling both global styling and scoped overrides.
    • Open Source: The project is open-source and welcomes community contributions.
  2. Use KInput for text inputs

    main

    KInput is a wrapper around general text inputs that provides contextual styling and states such as error, focus, and disabled. It supports standard HTML input types like text, password, number, email, search, etc., via attribute binding.

    <KInput placeholder="Placeholder text" />
  3. Use KDropdown for fly-out menus

    main

    The KDropdown component provides a button (or custom slotted content) that triggers a fly-out menu popover. By default, the trigger is a KButton using the trigger-text prop, but you can provide custom UI via the default slot.

    <KDropdown trigger-text="Documentation" :items="items" />
  4. Use KDateTimePicker for date and time selection

    main

    The KDateTimePicker component is a widget used to select dates, times, or ranges of time, displayed within a popover. It supports various modes ranging from simple date selection to complex relative time frames.

    <KDateTimePicker v-model="currentValue" mode="dateTime" />
  5. Use KCard to organize content

    main

    KCard is a styled container component used to organize related content and actions. It can be used as a simple wrapper for content or as a structured container with a title, action elements, and a footer.

    <KCard>
      <template #title>
        Card Title
      </template>
      <template #actions>
        <KButton appearance="tertiary" icon size="small">
          <MoreIcon />
        </KButton>
      </template>
      Card body content goes here.
      <template #footer>
        <KBadge appearance="success">Published</KBadge>
      </template>
    </KCard>
  6. Use KTextArea for text input

    main

    KTextArea is a wrapper around the standard HTML <textarea> element. It provides contextual styling and states such as error, focus, and required indicators. It supports two-way data binding via v-model and allows for custom labeling and help text.

    <KTextArea />
  7. What is KPrompt and when to use it

    main

    KPrompt is a pop-up window component used to temporarily interrupt user interaction, typically to require explicit confirmation before proceeding with a sensitive action. It is built on top of KModal.

    When to use KModal instead of KPrompt:

    • When you need to display information without requiring user input/interaction.
    • When you need to customize the appearance of elements (e.g., hiding the title or providing custom footer content).
    • When you require a custom modal layout that differs from the default (header, content, footer) structure.
  8. Best practices for typing Vue component props

    main

    When defining types for Vue component props, follow these guidelines to improve type safety and developer experience:

    • Use String Literal Types instead of String: For props with a fixed set of allowed values (e.g., a mode prop), define them as specific literals (e.g., light | dark | none) rather than the generic String type.
    • Avoid Object types: Do not use the generic Object type for props. Instead, define a specific interface that describes the object's structure.
  9. How KPagination handles neighbors and overflow

    main

    The neighbors prop determines how many neighboring pages are visible to the left and right of the center page when ellipsis are present. The default is 1.

    Note on Overflow: If KPagination detects horizontal overflow within its parent container, it will automatically reduce the number of displayed neighbors to fit the container, ensuring it never overflows. It will always display at least 1 neighbor, even if the neighbors prop is set to a higher value.

    <KPagination :neighbors="2" :total-count="1000" />