bootstrap-5.ts 677 B

12345678910111213141516171819202122
  1. import getMeta from '@/utils/meta'
  2. // The reason this is a function to ensure that meta tag is read before any
  3. // isBootstrap5 check is performed
  4. export const isBootstrap5 = () => getMeta('ol-bootstrapVersion') === 5
  5. export const bsVersion = ({ bs5, bs3 }: { bs5?: string; bs3?: string }) => {
  6. return isBootstrap5() ? bs5 : bs3
  7. }
  8. // get all `aria-*` and `data-*` attributes
  9. export const getAriaAndDataProps = (obj: Record<string, unknown>) => {
  10. return Object.entries(obj).reduce(
  11. (acc, [key, value]) => {
  12. if (key.startsWith('aria-') || key.startsWith('data-')) {
  13. acc[key] = value
  14. }
  15. return acc
  16. },
  17. {} as Record<string, unknown>
  18. )
  19. }