Skip to content

Commit

Permalink
quick fix to dark mode support
Browse files Browse the repository at this point in the history
  • Loading branch information
vzaidman committed Dec 29, 2024
1 parent 5e927f2 commit 1562bfc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ Optionally you can pass in `options` as the second parameter. The following opti
- `titleColor`
- `diffNameColor`
- `diffPathColor`
- `textBackgroundColor`
- `notifier: ({Component, displayName, hookName, prevProps, prevState, prevHookResult, nextProps, nextState, nextHookResult, reason, options, ownerDataMap}) => void`
- `getAdditionalOwnerData: (element) => {...}`

Expand Down Expand Up @@ -328,10 +329,11 @@ If you don't want to use `console.group` to group logs you can print them as sim

Grouped logs can be collapsed.

#### titleColor / diffNameColor / diffPathColor
#### titleColor / diffNameColor / diffPathColor / textBackgroundColor
##### (default titleColor: `'#058'`)
##### (default diffNameColor: `'blue'`)
##### (default diffPathColor: `'red'`)
##### (default textBackgroundColor: `'white`)

Controls the colors used in the console notifications

Expand Down
6 changes: 4 additions & 2 deletions src/defaultNotifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ function logDifference({Component, displayName, hookName, prefixMessage, diffObj
}
wdyrStore.options.consoleGroup(
`%c${diffObjType === 'hook' ? `[hook ${hookName} result]` : `${diffObjType}.`}%c${pathString}%c`,
`color:${wdyrStore.options.diffNameColor};`, `color:${wdyrStore.options.diffPathColor};`, 'color:default;'
`background-color: ${wdyrStore.options.textBackgroundColor};color:${wdyrStore.options.diffNameColor};`,
`background-color: ${wdyrStore.options.textBackgroundColor};color:${wdyrStore.options.diffPathColor};`,
'background-color: ${wdyrStore.options.textBackgroundColor};color:default;'
);
wdyrStore.options.consoleLog(
`${diffTypesDescriptions[diffType]}. (more info at ${hookName ? moreInfoHooksUrl : moreInfoUrl})`,
Expand Down Expand Up @@ -76,7 +78,7 @@ export default function defaultNotifier(updateInfo) {
return;
}

wdyrStore.options.consoleGroup(`%c${displayName}`, `color: ${wdyrStore.options.titleColor};`);
wdyrStore.options.consoleGroup(`%c${displayName}`, `background-color: ${wdyrStore.options.textBackgroundColor};color: ${wdyrStore.options.titleColor};`);

let prefixMessage = 'Re-rendered because';

Expand Down
1 change: 1 addition & 0 deletions src/normalizeOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function normalizeOptions(userOptions = {}) {
titleColor: '#058',
diffNameColor: 'blue',
diffPathColor: 'red',
textBackgroundColor: 'white',
trackExtraHooks: [],
trackAllPureComponents: false,
...userOptions,
Expand Down
3 changes: 2 additions & 1 deletion types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ export interface WhyDidYouRenderOptions {
titleColor?: string;
diffNameColor?: string;
diffPathColor?: string;
textBackgroundColor?: string;
notifier?: Notifier;
customName?: string;
}

export type WhyDidYouRenderComponentMember = WhyDidYouRenderOptions|boolean
export type WhyDidYouRenderComponentMember = WhyDidYouRenderOptions | boolean

export type Notifier = (options: UpdateInfo) => void

Expand Down

0 comments on commit 1562bfc

Please sign in to comment.