Skip to content

Commit

Permalink
fix deep source issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank1513 committed Jun 9, 2024
1 parent 1545d2a commit 6e904c4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/src/client/switch/switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface SwitchProps extends HTMLProps<HTMLElement> {
*/
export const Switch = ({ tag: Tag = "button", size = 24, skipSystem, ...props }: SwitchProps) => {
const [state, setState] = useStore();
/** toggle mode */
const handleModeSwitch = () => {
let index = modes.indexOf(state.m);
if (skipSystem && index === modes.length - 1) index = 0;
Expand All @@ -40,6 +41,7 @@ export const Switch = ({ tag: Tag = "button", size = 24, skipSystem, ...props }:
// @ts-expect-error -> we are setting the CSS variable
style={{ "--size": `${size}px` }}
data-testid="switch"
// skipcq: JS-0417 -> tradeoff between size and best practices
onClick={handleModeSwitch}
/>
);
Expand Down
1 change: 1 addition & 0 deletions lib/src/hooks/use-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface UseModeYeild {
*/
export const useMode = (): UseModeYeild => {
const [{ m: mode, s: systemMode }, setState] = useStore();
/** Set user preference */
const setMode = (m: ColorSchemePreference) => {
setState(prev => ({ ...prev, m }));
};
Expand Down
1 change: 1 addition & 0 deletions lib/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ const DEFAULT_STORE_VAL: Store = {
s: DARK as ResolvedScheme,
};

/** local abstaction of RGS to avoid multiple imports */
export const useStore = () => useRGS<Store>("ndm", DEFAULT_STORE_VAL);
4 changes: 2 additions & 2 deletions scripts/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ try {
}

const { version: VERSION, name } = require("../lib/package.json");
let LATEST_VERSION;
let LATEST_VERSION = "0.0.-1";

try {
LATEST_VERSION = execSync(`npm view ${name} version`).toString() ?? "0.0.-1";
} catch {
LATEST_VERSION = "0.0.-1";
// empty
}

console.log({ VERSION, LATEST_VERSION });
Expand Down

0 comments on commit 6e904c4

Please sign in to comment.