secureweb/sweb/src/lib/create-context.ts
Mahmoud Emad 4c6ce31b20 feat: Add Tailwind CSS and UI components
- Updated project to use Tailwind CSS for styling.
- Added new UI components including Navbar, Sidebar, Footer,
  Accordion, and Button.
- Created markdown content page for documentation.
- Improved overall structure and design of the application.
2025-05-11 16:10:53 +03:00

17 lines
403 B
TypeScript

import { getContext, hasContext, setContext } from 'svelte';
export function createContext<T>() {
const key = Symbol();
return {
get: () => {
if (!hasContext(key)) {
throw new Error('Context was not set');
}
return getContext<T>(key);
},
set: (context: T) => {
setContext(key, context);
}
};
}