Skip to content

Commit

Permalink
fix(*): gecut context update
Browse files Browse the repository at this point in the history
  • Loading branch information
MM25Zamanian committed Sep 22, 2024
1 parent 862e051 commit a7ab1d3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import 'unfonts.css';

import './ui/app-index';
import './ui/app-index.js';
6 changes: 3 additions & 3 deletions src/signal/color.context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ const lightness = params.get('l');
export type HSLColor = {hue: string; saturation: string; lightness: string};
export const colorContext = new ContextSignal<HSLColor>('color');

colorContext.setValue({
colorContext.value = {
hue: hue ?? json.get('HTB.HUE', '0'),
saturation: saturation ?? json.get('HTB.SATURATION', '0'),
lightness: lightness ?? json.get('HTB.LIGHTNESS', '0'),
});
};

colorContext.subscribe(
debounce((color: HSLColor) => {
const hex = chroma.hsl(Number(color.hue), Number(color.saturation) / 100, Number(color.lightness) / 100).hex('rgb');
themeContext.setValue(hex);
themeContext.value = hex;

json.set('HTB.HUE', color.hue);
json.set('HTB.SATURATION', color.saturation);
Expand Down
2 changes: 1 addition & 1 deletion src/signal/theme.context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ themeContext.subscribe((sourceColor) => {
document.documentElement.style.setProperty(key, color);
}

paletteContext.setValue(themeFromSourceColor(argbFromHex(sourceColor)));
paletteContext.value = themeFromSourceColor(argbFromHex(sourceColor));
});
8 changes: 4 additions & 4 deletions src/ui/components/footer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import {paletteContext} from '../../signal/palette.context.js';
const colorPickerChange = debounce((event: InputEvent) => {
const target = event.target as HTMLInputElement;

const color = colorContext.getValue();
const color = colorContext.value;

colorContext.setValue({
colorContext.value = {
hue: '0',
lightness: '0',
saturation: '0',
...color,
[target.name]: target.value.toString(),
});
};
}, 1000 / 60);

export function footer() {
const color = colorContext.getValue();
const color = colorContext.value;

return html`
<footer class="fixed bottom-0 inset-x-0 bg-surfaceContainer translucent flex flex-col p-4">
Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function header() {
events: {
click: async (event) => {
const target = event.target as HTMLElement;
const color = colorContext.getValue();
const color = colorContext.value;
if (!color) return;
Expand All @@ -86,7 +86,7 @@ export function header() {
const target = event.target as HTMLElement;
const download = () =>
new Promise<void>((resolve) => {
const fileName = 'h' + Math.ceil(Hct.fromInt(argbFromHex(themeContext.getValue() ?? '#000')).hue) + '.css';
const fileName = 'h' + Math.ceil(Hct.fromInt(argbFromHex(themeContext.value ?? '#000')).hue) + '.css';
const a = document.createElement('a'); // Create "a" element
const blob = new Blob([':root{', document.documentElement.getAttribute('style') ?? '', '}'], {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export function resolveRouterPath(unresolvedPath?: string) {
}

export const debouncedRender = debounce(() => {
routerContext.setValue(router.render());
titleContext.setValue(router.context.title);
routerContext.value = router.render();
titleContext.value = router.context.title;
}, 1000 / 60);

router.addEventListener('route-changed', debouncedRender);

0 comments on commit a7ab1d3

Please sign in to comment.