Skip to content

Commit

Permalink
fix: null coalish and theme variables
Browse files Browse the repository at this point in the history
  • Loading branch information
davidecarpini committed Jan 8, 2024
1 parent 2c7f40a commit 517d17d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/dapp-kit-ui/src/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const createModalIfNotPresent = (options?: {

const newModal = document.createElement('vdk-modal');

(options?.modalParent || document.body).appendChild(newModal);
(options?.modalParent ?? document.body).appendChild(newModal);

return newModal;
};
Expand Down
8 changes: 4 additions & 4 deletions packages/dapp-kit-ui/src/utils/ui-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { type DAppKitUIOptions } from '../client';
import { Colors, Font, modalZIndex, defaultI18n } from '../constants';

const StyleVariables = {
const ThemeVariables = {
'--vdk-color-dark-primary': Colors.Dark.Primary.toString(),
'--vdk-color-dark-primary-hover': Colors.Dark.PrimaryHover.toString(),
'--vdk-color-dark-primary-active': Colors.Dark.PrimaryActive.toString(),
Expand All @@ -25,18 +25,18 @@ const StyleVariables = {
'--vdk-modal-z-index': modalZIndex.toString(),
};

export type StyleVariables = keyof typeof StyleVariables;
export type ThemeVariables = keyof typeof ThemeVariables;

export type CustomizedStyle = {
[key in StyleVariables]?: string;
[key in ThemeVariables]?: string;
};

export const initStyles = (customizedStyle: CustomizedStyle): void => {
const root: HTMLElement | null = document.querySelector(':root');

if (root) {
for (const [key, value] of Object.entries({
...StyleVariables,
...ThemeVariables,
...customizedStyle,
})) {
root.style.setProperty(key, value);
Expand Down

0 comments on commit 517d17d

Please sign in to comment.