Skip to content

Commit a885234

Browse files
committed
skins: Updated Windows 95 skin
1 parent dfdca49 commit a885234

13 files changed

Lines changed: 128 additions & 50 deletions

File tree

demo/src/Main.tsx

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
1-
import { ReactElement, useEffect, useState } from "react";
1+
import { ReactElement } from "react";
22
import { defaultSkin } from "./config/skin.config";
33
import { NAME, TAG_LINE } from "./config/branding.config";
44
import { appsConfig } from "./config/apps.config";
5-
import { getViewportParams, ProzillaOS, Router } from "prozilla-os";
5+
import { getViewportParams, ProzillaOS, Router, useLazyRef } from "prozilla-os";
66
import { macOsSkin, minimalSkin, pixelSkin, windows95Skin } from "@prozilla-os/skins";
77

88
export function Main(): ReactElement {
9-
const [skin, setSkin] = useState(defaultSkin);
10-
11-
useEffect(() => {
9+
const skinRef = useLazyRef(() => {
1210
const params = getViewportParams();
1311

14-
if (params.skin == null)
15-
return;
16-
17-
switch (params.skin) {
18-
case "mac":
19-
setSkin(macOsSkin);
20-
break;
21-
case "minimal":
22-
setSkin(minimalSkin);
23-
break;
24-
case "pixel":
25-
setSkin(pixelSkin);
26-
break;
27-
case "win95":
28-
setSkin(windows95Skin);
29-
break;
12+
if (params.skin != null) {
13+
switch (params.skin) {
14+
case "mac":
15+
return macOsSkin;
16+
case "minimal":
17+
return minimalSkin;
18+
case "pixel":
19+
return pixelSkin;
20+
case "win95":
21+
return windows95Skin;
22+
}
3023
}
31-
}, []);
24+
25+
return defaultSkin;
26+
});
3227

3328
return <ProzillaOS
3429
systemName={NAME}
3530
tagLine={TAG_LINE}
36-
skin={skin}
31+
skin={skinRef.current}
3732
config={{
3833
apps: appsConfig,
3934
}}

packages/apps/terminal/src/components/InputLine.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeEvent, CSSProperties, KeyboardEvent, MutableRefObject, useState } from "react";
1+
import { ChangeEvent, CSSProperties, KeyboardEvent, RefObject, useState } from "react";
22
import styles from "./Terminal.module.css";
33
import { Ansi } from "./Ansi";
44

@@ -9,7 +9,7 @@ interface InputLineProps {
99
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
1010
onKeyUp?: (event: KeyboardEvent<HTMLInputElement>) => void;
1111
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
12-
inputRef: MutableRefObject<HTMLInputElement>;
12+
inputRef: RefObject<HTMLInputElement>;
1313
}
1414

1515
export function InputLine({ value, prefix, onChange, onKeyUp, onKeyDown, inputRef }: InputLineProps) {

packages/apps/terminal/src/components/Terminal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeEventHandler, KeyboardEventHandler, MouseEventHandler, MutableRefObject, useEffect, useRef, useState } from "react";
1+
import { ChangeEventHandler, KeyboardEventHandler, MouseEventHandler, useEffect, useRef, useState } from "react";
22
import styles from "./Terminal.module.css";
33
import { OutputLine } from "./OutputLine";
44
import { InputLine } from "./InputLine";
@@ -396,7 +396,7 @@ export function Terminal({ app, path: startPath, input, setTitle, close: exit, a
396396
prefix={prefix}
397397
onKeyDown={onKeyDown}
398398
onChange={onChange}
399-
inputRef={inputRef as unknown as MutableRefObject<HTMLInputElement>}
399+
inputRef={inputRef}
400400
/>
401401
: <OutputLine text={streamOutput ?? ""}/>
402402
}

packages/core/src/components/actions/Actions.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useShortcuts } from "../../hooks/_utils/keyboard";
33
import styles from "./Actions.module.css";
44
import { useScreenBounds } from "../../hooks/_utils/screen";
55
import { ActionsManager } from "../../features/actions/actionsManager";
6+
import { useClassNames } from "../../hooks";
67

78
export interface ActionProps {
89
/** ID of the action. */
@@ -115,7 +116,7 @@ export function Actions({ children, mode, className, onAnyTrigger, triggerParams
115116
if (!initiated)
116117
classNames.push(styles.Uninitiated);
117118

118-
return <div ref={ref as Ref<HTMLDivElement>} className={classNames.join(" ")}>
119+
return <div ref={ref as Ref<HTMLDivElement>} className={useClassNames(classNames, "Actions", undefined, mode)}>
119120
{iterateOverChildren(children)}
120121
</div>;
121122
}

packages/core/src/components/actions/actions/ClickAction.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { IconProp } from "@fortawesome/fontawesome-svg-core";
55
import { ActionProps } from "../Actions";
66
import { formatShortcut } from "../../../features";
77
import { ImagePreview } from "../../_utils/directory-list/ImagePreview";
8+
import { useClassNames } from "../../../hooks";
89

910
export interface ClickActionProps extends ActionProps {
1011
icon?: string | object;
@@ -15,8 +16,8 @@ export const ClickAction = memo(({ actionId, label, shortcut, disabled, onTrigge
1516
if (disabled)
1617
classNames.push(styles.Disabled);
1718

18-
return (<button key={actionId} className={classNames.join(" ")} tabIndex={0} disabled={disabled} onClick={onTrigger as unknown as MouseEventHandler}>
19-
<span className={styles.Label}>
19+
return <button key={actionId} className={useClassNames(classNames, "Actions", "Click")} tabIndex={0} disabled={disabled} onClick={onTrigger as unknown as MouseEventHandler}>
20+
<span className={useClassNames([styles.Label], "Actions", "Label")}>
2021
{icon && <div className={styles.Icon}>
2122
{typeof icon == "string"
2223
? <ImagePreview source={icon} className={styles.ImageIcon}/>
@@ -26,5 +27,5 @@ export const ClickAction = memo(({ actionId, label, shortcut, disabled, onTrigge
2627
<p>{label}</p>
2728
</span>
2829
{shortcut && <p className={styles.Shortcut}>{formatShortcut(shortcut)}</p>}
29-
</button>);
30+
</button>;
3031
});
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { useClassNames } from "../../../hooks";
12
import styles from "../Actions.module.css";
23

34
export function Divider() {
4-
return <div className={styles.Divider}/>;
5+
return <div className={useClassNames([styles.Divider], "Actions", "Divider")}/>;
56
}

packages/core/src/components/actions/actions/DropdownAction.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { faCaretRight, IconDefinition } from "@fortawesome/free-solid-svg-icons"
44
import { ReactElement, useState } from "react";
55
import { ActionProps } from "../Actions";
66
import { OutsideClickListener } from "../../../hooks/_utils/outsideClick";
7+
import { useClassNames } from "../../../hooks";
78

89
export interface DropdownActionProps extends ActionProps {
910
showOnHover?: boolean;
@@ -22,7 +23,7 @@ export function DropdownAction({ label, icon, children, showOnHover = true }: Dr
2223
}}>
2324
<div
2425
key={label}
25-
className={classNames.join(" ")}
26+
className={useClassNames(classNames, "Actions", "Dropdown")}
2627
tabIndex={0}
2728
onMouseEnter={() => {
2829
if (showOnHover)
@@ -37,12 +38,12 @@ export function DropdownAction({ label, icon, children, showOnHover = true }: Dr
3738
setShowContent(!showContent);
3839
}}
3940
>
40-
<span className={styles.Label}>
41+
<span className={useClassNames([styles.Label], "Actions", "Label")}>
4142
{icon && <div className={styles.Icon}><FontAwesomeIcon icon={icon as IconDefinition}/></div>}
4243
<p>{label}</p>
4344
</span>
4445
<div className={styles.DropdownArrow}><FontAwesomeIcon icon={faCaretRight}/></div>
45-
<div className={styles.DropdownContent}>
46+
<div className={useClassNames([styles.DropdownContent], "Actions", "Content")}>
4647
{children}
4748
</div>
4849
</div>

packages/core/src/components/actions/actions/RadioAction.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { faCircleDot } from "@fortawesome/free-solid-svg-icons";
55
import { ReactElement, useState } from "react";
66
import { faCircle } from "@fortawesome/free-regular-svg-icons";
77
import { ActionProps } from "../Actions";
8+
import { useClassNames } from "../../../hooks";
89

910
export interface RadioActionProps extends ActionProps {
1011
options: {
@@ -17,13 +18,13 @@ export interface RadioActionProps extends ActionProps {
1718
export function RadioAction({ actionId, options, initialIndex, onTrigger }: RadioActionProps): ReactElement {
1819
const [activeIndex, setActiveIndex] = useState(initialIndex ?? 0);
1920

20-
return (<div key={actionId}>
21+
return <div key={actionId} className={useClassNames([], "Actions", "Radio")}>
2122
{options.map(({ label, shortcut }, index) =>
2223
<button key={label} className={styles.Button} tabIndex={0} onClick={(event) => {
2324
setActiveIndex(index);
2425
onTrigger?.(event as unknown as Event, index);
2526
}}>
26-
<span className={styles.Label}>
27+
<span className={useClassNames([styles.Label], "Actions", "Label")}>
2728
<div className={styles.Icon}>
2829
{activeIndex === index
2930
? <FontAwesomeIcon icon={faCircleDot}/>
@@ -35,5 +36,5 @@ export function RadioAction({ actionId, options, initialIndex, onTrigger }: Radi
3536
{shortcut && <p className={styles.Shortcut}>{formatShortcut(shortcut)}</p>}
3637
</button>
3738
)}
38-
</div>);
39+
</div>;
3940
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { ReactNode } from "react";
22
import styles from "../Actions.module.css";
3+
import { useClassNames } from "../../../hooks";
34

45
export interface TextDisplayProps {
56
children: ReactNode;
67
}
78

89
export function TextDisplay({ children }: TextDisplayProps) {
9-
return <p className={styles.TextDisplay}>
10+
return <p className={useClassNames([styles.TextDisplay], "Actions", "Text")}>
1011
{children}
1112
</p>;
1213
}

packages/core/src/components/actions/actions/ToggleAction.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ReactElement, useState } from "react";
55
import { faSquare } from "@fortawesome/free-regular-svg-icons";
66
import { faSquareCheck } from "@fortawesome/free-solid-svg-icons";
77
import { ActionProps } from "../Actions";
8+
import { useClassNames } from "../../../hooks";
89

910
export interface ToggleActionProps extends ActionProps {
1011
initialValue: boolean;
@@ -13,11 +14,11 @@ export interface ToggleActionProps extends ActionProps {
1314
export function ToggleAction({ actionId, label, shortcut, initialValue, onTrigger }: ToggleActionProps): ReactElement {
1415
const [active, setActive] = useState(initialValue ?? false);
1516

16-
return (<button key={actionId} className={styles.Button} tabIndex={0} onClick={(event) => {
17+
return <button key={actionId} className={useClassNames([styles.Button], "Actions", "Toggle", active ? "Active" : undefined)} tabIndex={0} onClick={(event) => {
1718
onTrigger?.(event as unknown as Event, !active);
1819
setActive(!active);
1920
}}>
20-
<span className={styles.Label}>
21+
<span className={useClassNames([styles.Label], "Actions", "Label")}>
2122
<div className={styles.Icon}>
2223
{active
2324
? <FontAwesomeIcon icon={faSquareCheck}/>
@@ -27,5 +28,5 @@ export function ToggleAction({ actionId, label, shortcut, initialValue, onTrigge
2728
<p>{label}</p>
2829
</span>
2930
{shortcut && <p className={styles.Shortcut}>{formatShortcut(shortcut)}</p>}
30-
</button>);
31+
</button>;
3132
}

0 commit comments

Comments
 (0)