廓形仪rn版本-技术调研
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
970 B

  1. 'use client';
  2. import React from 'react';
  3. import { tva } from '@gluestack-ui/nativewind-utils/tva';
  4. import { Platform, View } from 'react-native';
  5. import type { VariantProps } from '@gluestack-ui/nativewind-utils';
  6. const dividerStyle = tva({
  7. base: 'bg-background-200',
  8. variants: {
  9. orientation: {
  10. vertical: 'w-px h-full',
  11. horizontal: 'h-px w-full',
  12. },
  13. },
  14. });
  15. type IUIDividerProps = React.ComponentPropsWithoutRef<typeof View> &
  16. VariantProps<typeof dividerStyle>;
  17. const Divider = React.forwardRef<
  18. React.ComponentRef<typeof View>,
  19. IUIDividerProps
  20. >(function Divider({ className, orientation = 'horizontal', ...props }, ref) {
  21. return (
  22. <View
  23. ref={ref}
  24. {...props}
  25. aria-orientation={orientation}
  26. role={Platform.OS === 'web' ? 'separator' : undefined}
  27. className={dividerStyle({
  28. orientation,
  29. class: className,
  30. })}
  31. />
  32. );
  33. });
  34. Divider.displayName = 'Divider';
  35. export { Divider };