Skip to content

Commit

Permalink
dev: Added configuration module for static components
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-crowell committed Jun 18, 2024
1 parent e218a10 commit b0cd9d8
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
9 changes: 4 additions & 5 deletions packages/ui/src/components/Image/Image.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use client';

import React from 'react';
import { DoobUiContext } from '@do-ob/ui/context';
import { configUI } from '@do-ob/ui/config';
import { Image as NextUIImage, ImageProps } from '@nextui-org/react';

export function Image(props: ImageProps) {

const { image } = React.useContext(DoobUiContext);
const image = configUI.get('image');

console.log('image', image);

return (
<NextUIImage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NavbarBrand, Link } from '@nextui-org/react';
import { Image } from '@do-ob/ui/components';
import { NavigationProps } from '../data/NavigationProps';
import { clsx } from '@do-ob/core';

/**
* Navigation Brand component
Expand All @@ -19,12 +20,10 @@ export function NavigationPart_Brand({ base: {
<Image
src={logo}
alt={title}
width={40}
height={40}
className={classNames?.logo}
classNames={{
wrapper: 'w-[40px] h-[40px]',
}}
width={0}
height={0}
loading="eager"
className={clsx('h-[40px] w-auto',classNames?.logo)}
/>
) : null}
<h1 className="hidden text-3xl tracking-tight md:inline">{title}</h1>
Expand Down
39 changes: 39 additions & 0 deletions packages/ui/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

/**
* The configuration object for the application.
*/
export interface ConfiUI {

/**
* The image node to use.
*/
image?: React.ElementType<any>;

}

/**
* The configuration object that should persist throughout the application.
*/
const configuration: ConfiUI = {};

/**
* This object is exported to provide a way to expose configuration settings.
*/
export const configUI = {

/**
* Initializes the configuration.
*/
init(config: ConfiUI) {
Object.assign(configuration, config);
},

/**
* Gets the configuration based on the key.
*/
get<K extends keyof ConfiUI>(key: K): ConfiUI[K] {
return configuration[key];
}

};

0 comments on commit b0cd9d8

Please sign in to comment.