mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-26 18:51:50 +02:00
* Remove skipLoadingStyleSheet * Remove unused bootstrap-5 assignment from the Account settings page since it's archived * Remove bsVersionIcon * Remove bsVersion, bootstrapVersion and isBootstrap5 from elements on the IDE page * Remove BS3Dropdown from the context menu * Cleanup Bootstrap 3 related comment and type GitOrigin-RevId: a67244eb78943ee84cc5f89bae164c0361e8fc13
27 lines
920 B
TypeScript
27 lines
920 B
TypeScript
import getMeta from '@/utils/meta'
|
|
|
|
// The reason this is a function is to ensure that the meta tag is read before
|
|
// any isBootstrap5 check is performed
|
|
export const isBootstrap5 = () => getMeta('ol-bootstrapVersion') === 5
|
|
|
|
/* eslint-disable no-redeclare */
|
|
export function bsVersion<A>({ bs5 }: { bs5: A }): A | undefined
|
|
export function bsVersion<B>({ bs3 }: { bs3: B }): B | undefined
|
|
export function bsVersion<A, B>({ bs5, bs3 }: { bs5: A; bs3: B }): A | B
|
|
export function bsVersion({ bs5, bs3 }: { bs5?: unknown; bs3?: unknown }) {
|
|
return isBootstrap5() ? bs5 : bs3
|
|
}
|
|
|
|
// get all `aria-*` and `data-*` attributes
|
|
export const getAriaAndDataProps = (obj: Record<string, unknown>) => {
|
|
return Object.entries(obj).reduce(
|
|
(acc, [key, value]) => {
|
|
if (key.startsWith('aria-') || key.startsWith('data-')) {
|
|
acc[key] = value
|
|
}
|
|
return acc
|
|
},
|
|
{} as Record<string, unknown>
|
|
)
|
|
}
|