Skip to content

Commit 787d6e4

Browse files
authored
feat: normalize font sizes (#12)
* feat: font normalization and heirlooms page tweaks * feat: portal screen tweaks * feat: bone trader tweaks * feat: buy container tweaks * feat: map view tweaks
1 parent 6382810 commit 787d6e4

File tree

28 files changed

+566
-700
lines changed

28 files changed

+566
-700
lines changed

public/config.js

Lines changed: 54 additions & 55 deletions
Large diffs are not rendered by default.

public/main.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,6 @@ function portalClicked(noUniChange) {
16641664
document.getElementById('inPortalC2Name').innerHTML = (game.global.highestRadonLevelCleared >= 49) ? "<span class='icomoon icon-infinity'></span>" : "2";
16651665
var className = (game.global.highestRadonLevelCleared >= 49) ? "thingColorInfinite" : "thingColorSquared";
16661666
swapClass("thingColor", className, document.getElementById('inPortalC2Button'))
1667-
document.getElementById("challengeDescription").style.height = (getSLevel(true) >= 1) ? "19vw" : "22.5vw";
16681667
document.getElementById("challengeDescriptionPre").innerHTML = (getSLevel(true) >= 1) ? "Don't forget to bring a challenge<br/>" : 'You can also choose to activate a challenge before using your portal. Completing a challenge will earn you a permanent reward. You can abandon or view an active challenge at any time by clicking the "View Perks" button.';
16691668
if (game.global.canRespecPerks) {
16701669
document.getElementById("respecPortalBtn").innerHTML = "Respec";
@@ -5743,7 +5742,6 @@ function hideAdvMaps(displayOnly, hideForVoid){
57435742
document.getElementById('mapsCreateRow').style.paddingBottom = (hidden) ? "1vw" : "0";
57445743
var maps2 = checkAdvMaps2(hidden);
57455744
var mapSize = (hidden) ? "0" : ((maps2) ? "2" : "1");
5746-
swapClass('mapSize', 'mapSize' + mapSize, document.getElementById('mapsHere'));
57475745
}
57485746

57495747
function getUnlockZone(what){
@@ -10013,9 +10011,6 @@ function drawGrid(maps) { //maps t or f. This function overwrites the current gr
1001310011
cell.setAttribute("id", idText + counter);
1001410012
row.appendChild(cell);
1001510013
cell.style.width = (100 / cols) + "%";
10016-
cell.style.paddingTop = ((100 / cols) / 19)+ "vh";
10017-
cell.style.paddingBottom = ((100 / cols) / 19) + "vh";
10018-
cell.style.fontSize = ((cols / 14) + 1) + "vh";
1001910014
var className = "battleCell cellColorNotBeaten"
1002010015
if (maps && game.global.mapGridArray[counter].name == "Pumpkimp") className += " mapPumpkimp";
1002110016
if (maps && map.location == "Void") className += " voidCell";
@@ -10385,7 +10380,6 @@ function toggleMapGridHtml(on, currentMapObj){
1038510380
document.getElementById("mapGrid").style.display = settings[0];
1038610381
if (game.options.menu.extraMapBtns.enabled){
1038710382
swapClass("col-xs", "col-xs-" + settings[1], document.getElementById("extraMapBtns"));
10388-
swapClass("col-xs", "col-xs-" + settings[2], document.getElementById("gridContainer"));
1038910383
}
1039010384
document.getElementById("repeatBtn").style.display = settings[3];
1039110385
if (!on) return;
@@ -16872,7 +16866,9 @@ function toggleVoidMaps(updateOnly){
1687216866
else if (!game.global.preMapsActive) game.global.voidMapsToggled = false;
1687316867
if (!game.global.voidMapsToggled){
1687416868
voidMapsHere.style.display = "none";
16875-
mapsHere.style.display = "block";
16869+
mapsHere.style.display = "flex";
16870+
mapsHere.style.flexFlow = "row wrap";
16871+
mapsHere.style.gap = "1em";
1687616872
mapsCreate.style.display = "block";
1687716873
heirRare.style.display = "none";
1687816874
elem.innerHTML = "Void Maps (" + game.global.totalVoidMaps + ")";

public/updates.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4102,7 +4102,6 @@ function resetGame(keepPortal, resetting) {
41024102
document.getElementById("energyShieldLayer2").style.width = "0%";
41034103
document.getElementById("openTutorialContainer").style.display = "none";
41044104
lookingAtCurrentChallenge = false;
4105-
swapClass("col-xs", "col-xs-10", document.getElementById("gridContainer"));
41064105
swapClass("col-xs", "col-xs-off", document.getElementById("extraMapBtns"));
41074106
mutations.Magma.multiplier = -1;
41084107
mutations.Magma.lastCalculatedMultiplier = -1;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@use "../../styles/sass/variables.scss" as *;
2+
@use "../../styles/sass/mixins" as mixins;
3+
4+
.block {
5+
@include mixins.button();
6+
7+
&_clicking {
8+
cursor: progress;
9+
}
10+
}
11+
12+
.submit {
13+
--local-colour-text-primary: var(--submit-colour-text-primary);
14+
--local-colour-text-secondary: var(--submit-colour-text-secondary);
15+
--local-colour-text-tertiary: var(--submit-colour-text-tertiary);
16+
--local-colour-background-primary: var(--submit-colour-background-primary);
17+
--local-colour-background-secondary: var(
18+
--submit-colour-background-secondary
19+
);
20+
--local-colour-background-tertiary: var(--submit-colour-background-secondary);
21+
}
22+
23+
.positive {
24+
--local-colour-text-primary: var(--positive-colour-text-primary);
25+
--local-colour-text-secondary: var(--positive-colour-text-secondary);
26+
--local-colour-text-tertiary: var(--positive-colour-text-tertiary);
27+
--local-colour-background-primary: var(--positive-colour-background-primary);
28+
--local-colour-background-secondary: var(
29+
--positive-colour-background-secondary
30+
);
31+
--local-colour-background-tertiary: var(
32+
--positive-colour-background-secondary
33+
);
34+
}
35+
.negative {
36+
--local-colour-text-primary: var(--negative-colour-text-primary);
37+
--local-colour-text-secondary: var(--negative-colour-text-secondary);
38+
--local-colour-text-tertiary: var(--negative-colour-text-tertiary);
39+
--local-colour-background-primary: var(--negative-colour-background-primary);
40+
--local-colour-background-secondary: var(
41+
--negative-colour-background-secondary
42+
);
43+
--local-colour-background-tertiary: var(
44+
--negative-colour-background-secondary
45+
);
46+
}

src/components/buttons/base.tsx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { useState } from "react";
2+
import clsx from "clsx";
3+
import {
4+
createBlockComponent,
5+
IBaseComponentPropsWithChildren,
6+
} from "#components/meta";
7+
import type { IClickEvent, IViewType } from "./types";
8+
9+
import styles from "./base.module.scss";
10+
11+
export interface IButtonBaseProps
12+
extends IBaseComponentPropsWithChildren<"button"> {
13+
/**
14+
* A type of the view of button.
15+
* Is not related to `HTMLButtonElement.type`
16+
* because it only affects the looks and not the behaviour.
17+
* For cases like a submit button within a nested dependant form -
18+
* it needs to behave like a submit button, but look like a normal one.
19+
*/
20+
viewType?: IViewType;
21+
onClick?: (event: IClickEvent) => Promise<void> | void;
22+
}
23+
24+
export const ButtonBase = createBlockComponent(styles, Component);
25+
26+
function Component({
27+
className,
28+
viewType = "button",
29+
onClick,
30+
...props
31+
}: IButtonBaseProps) {
32+
const [isClicking, switchClicking] = useState(false);
33+
const blockClass = clsx(
34+
className,
35+
styles[viewType],
36+
isClicking && styles.block_clicking,
37+
);
38+
39+
async function handleClick(event: IClickEvent) {
40+
if (isClicking) {
41+
return;
42+
}
43+
44+
try {
45+
switchClicking(true);
46+
if (onClick) {
47+
await onClick(event);
48+
}
49+
} finally {
50+
switchClicking(false);
51+
}
52+
}
53+
54+
return <button className={blockClass} onClick={handleClick} {...props} />;
55+
}

src/components/buttons/button.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { createBlockComponent } from "#components/meta";
2+
import { ButtonBase, type IButtonBaseProps } from "./base";
3+
4+
export interface IButtonProps
5+
extends Omit<IButtonBaseProps, "type" | "onClick">,
6+
Pick<Required<IButtonBaseProps>, "onClick"> {}
7+
8+
export const Button = createBlockComponent(undefined, Component);
9+
10+
function Component({ ...props }: IButtonProps) {
11+
return <ButtonBase type="button" {...props} />;
12+
}

src/components/buttons/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Button } from "./button";

src/components/buttons/types.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { type MouseEvent as IReactMouseEvent } from "react";
2+
3+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4+
const VIEW_TYPES = [
5+
"button",
6+
"submit",
7+
"reset",
8+
"negative",
9+
"positive",
10+
] as const;
11+
12+
export type IViewType = (typeof VIEW_TYPES)[number];
13+
14+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
15+
export interface IClickEvent
16+
extends IReactMouseEvent<HTMLButtonElement, MouseEvent> {}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import clsx from "clsx";
2+
3+
export type IFuncComponent<PropsType> = (
4+
props: PropsType,
5+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6+
ref?: any,
7+
) => JSX.Element;
8+
9+
interface IBaseProps {
10+
className?: string;
11+
}
12+
13+
interface IBlockStyles {
14+
block?: string;
15+
}
16+
17+
/**
18+
* Concatenates `className` of the component with the `className`
19+
* of the props passed to it, so it could be passed with `{...props}` call.
20+
* @param blockClassName
21+
* Either a `className` string or a `styles` object module.
22+
* The `styles` object always assumes the presence of the `.block` style.
23+
*
24+
* @example
25+
* Without decorator:
26+
* ```tsx
27+
* import type { ComponentPropsWithoutRef } from "react";
28+
*
29+
* import styles from "./base.module.scss";
30+
*
31+
* interface IProps extends ComponentPropsWithoutRef<"button"> {}
32+
*
33+
* export function Button({ className, ...props }: IProps) {
34+
* return <button className={`${styles.block} ${className}`} {...props} />;
35+
* }
36+
* ```
37+
* @example
38+
* With decorator:
39+
* ```tsx
40+
* import type { ComponentPropsWithoutRef } from "react";
41+
* import { createBlockComponent } from "@repo/ui/meta";
42+
*
43+
* import styles from "./base.module.scss";
44+
*
45+
* interface IProps extends ComponentPropsWithoutRef<"button"> {}
46+
*
47+
* export const Button = createBlockComponent(styles, Component);
48+
*
49+
* function Component({ ...props }: IProps) {
50+
* return <button {...props} />;
51+
* }
52+
* ```
53+
*/
54+
export function createBlockComponent<Props extends IBaseProps = IBaseProps>(
55+
blockClassName: IBlockStyles | string | undefined,
56+
functionComponent: IFuncComponent<Props>,
57+
): typeof functionComponent {
58+
return (...args: Parameters<typeof functionComponent>) => {
59+
const [props, ref] = args;
60+
const baseClassName =
61+
typeof blockClassName === "string"
62+
? blockClassName
63+
: blockClassName?.block;
64+
const className = clsx(baseClassName, props.className);
65+
66+
return functionComponent({ ...props, className }, ref);
67+
};
68+
}

src/components/meta/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export { createBlockComponent } from "./block-component";
2+
export type {
3+
IBaseComponentProps,
4+
IBaseComponentPropsWithChildren,
5+
} from "./types";

0 commit comments

Comments
 (0)