rounded.mjs 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. // Utilities
  2. import { computed, isRef } from 'vue';
  3. import { getCurrentInstanceName, propsFactory } from "../util/index.mjs"; // Types
  4. // Composables
  5. export const makeRoundedProps = propsFactory({
  6. rounded: {
  7. type: [Boolean, Number, String],
  8. default: undefined
  9. },
  10. tile: Boolean
  11. }, 'rounded');
  12. export function useRounded(props) {
  13. let name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getCurrentInstanceName();
  14. const roundedClasses = computed(() => {
  15. const rounded = isRef(props) ? props.value : props.rounded;
  16. const tile = isRef(props) ? props.value : props.tile;
  17. const classes = [];
  18. if (rounded === true || rounded === '') {
  19. classes.push(`${name}--rounded`);
  20. } else if (typeof rounded === 'string' || rounded === 0) {
  21. for (const value of String(rounded).split(' ')) {
  22. classes.push(`rounded-${value}`);
  23. }
  24. } else if (tile || rounded === false) {
  25. classes.push('rounded-0');
  26. }
  27. return classes;
  28. });
  29. return {
  30. roundedClasses
  31. };
  32. }
  33. //# sourceMappingURL=rounded.mjs.map