progress.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { Progress as Kobalte } from "@kobalte/core/progress"
  2. import { Show, splitProps } from "solid-js"
  3. import type { ComponentProps, ParentProps } from "solid-js"
  4. export interface ProgressProps extends ParentProps<ComponentProps<typeof Kobalte>> {
  5. hideLabel?: boolean
  6. showValueLabel?: boolean
  7. }
  8. export function Progress(props: ProgressProps) {
  9. const [local, others] = splitProps(props, ["children", "class", "classList", "hideLabel", "showValueLabel"])
  10. return (
  11. <Kobalte
  12. {...others}
  13. data-component="progress"
  14. classList={{
  15. ...(local.classList ?? {}),
  16. [local.class ?? ""]: !!local.class,
  17. }}
  18. >
  19. <Show when={local.children || local.showValueLabel}>
  20. <div data-slot="progress-header">
  21. <Show when={local.children}>
  22. <Kobalte.Label data-slot="progress-label" classList={{ "sr-only": local.hideLabel }}>
  23. {local.children}
  24. </Kobalte.Label>
  25. </Show>
  26. <Show when={local.showValueLabel}>
  27. <Kobalte.ValueLabel data-slot="progress-value-label" />
  28. </Show>
  29. </div>
  30. </Show>
  31. <Kobalte.Track data-slot="progress-track">
  32. <Kobalte.Fill data-slot="progress-fill" />
  33. </Kobalte.Track>
  34. </Kobalte>
  35. )
  36. }