sk-oidc-oauth
Version:
OIDC/OAuth2 authentication and authorization for prerendered/client-side-rendered SvelteKit apps.
37 lines (36 loc) • 1.22 kB
JavaScript
import { mediaQuery } from 'svelte-legos';
import { twMerge } from 'tailwind-merge';
export const cn = (...inputs) => twMerge(...inputs);
/**
* Checks if the current path matches the path to match.
* @param currentPath the current path of the app
* @param pathToMatch the path to match
* @returns boolean
*/
export const doesPathMatch = (currentPath, pathToMatch) => {
return currentPath === pathToMatch;
};
export const getInitials = (name) => {
if (!name) {
return 'NA';
}
const firstInitial = name.charAt(0).toUpperCase();
const lastInitial = name.charAt(name.lastIndexOf(' ') + 1).toUpperCase();
return firstInitial + lastInitial;
};
export const isMinWidthSm = () => mediaQuery('(min-width: 640px)');
/**
* Shows an error toast.
* @param toastStore - the {@link https://www.skeleton.dev/utilities/toasts#toast-store | skeleton toast store}
* @param message - the message to show
*/
export const errorToast = (toastStore, message) => {
toastStore.trigger({
message,
background: 'variant-ghost-error',
classes: 'break-words',
hoverable: true,
timeout: 15000, // 15 seconds
});
};
export const doubleThem = (a, b) => a * b;